Sunday, 20 August 2017

Using Chromatic Remapping To Generate Musical Inspiration

Previously, I looked in some depth at the Ableton 'Scale' effect, one of the quieter backwaters of the 'built-in' MIDI effects. That blog started out concentrating on how to invert a keyboard, but ended up producing lots of chromatic maps that take incoming notes and map them to different outgoing note pitches. Which led to another investigation, the results of which you are now reading...

While I was producing the variations on chromatic inverted scales for the previous blog, I realised that these were all specific cases of a much more general set: the set of remapping of incoming notes to single outgoing notes on a one-to-one basis. In other words, each and every incoming note is converted to one, and only one, outgoing note. There are a lot of these maps: there are 12 input notes and 12 output notes, so I think that means that there are 12! combinations, which is just under 480 million. So me making 30-odd of them available is a tiny fraction of the whole set! And that's where I realised that I could make them all available in a MaxForLive plug-in utility, and MIDI_ChromatixT_mr was born.

In the screenshot, MIDI_Chromatix_mr is shown in its normal location in the MIDI processing chain - just in front of the Scale effect (Alternatively, you could use any of the many available MIDI Scale-type effects available in MaxForLive). The diagram below shows how everything fits together:

Incoming notes are mapped to different pitches by MIDI_ChromatixT_mr, and then restricted to the chosen notes in the scale set by the Scale effect. In the example screenshot above, the C minor preset scale has been altered so that only 5 output pitches can occur. This constrains the output notes to just the pitches C, D#, F, G# and A#. Incoming notes can be at any pitch, and they will be mapped to new pitches by the map. So an incoming A might be mapped to C, whilst an F could be mapped to a D#, etc. 

The grid in MIDI_ChromatixT_mr sets the mapping of incoming notes. In the screenshot above, the vertical cursor line is showing an incoming D (moving across from left to right), whilst the orange marker is in the A# row (counting up from bottom to top). Now, whilst it is possible to edit the mappings (Click on the 'Auto/Fix' button so it shows 'Fix', and the mapping will be fixed and editable), the 'Generate' button creates new random mappings with a single click. So it is easy to just keep clicking on the 'Generate' button until it has created a random mapping that you like - the usual M4L store/recall buttons on the left can be used to save it if you wish. 

But the really interesting part of MIDI_ChromatixT_mr is the 'Auto' button, when it is set to 'Auto' then the 'Generat' button will be pressed every time the bar count to the left of the 'Auto' button matches the number set in the pop-up selector on the far left. So if the selector is set to 4, then every 4 bars, a new chromatic mapping will be produced, and incoming notes will be mapped using that new mapping instead of the one used in the previous 4 bars. This then repeats every 4 bars.

What this means is that every time the bar count reaches the number of bars shown by the selector, then incoming notes will be mapped differently, using a new one of the millions of possible chromatic mappings. So whatever notes are in the (monophonic is recommended) track sequence that is driving MIDI_ChromatixT_mr, the output will be a scale-constrained version of the remapped versions of them. The D to A# mapping in one set of bars could be replaced with a D to G# in the next set of bars, then a D to F mapping in the next set of bars. 

It's a bit like shuffling cards and then dealing them out for a card game. The shuffling means that you get a different hand of cards each time, but the number of cards you get (and the game you are playing) are fixed. So whilst the notes get remapped to new pitched notes, they are still constrained to just the notes in the scale you have set. 

What this does musically is take a monophonic sequence in a track, and play those notes, remapped to new pitches whilst still being constrained by the scale, and yet the timing and velocity of those new notes remains exactly as it was in the original sequence. So it's a bit like an randomiser and a bit like an arpeggiator, but until that 'Generate' button is activated, the mapping is fixed, so if you find a mapping that you like, click on the 'Auto' button so that it says 'Fix', and then session record the output with the 'doughnut' session record button in Live. Of course, an easy alternative is just to let it free run, generating new mappings every 4 or 8 bars, and to record everything, and then just extract the bits you like. 

In a few minutes, MIDI_ChromatixT_mr will run through lots of variations of your monophonic track sequence, all following the timing and the velocity exactly, but with different pitches every time the 'Generate' happens. It's a bit like having an assistant who can keep running through variations, one after the other, and who never gets tired or bored, and never loses patience. MIDI_ChromatixT_mr is an automatic 'Can you just do that twisted around a bit?' generator.

Demonstration 1

The problem with random music generators is the they are often too random, and when they do come up with something interesting, then it has happened and gone almost before you realise. MIDI_ChromatixT_mr repeats each random variation for the number of times that you set the bar selector, and so if it is set to 4 bars, then you will hear the same variation 4 times, before it moves on to the next one. This is probably best heard rather than described in words, so here's a demonstration of a simplee piano and bass duet produced entirely from an 8-note track sequence and a 4 note bass track sequence, with MIDI_ChromtixT_mr producing all the variations every 4 bars. Once the 12 notes have been set in the track sequences, everything else is just a straight recording. 

Demonstration 2

This second demonstration has the same bass, and has two independently variations piano lines using the same technique, spaced an octave apart. 

The top line adds a 16 note sequence, but with a random velocity added to provide additional variety. Again, once set running, the recording has had no user manipulation. 


As usual, MIDI_ChromatixT_mr can be downloaded from Enjoy!

The Name?

Why such a weird name? Well, I thought about all sorts of variations (!) on chromatic remapped, or even diffuser (cryptographers call this type of device a 'diffuser') and the first version was completely manual and was 'Chromatix. When I then added the automatic 'every n-bars' generation feature, then it needed something to indicate time, so I added a 'T' at the end. As a result, you aren't likely to forget this M4L device.


Yep. Try poly tracks and see what happens...

Sunday, 6 August 2017

Scale Inversion of MIDI Notes...

Hidden away inside Ableton Live are some interesting comments. One that is in plain sight is in the presets for the 'Scale' MIDI Effect. If you look carefully at all of the sometimes exotically named scales, you will see one that is named 'Inverted and Useless'.

Now that got my interest immediately. Inverted keyboards have always fascinated me, and I had already done a MIDI Effect that could invert a keyboard, and lots more besides: MIDI f(x)_mr. But why would Ableton describe one of their own presets as 'Useless'? Here are the default 'Scale' settings, which pass notes through unchanged:

The mapping of input to output is very straight-forward:

Here is the 'Inverted' version, which takes the diagonal mapping and just reverses it, which intuitively ought to be fine - after all, all that has happened is that the diagonal now goes the other way, so the notes should too...

Unfortunately, when I tired playing the MIDI output of a keyboard through the Scale MIDI Effect using the 'Inverted and Useless' preset and driving a piano instrument, then I quickly learned why it was described as useless. Some arpeggios work ok, but others have sudden jumps of just under an octave, and some chords sounded very weird indeed, even when I deliberately adjusted them for the inversion. Something was definitely wrong... This needed deeper investigation with a specialist setup.

Investigation Setup

First, I created an arpeggio clip stretching over about three octaves, and then I surrounded the 'Scale' MIDI Effect with some display tools: two MIDI HugeNoter_mr 'big' note displays, and a variation of one of my favourite tools, the MIDIKeyMon_mr, which I described in a previous blog entry. (MIDIKeyMonFull_mr shows the whole MIDI keyboard range and has a summary scrolling window showing the notes played.) HugeNoter is great when you need to display notes in a way that is difficult to miss, and is available from

But the important part of this setup is the Ableton 'Scale' MIDI Effect in the middle. As you can see, in the case shown in that screenshot a C3 note input has become a B3 output. So there's obviously some pitch changing going on, but C3 inverting to a B3 seems strange. So I wrote down the input and output of the Ableton 'Scale' MIDI Effect with the 'Inverted and Useless' preset:

After noting down all those inputs and outputs, here's part of what I got:

It isn't easy to see what's actually happening here, so here are plots of the input and output:

So the purple input is a rising series of notes, and appears as a sloping line going up from left to right. The blue-green output does have a series of descending notes, from 71 (B3) to 60 (C3), but either side of that descending series is a sudden jump - the output jumps from 48 (C2) to 71 (B3) when the input changes from 59 (B2) to 60 (C3), and the output changes from 60 (C3) to 83 (B4) when the input changes from 71 (B1) to 72 (C4). Both of these intervals are 13ths, which my head (and ears) don't really think of as an octave plus a semitone - they just sound wrong.

The results show why the 'Scale' effect only shows an octave grid - it is just working on an octave at a time, and mapping the notes in that octave to new values. For any rising scale then this is fine, but when you have an 'Inverted' scale, then you get jumps because each octave map is being transposed to try and do an inversion across the whole range. 

If we look at the whole range, then it looks like this:

And what the 'Inverted and Useless' scale effect preset is trying to do is turn those descending blue-green segments into an inversion of the rising purple line, and the effect is a broken series of invited scales with discontinuities at the ends of each octave:

What is really needed is an inverter that inverts properly over the whole range, of course! The 'Scale' effect is designed to provide a way of mapping rising scales to other rising scales, and it was never designed to invert the complete MIDI keyboard range.

But since I had started investigating, I wondered if there was any way to improve on the existing 'Inverted and Useless' preset. C3 mapping to B3 seemed wrong to me, so I looked at the theory behind inverting MIDI keyboards...

Theory: Inverting MIDI Keyboards

The limits of the MIDI keyboard range are:

Lowest Note. 

The lowest note on a MIDI keyboard is number 0, and this is normally referred to as C-2. (But it can be C-1 or C0 - see the next entry)

Middle Note.

There is some variation on MIDI note octaves (the '-2' in the example above) and the middle of the keyboard, because the original MIDI specification isn't very precise about which pitch is MIDI note 60, and so as a result Middle C can be C3 or C4 or even C5, and may be assigned MIDI Note Number 60, 72 or 84. MIDI equipment tends to use C3 = 60 and so that's what I will use here. (Look up 'Is Middle C C3, C4 or C5' or 'Is MIDI note number 60 = C3?' on your favourite Interweb search engine to see lots of people politely failing to agree...)

Highest Note.

The highest note on a MIDI keyboard is number 127, and this is normally referred to as G8 (or G9 or G10 - see the previous entry)

Keyboard ranges.

Most musical keyboards do not have 128 notes, and so they only provide a sub-set of the available notes. 5 octave, 61 note, C-C keyboards are common for professional synthesisers, but monosynths tend to have less notes (44 F-C on a Minimoog), and top-of-the-range workstations tend to have more (88 or more, and often not C-C). 

Octave numbering.

If you go up from A2, you get A#2, B2, C3, C#3... Octaves change when a new C starts (not when you go from G to A as you might expect!). Because the lowest MIDI note is a C (number 0), and the top note is a G (number 127), then the half way point happens in the 3rd Octave, and is between D#3 and E3. 

if we ignore the notes above 120, and consider MIDI as having a range from 0 to 120 (C-2 to C8), then the middle of these 121 notes is number 60, C3. By using sub-sets of the full 128 notes, then any note can be used for inversion, although maximising the usable keyboard range seems to be a good goal, and inverting around D#3 and E3 gives 127 usable notes, whilst inverting around the D#3/E3 (63/64) boundary gives 128 notes. 

Exploring inverted scales

The 'Inverted and Useless' preset is just the opposite diagonal to the default chromatic diagonal scale grid.

Because the grid used by the Scale effect is just one octave, then the lowest note when the Base is set to C is a C, and the highest note is a B - this can be seen by looking at the second row up on the grid - the pattern of darker notes reflects the 2 and 3 groupings of 'black/enharmonic' keys on a piano keyboard. If you plot one keyboard against another, then you get a useful diagram of the corresponding keys:

Which explains why the C3 gives a B3 output. Note that this has all white keys mapped to white keys, and all the black keys mapped to black keys, except for the F to G# mappings.

However, there is an extra row in the grid, and if you use this, then you can do a different diagonal: shifted one cell upwards. This gives a different output for a C, and a different diagram.

This time, the mapping is almost all opposites (back mapped to white), except for the G, G# and F keys. Here are the two grids, side by side:

                                         Inverted and Useless                                          Scale Invert mr1

When you play these, then the 'Inverted and Useless' is obvious because it shifts the C downwards to a B. Otherwise they are both chromatic inversions over an octave, and both have a jump at each end of the octave. For someone like me, who likes a C to play as a C, then I prefer 'mr1'.

Alternative inversions

Here are some alternative inversions that I experimented with, trying to minimise the discontinuities, or perhaps, trying to spread them out across the octave.

                                                                                Scale Invert mr2

This scale moves the C from the top row to the bottom row, and so the octave jump is between the C and the C#, instead f the B and the C. It's a different feel, but still an inversion.

The interesting results so far then inspired the following explorations.

                                             Scale Invert mr7                                        Scale Invert mr 8n

The above scales put the jump in a different place on the keyboard, but there are now two discontinuities per octave...

                                          Scale Invert mr1m                                         Scale Invert mr1s

The above scales spread the discontinuities wider... Scale Invert 1s puts the  main discontinuity between E and F, whilst Scale Invert 1m  puts it between F and F#. It really depends on what key you are playing in, really. Having a set of different inverts is actually a great way of creating new melodies, chords or chord progressions, because it removes any bias or preference your fingers have for well-worn scales or fingerings. 

                                                 Scale Invert mr1w                                   Scale Invert mr1q 

The above scales spread the discontinuities wider and in different ways.

                                                                                Scale Invert mr1x

And finally, almost not an inverting scale at all!

Now it is possible to input these scale grids into the Scale effect, but that is a lot of work, and so here's a shared 'Scale Invert' folder containing all of the chromatic scales above, plus several extras, and they are all free for you to download: Scale Invert

MIDI HugeNoter_mr 

HugeNoter_mr is just a way to show MIDI notes and note numbers in a big way. I use it when developing utilities or doing investigations, as in this blog. It shows, from top to bottom, the MIDI note number (in dark blue), the note and octave (in white), and the note and octave split, as described in this blog. The three small grey buttons at the top let you set the justification of the displayed note and octave. MIDI_HugeNoter_mr is available from


MIDIKeyMonFull_mr is a variant of the MIDIKeyMon, but adjusted so that you can see the whole of the MIDI note range without needing to select a range. It also has a scrolling display of previous notes played. A useful utility when working on scale effects... MIDIKeyMonFull_mr is available from

Where's the dark version?

Available at

Sunday, 30 July 2017

Probably - an antidote to step sequencers...

I've always loved step sequencers. From the ARP Little Brother, to my own modular synths, 8 or 16 step notes metronomically repeated ad infinitum has always been part of my synthesis toolkit. But there's always been a tiny nagging voice whispering in my ear, and recently, I decided to listen to it and see where it took me. The voice told me to break the four rules:

The Rules of Step Sequencers

- Each step is one note.
- Each step has the same length note
- Each step has a find common velocity
- Each note always plays

So MIDI Probably gleefully breaks them! Each step in this M4L add-on can have from one to 13 pitches, spread over an octave. If you have one pitch, then the note played is that pitch. If you have two pitches, then each one will play, on average, for half the number of times that the sequencer loops round. Three notes get a third each. Four notes get a quarter, etc. Just probability really. There's a random number generator inside, and it decides which of the choices that are specified gets to control that note event.

There are four grids that are used to control Probably. From left to right they are:

Pitch, which is arranged paint roll style just like Live. Higher pitches are higher up the screen, lower pitches are lower down the screen. You get a black and white guide to show where the notes are. One octave may seem a bit limiting, but Probably accepts incoming MIDI notes as transpose settings, so you can transpose the playing sequence live with th computer keyboard, an external MIDI keyboard, or a session clip (if you make the session clip several bars long, then you get a transpose sequence that drives Probably...).

Probability, which sets the likelihood of a given step actually playing. The top row is 100%, where the note event always plays, whilst the lowest row is 0%, where the note event never happens. If you put a white square in the top row and the lowest row by clicking on the same step, then you get a 50% probability of that note event happening. If you replace those two square with one in the middle, then you get 50% as well. But if you add a lower square at 25%, then you get half of the notes playing for half of the time, plus a quarter of the notes playing for half of the time. If you have a square in the top, lower and 25%, then each gets a third of the time, which is 100% (33%), 0% (0%) and 25% (8.1%). Don't bother too much with trying to understand the maths: the more and higher the squares you fill in, the more likely it is that a note event will play.

Velocity, which sets the velocity for each note event. Again the top row is maximum velocity (127), and the lowest row is minimum velocity (1). Selecting specific squares gives fixed instances of velocity, whilst selecting a range of squares will give a range of velocities - each chosen at random. Single squares give fixed velocity. So you can have notes on the beat have fixed high velocity, whilst notes off the beat can have lower random velocities to add interest, or the opposite, or any other scheme you can think of.

Length, which sets he length of the note events. Each note event is independent, so if you want to have steps where the notes are longer than the step interval, then you can have them, and so you get chords instead of single notes. Each note can have its own length, and act length can be randomly chosen from a range or set of values. You control the values, and the randomness just make the choices.

If you've never played with a step sequencer that allows control over the length of notes (from staccato, to legato, to overlapping chords), or one where velocity is controlled random choices, the you are in for a treat!


When you add MIDI Probably to a track, then it starts up in a weird default:

This isn't very useful, and the first thing you need to do is compensate for my laziness in not writing the code to create a sensible default. Here's my suggested starting point:

This has a rising arpeggio for the Pitch grid, a top row full of 100% for the Probability grid, Maximum Velocity, and 16th demis for the Lengths. You need to provide a Pitch reference for the transpose, so arm the track, and play a note on the computer keyboard, on your external keyboard, or in a clip (which could be a slow, multi-bar transpose map for people who love circle of fifths etc.) Playing this gives a simple 8 step sequence:  

Well, nothing spectacular so far!

So let's draw in the opposite arpeggio:

Running this gives a rather more interesting result. You get each of the pairs of notes in each of the columns, selected at random. Every 16 bars or so, you stand a reasonable chance of getting all f the possible variations of each of the two arpeggios. Here's some of the output:

That word 'variations' is very significant here. Two notes have been specified for each of the 8 steps, and Probably dutifully selects at random from each of those pairs, and eventually will play every combination of the notes. The result sounds like someone learning jazz improvisation based on a scale, and most people assume that there's huge amounts of processing behind it... You might want to keep quiet that there's actually just a very simple grid, and probability does all the rest.

The red lower portion of those piano rolls shows the usual boring velocity values of 127, so lets put some ranges into the Velocity grid:

The first note in the arpeggio, plus the middle one, have single velocity values, so they will always play at maximum velocity. The remainder in the first half get quieter on average, and the second half hey get quieter still. There's still a chance that you will get all of the notes at the maximum velocity, but it might take a long time to get to it. Here's a capture:

Notice that the notes are different from the previous example. Not only re the velocity values being chosen according o the white squares for each note, but each note is independent, and so the sequence of jumping between two arpeggios that we got the first time, is different this time. This is randomness, not repetition.

Let's add a bit of control over the Probability, by making the off-beat notes less probable. (This is kind of emulating what real human players tend to do in some circumstances...) And the Length is now set to choose from a range of possibilities, but set exactly the same for each note event (painting across all of the columns is easy, but boring - I prefer the individual control against time that is shown in the probability and velocity grids). This gives us a sequence which has lots of variation across multiple parameters:

...and the result starts to look and sound quite interesting:

There's not very much range to the velocity or the length, so let's increase the amount of white squares and give it a few more pitches to play with:

Which gives us this output:

Now, does this look like a piano roll generated from a few simple choices on a few grids to you?

Lets try a different pair of arpeggios, and make those Lengths a little longer:

Resulting in:

Remember that this is produced by a step sequencer...

Instead of arpeggios, lets's constrain the choices to just a few notes from a scale, and see what happens:

 And let's try making the available note choices much sparser, and make the length of the notes (and the probability) dependent on where we are in the bar:

I'm afraid to say that when you add a piano instrument to the track, this gives results which sound pretty much like a reasonably competent player randomly noodling on the piano. All you need to do it capture it to a MIDI track, and then select the bits you like: either for inspiration, or just 'as is'.

To capture the output of Probably, you just create a new MIDI track, setts input to the output of the track with Probably on, and then use the Session Record button to create a new clip with the output of Probably. (I call the Session Record button the 'new doughnut', because it is a circle next to the 'NEW' button, and it goes red (I think of it as brown) when it is recording).


When you first insert Probably into a track, you need to provide a note. If you don't, then the transpose function will think you want to transpose way down at the bottom of the MIDI range. Because of the way that Probably works, you also lose the lowest C (C-2) from the output. Sorry. 

And that's MIDI Probably, a kind of 'antidote' to the usual M4L step sequencer. Enjoy playing with randomness!

As always, you can get MIDI Probably from