# n Mod -m: Max vs. Matlab

Today I was working on a little acoustics simulation patcher in Cycling 74’s Max, and part of the code required the use of a modulo function. No problem, right?

Problem. I originally wrote the code in Matlab, and I was porting it to Max; and the numbers just weren’t working properly. After getting rid of my own home-made bugs, it still wasn’t working…

Turns out that there seems to be a disagreement in the code community about how to do the modulo of a negative number.

The best indication of the problem I was facing is found on this page, where you can see that different languages come up with different answers for -13 mod 3 and 13 mod -3. The problem is that neither Max nor Matlab are in the list. So: here are the results of those two, to add to the list.

The results are:

This means that Matlab behaves like Python, using the formula

mod(a, n) = a – n * floor(a / n)

whereas Max behaves like C and Java.

So, if you, like me, move back and forth between Matlab and Max, beware!

# Typical Errors in Digital Audio: Part 4 – Ode to Billy Joe

It was the third of June, another sleepy, dusty Delta day
I was out choppin’ cotton, and my brother was balin’ hay

I’ve always liked the song “Ode to Billy Joe”. It starts on a 7-chord, so you know it’s going to go somewhere… I love how Papa, when he hears that Billy Joe jumped off the Tallahatchie Bridge just says that he “never had a lick of sense”, and asks for more biscuits. And who, exactly, did Brother Taylor see with Billy Joe? What did they throw off the bridge?

I like the fact that there are many questions and few answers – and life just goes on anyway…

But we’re not here to talk about songwriting, we’re here to talk about typical errors in digital audio – specifically today – streaming services.

This error is an easy one to discuss – but an important one nonetheless…

When I’m sitting at work, typing on my computer, I listen to music a lot. Usually, I use the “Audirvana” software on my Mac, with an external Teac UD-501 USB-Audio headphone DAC (which does the digital-to-analogue conversion and the amplification for the headphones, all in one box). The reasons I choose to use Audirvana are (1) that it can play all of my files (I have some DSD stuff on my hard drive), it can stream directly to my external DAC without routing the audio through Mac’s OS, and it can also see my Tidal account.

Now, just to be clear, this posting is not an advertisement for Apple, Audirvana, Teac, or Tidal. I mention all of that just as background information… I also drive an 11-year old base-model Honda Civic (that will come up later in this posting) and I wear Ecco shoes (which is completely irrelevant…).

If you use Audirvana to search Tidal for tracks called “Ode to Billy Joe” You will get 300 hits. I don’t know if this is because there are 300 covers of that song on Tidal (I doubt it) or if 300 is a limit on the number of tracks either Tidal or Audirvana will report in a Search function (I suspect that this is the case…)

As you can see in the screenshot in Figure 1, all of them are 16 bit, 44.1 kHz files. So far so good…

I have two favourite versions of this song. One of them is by Paula Cole (the other is by Patty Smyth). If I press “play” on the Paul Cole version, and I look at the top of the screen, I see something like the screenshot in Figure 2.

One of the nice things about Audirvana is that it tells you a little technical information about the track to which you’re listening. Notice there on the right-hand side of the screenshot above, that we’re listening to a 16-bit, 44.1 kHz FLAC file.

This makes sense. In fact, it’s what I expect, since my Tidal subscription promises “lossless high fidelity sound quality” – that’s why I pay extra for a Tidal HiFi subscription…

So far so good.

One of my less-favourite renditions of “Ode to Billy Joe” is performed by The Stadium Saxophone Players on their album “Timeless Sax Instrumentals – Volume 2”. IF I press play on this version, and look at the top of my Audirvana window, I see the information in Figure 3.

Interesting…. Notice that I am now listening to a 96 kbps AAC file with a 16-bit word length, and a sampling rate of “22.1 kHz” (actually 22.05 kHz – half of 44.1). So much for “lossless high fidelity sound quality”.

This calls for more investigation.

So, I pressed “Play” on the top hits in my search, one by one, and checked the file format displayed on the screen. The results of this “test” was that, in the first 66 “Ode to Billy Joe’s” listed, 6 of them were 96 kbps AAC files, 60 of them were FLAC.

So, for this sampling, roughly 9% of the available tracks were not in a lossless format, and were not even full bandwidth. Admittedly, the tracks that were in the lower-quality format were versions that I would not listen to anyway – so, to be honest, I don’t really care too much.

Now, before you mis-interpret me, I want to be very explicit and state that this is NOT Tidal’s fault. Of course they did not ask for an AAC version of the file they put on their hard drives. This was the file format supplied to them by the record label (to use an increasingly old-fashioned term…). So, we can’t blame Tidal for this – and I’m quite certain that they’re not the only streaming service that “suffers” from this issue.

However, what my little test shows is that what Tidal is actually selling me is the capability of streaming “lossless high fidelity sound quality” – and not a guarantee that what is in the “pipe” really is lossless.

Of course, this is not just true for streaming services. Other people have shown that some higher-priced “high resolution” audio files that you can purchase online are actually just a bit-for-bit copy of the “normal resolution” version of the same track. I have at least one CD that contains at least one track that has MP3 artefacts obvious enough that I can hear them on my unbranded audio system in my 11-year old Honda Civic while I’m driving… (It’s a compilation disc, so I guess the label was supplied with an MP3 version that they decoded to PCM and put on the CD.)

So, just like Ode to Billy Joe – there are some questions here… and you don’t need to know much about digital audio to answer them… But the basic moral of this part of the story is that the format that is used to deliver your music is not a guarantee of higher quality…

# No more FTP on a Mac!????

I am not impressed! Apparently, Apple has decided that FTP shall no longer be available as a Unix command in the Terminal window as of 10.13.x (High Sierra)…

All I get is a message that says “ftp: command not found”. You have GOT to be kidding me…

Grrrrr….

According to this link I’m not alone…

# My 3 favourite “secret” Mac moves

Okay, okay, they’re not secrets… But it seems that, whenever I do one of these, and a “Mac person” is watching over my shoulder, they ask “how did you do that?”

I’m sure that there are Windows equivalents to all of these – but I’ve lived on a Mac for almost 30 years… Been a long time since I switched from an x86 machine to my brand-new Mac Classic!

## Small steps in volume and brightness changes

Before pressing the “volume up” or “volume down” buttons, hold down OPTION+SHIFT. This will give you 4 times as many volume steps.

The same works for screen brightness and keyboard brightness.

## Switching Safari tabs

Version 1: COMMAND + number will bring you directly to a tab.

Version 2: COMMAND+SHIFT + left/right arrow keys will move you left and right through your tabs. (Note that this one will not work with some webpages. For example, if you’re editing a WordPress posting, then this function is disabled on that tab.)

Note that, in the Finder, the second of these will work the same. The first will not – COMMAND+number in the Finder will change your view instead…

## FIND in open Safari Tabs

• Open up a bunch of different pages in different tabs in a Safari window
• Show all tabs (under the VIEW menu)
• Press COMMAND-F for find
• Start typing a word – Safari will automatically start showing only the tabs that contain the search word