## Tuesday, 25 February 2020

### 256 oscillators (I mis-counted) plus Detune control...in a Max For Live plug-in.

My excuse is that I was distracted. On Twitter I under-stated the number of oscillators in my INSTframeOSCmr Max For Live plug-in for Ableton Live 10. There are actually 256: 64 per frame, but there are two parallel pairs of frames, and if you select the 'Stereo' button, then there are two separate oscillator banks per channel, so what you hear is 256 oscillators in total.

But whilst I was looking at the design, I saw a better way of doing the stereo routing, and so I added that. I also figured out a way to solve one of the biggest problems that I had with the user interface - drawing lines in the Frequency grid. The result is INSTframeOSCmr02, as usual a free upgrade from maxforlive.com.

I also realised that the frequency grids aren't easy to understand, so here's a guide to using them, plus details of the new 'Detune' control.

First we need to see how the frequency grid and the spectrum plots align...

### Spectrum plots and frequency grids

1. Single low frequency

Here's a spectrum of the basic frequency grid setting - a horizontal line. This gives a single frequency at the output. (Note that the 'Detune' rotary control is set to zero.)

One way to think of how this is working is to just take the frequency grid and rotate it clock-wise - that horizontal row of orange blocks turns into a vertical line, which is the single frequency shown in the spectrum (Okay, so spectrum analysis always turns frequencies into these weird spikes that are narrow at the top and wider at the bottom, but that is just the way that the maths works). Now that the frequency grid is rotated, low frequencies are on the left, and high frequencies are on the right - just as in the spectrum:

2. Single high frequency

If we re-draw the orange blocks at the top of the frequency grid, then we get a single frequency 'spike' at a high frequency in the spectrum:

And if we rotate the frequency grid, then you can probably see how the two line up...:

3. Two frequencies: Low and High

If we draw low and high frequency horizontal lines in the frequency grid, then we get two lines in the spectrum. (Notice that the oscillator index doesn't matter to the spectrum - you can try it yourself by drawing the two horizontal lines with different positions, and the spectrum will stay the same):

And the rotated frequency grid now looks like this (the blue cursor just happens to be where the two orange lines change frequency - this isn't significant!):

4. Three frequencies

So what about three frequencies? Well, we just draw three horizontal lines in the frequency grid:

And the rotated version looks like:

At which point you may notice that the spacing of the three frequencies in the frequency grid and the spectrum are different! This is because the frequency grid horizontal axis is 'linear', where the frequency goes up in equal steps, whilst the spectrum's horizontal axis is 'logarithmic' where the frequency goes up in steps that keep doubling. This is exactly the same way that notes double in frequency when you transpose them by an octave. So a C2 at 110 Hz, becomes C3 at 220 Hz, and a C4 is 440 Hz, whilst a C5 is 880 Hz. So the spectrum's 'logarithmic' horizontal axis is a good way of showing musical intervals: a C2, C3, C4 and C5 would all have the same horizontal spacing. Unfortunately, the Max 'multi slider' object that I'm using for the frequency grid does not have a logarithmic axis option.

5. Detune

You can see how the logarithmic horizontal axis works by adding 'Detune' to the 'Two frequency' example. Notice how the low frequency (the right-hand orange horizontal set of blocks in the frequency grid) gives a wide band of frequencies in the spectrum, but the high frequency (the left-hand orange horizontal set of blocks in the frequency grid) gives a much narrower band of frequencies. The detune values that are applied are the same in both cases - the frequencies that are added or subtracted are the same, but the way that the spectrum shows the resulting band of frequencies is different. Actually, to sound correct musically, then the detune values should be larger for higher frequencies, but that's not how I programmed it...

Okay, that completes the tutorial on the alignment between the frequency grids and the spectrum plots.

### How to use the frequency grid...

1. Single frequency

Now that you have a better idea of what is happening on the frequency grid and the spectrum, let's look at that single frequency example again. When you look at the frequency grid and spectrum now, then you should see that the horizontal orange set of blocks in the frequency grid corresponds to the single 'spike' in the spectrum plot:

2. Rising ramp

And next, the plot that seems to confuse people. A rising ramp on the frequency grid... Remember that the horizontal axis is the oscillator index, so what the rising orange line means is that the frequency goes up as the oscillator index goes up - each oscillator will produce a different frequency. So this will produce a block of frequencies:

3. Chords

Next, some horizontal lines drawn by dragging the mouse horizontal across the grid. This gives four different frequencies (a chord!), because all of the oscillators along the horizontal axis are set to the same vertical frequency:

4. Wobbly lines give bands of frequencies

And now to that problem I mentioned. If you aren't good at drawing horizontal lines with the mouse, then you actually don't get single frequencies, but you get broader 'bands' of frequencies. if you look, you can see that the lines are not horizontal, they are 'wobbly' in the vertical direction, and this produces the bands of frequencies in the output:

5. Detune...

Now for Detune. Here's that first 'single frequency' setup, but with the 'Detune' rotary control turned up past half-way, it is as if that horizontal line was very wobbly up and down vertically. So now you don't need to try to wobble the lines, you just turn up the 'Detune' rotary control. What you get is bands of frequencies instead of single ones:

6. Detuned chords

Finally, a nice neat horizontal 'chord' grid, but with quite a lot of 'Detune' - so you get several bands of frequencies all mushed together (The screenshot doesn't capture the dynamism of the spectrum that you get here - it is going up and down all over the place!):

The Detune rotary control saves you the hassle of trying to draw wobbly horizontal lines - and most importantly: you can quickly adjust the control, instead of having to redraw wobbly horizontal lines with more or less wobble.

### Detune?

The 'Detune' rotary control applies little frequency offsets to the oscillators. It does this with different values for each grid - each grid has a captured list of random values that it uses to apply the detuning to the oscillators. Which brings me to this post's 'Max' content, and it concerns the 'vexpr' object.

Vexpr works on lists. Give it a list like (1,2,3,4) and it will process the 1, then the 2, then the 3, and finally the 4. So one object in Max allows you to change four values at once. So in INSTframeOSCmr I use it to process the frequency grid, which is a list. I'm going to use a single diagram with numbered 'points of interest':

1. This is a 'bang' event that indicates that a frame has been activated, and that the oscillators should load new values for their frequency and amplitude.

2. The frequency grid outputs a list of 64 frequency values.

3. This message box contains a list of 64 different randomly-generated 'Detune' values.

4. The 'Detune' rotary control controls how much detune is going to be applied to the frequency grid output values (which is a list of 64 frequency values).

5. This is the first of two 'Vexpr' objects. This one has 'Scalar Mode 1' set, and so it multiplies every value in the list of detune values by the single value from the Detune control. In this case, the Detune is set to zero, so the output of this Vexer object will be a list of 64 zeroes.

6. This is the other 'Vexpr' object. This one does not have Scalar Mode 1 set, and so it works on two lists. It adds the list of frequency values from the frequency grid (2) with the list of Detune values, so if you imagine that the 'Detune' rotary control was set to something other than zero, then the list of detune values would be 64 different randomly-generated values, and they would be added, one by one, to the 64 frequency values from the frequency grid output. If lists were not used here, then there would need to be a lot of * and + objects in this Max For Live Patch! (As a quick aside, what would happen if this '+' object was a '*' (multiply) object instead? Would this affect how the detune is applied to the frequency values?)

7. I have cheated here by pasting in a message box containing the 64 frequency values that would have been output if the Detune control was higher than zero!

8. The 'detuned' list of frequency values eventually gets to the 'ioscbank~' object, which contains the 64 oscillators for this frame.

Note that the two different versions of Vexpr do very different things.

• The Scale Mode 1 version takes a list and processes every item in the list with a single value (from the Detune rotary control in this example).
• The other version (without the Scale Mode 1) takes two lists, and processes every item in one list with the same item in the other list.

### Getting INSTframeOSCmr

You can get the updated version of  INSTframeOSCmr here:

https://maxforlive.com/library/device/6012/instframeoscmr

Here are the instructions for what to do with the .amxd file that you download from MaxforLive.com:

(In Live 10, you can also just double-click on the .amxd file, but this puts the device in the same folder as all of the factory devices...)

Oh, yes, and sometimes last-minute fixes do get added, which is why sometimes a blog post is behind the version number of MaxForLive.com...

### Modular Equivalents

In terms of basic modular equivalents, then INSTframeOSCmr would require two LFOs, and 256 VCOs, a lot of stored parameters (blocks of 16?) to do the frame loads, a mixer and a Ring Modulator, giving a total of well over 260 ME, which is the biggest count so far, I think. You might want to use some specialist additive oscillators instead of brute-force VCOs!