Monday 11 May 2020

Full-range Chromatic Note Remapper in Max For Live for Ableton Live

I have experimented with remapping previously with my MIDI ChromatixT, which takes incoming MIDI notes and changes their numbers to new ones, but each octave is treated the same, and when you generate a new mapping grid, then it is often a huge change and not the slight variation that I really wanted. So I've been playing around wth a few ideas...

MIDIchromatixN


MIDIchromatixN is the result. It combines two of the methods that I explored into one device: a random remapper and a modulo-arithmetic remapper. Both use almost exactly the same controls, and the outputs are very different - the random remapper is, well, random and wild, and the modulo remapper is more mathematical and constrained. In both cases, you need to follow them by a scale-setting device: the stock/factory Ableton Live Scale device is fine, or you could use my MIDINoteScalery device for extra control, proper invert and 'n'-octave folds as well.


MIDIchromatixN is basically just a look-up table. If you want to, you can set it so that the notes coming out have exactly the same note numbers as the ones going in (velocity is unchanged in this note remapper), but that isn't very useful. You can set it so that it inverts the whole MIDI note range as well, so that low MIDI notes become high ones, and vice-versa, but MIDINoteScalery makes that easy with a single button instead of setting about 8 rotary controls... However, if you want to gradually make changes to a constrained random (or mathematical pattern) mapping every so many bars, and have detailed control over the mapping, then you need MIDIchromatixN. In many ways, it is conceptually a bit like the stock/factory Saturator plug-in, but for note numbers rather than audio - and the mathematical functions it uses are different...

The flow diagram above also shows what you need to do to allow MIDIchromatixN to work. You need to have put some notes into a clip on the same track, and you need to add Scale or MIDI Note Scalery after MIDIchromatrixN. Finally, you need something to make a sound - any of the stock/factory Ableton Live Instruments is fine, or you could use a VST plug-in instrument.

So what does a remapper do?


A note remapper goes between the notes produced by a Clip and the sounds produced by an Instrument. MIDIchromatixN isn't sophisticated enough to do things 'in key', and so you need to add a scale controlling device after it. A remapper uses mathematical formulas to change the note numbers as they pass through. So As an example, with the Modulo mode selected, I tried 10 different variations when I input a C Major chord (C E G) and set the scale device to only let C Major notes through. The outputs were: C D A, C D A, F G D. A C G, D D F, A C G, D F C, G A F, C C D, and A F F, where a repeated letter indicates a note one octave higher. These output notes are consistent in Modulo mode - if you select a Variation number and input C E G then you will get exactly the same notes out again. Change the settings, and the output notes would be different, of course. In Random mode, things are slightly different, because the randomness gets shuffled each time you move some controls, and so, as the name suggests, you get more unpredictable 'random' notes out - and they won't be the same if you set the controls to the same settings. 

So what do you use it for?

A remapper can be used to change a melody (or chords). Whatever you put into the Clip, the output from the remapper is probably going to be different - unless you find one of the 'input=output' settings - and you would be able to see that on the display. So you can use it to create new melody ideas, or for generative music, or just for fun!

User Interface


As normal, I will go across the user interface from left to right...

There are two indicator lights with 'Yes/no' buttons underneath them, with rotary controls called 'AutoVar' or 'AutoRand'. These enable changes in the remapping to happen every 'n' bars. The 'Var' section controls the Variation rotary control, which makes small changes to the mapping. You can move the Variation rotary control manually to audition the effect that it has on the remapping of notes. The 'Var' section works in either of the two modes of operation (more about them in a moment). To enable the automatic variation, you just select the repetition rate (every 'n' bars) and click on the 'Yes/No' button so that it says 'Yes'. When Ableton Live's transport is running, then the indicator light will flash after that number of bars have happened, and the Variation rotary control will increase by one. After 127, it resets to 1 again.


Well, that WAS how it worked, right up until when I was writing this, where I realised that having the Variations button always cycle through all 128 possible values was a bit boring... As a result, I added 'Start' and 'Range' numbers, plus 'nudge' controls to adjust them, and now you can set the start Variation number, plus how many increments it will make before it returns to the start value. You can see the new controls on the far left hand side in the diagram above.

So if you set the Start to 1, and the Range to 4, then it will increment through Variations 1, 2, 3, and 4 (and then back to 1) every 'n' bars - where 'n' is set by the 'AutoVar' rotary control. If you set the Start to 8 and the Range to 16, then it will increment through Variations 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, and 23 (and then back to 1).

The 'AutoRand' section only works in the 'Random' mode, and causes a new random remapping to be generated every 'n' bars - if the 'Yes/No' button is set to 'Yes'. Note that the two auto bar settings can be different values. To the right of the AutoRand section is the 'Transport' section: the red/green indicator light shows when Live is stopped (red) or running (green).  The small indicator light will flash once every beat, and the bar count on the right will increment every bar. You need to make sure that you stop Live in order for the bar counting to work properly - just pressing the spacebar for pause doesn't work properly, but I'm working on it...

The main control just above the transport indicators is the 'Random/Modulo' button. In 'Random' mode the remappings are rough and 'random', plus the background colours are slightly more purple, whilst in 'Modulo' mode the remappings are more repetitive and mathematical in appearance. Apart from the AutoRand only happening in 'Random' mode, all of the other controls work in both modes.

Above the mode button are the main set of controls for the remapping. There are two identical mathematical generators inside, connected in series (the notes from the clip go through generator 1 first, then generator 2, then go to the Scale device) and each generator has a Range rotary control and a Step rotary control. Range sets the range of output notes, and Step sets the increment of the output notes within that range - which roughly equates to the slope of the diagonals (within limits, as we will see). If you set the controls like this:


...then you get what you might expect - the Ranges mean that the remapping uses the whole of the output range, whilst the step size of 1 means that every output note is used, and so you get a 1:1 mapping of input notes to output notes. So every incoming note will cause the exact same output note to be output, although the Scale device may then change that note, of course. You might wonder why you have a device that does nothing! But set the controls like this (turn Step2 to 64, and Pitch2 to 32):


...and things are now very different. The output range is only half what is was before, and there are now two different input notes that produce the same output note. Let's look at that 'sawtooth' shape in more detail...

The central user interface feature is what looks like a strange audio waveform on a dark background, or maybe a broken LFO waveshape. Above this are 128 numbers which define the mapping of input MIDI note numbers to output MIDI note numbers - and they are very small because for most purposes they are very boring and you may not need to use them very often! So when we had the first setting, then there was a straight line across the rectangle, from lower left to upper right. When we set the Range2 rotary control to 64, then there were two diagonal lines and we needed to alter the Pitch2 control to get the output notes playing the correct notes. So what would happen if we set the Step1 value to -1 instead of 1?


The screenshot above shows the effect of a Step1 of -1 - with Pitch2 increased to 95 to compensate for the pitch dropping. The diagonal lines are now sloping the opposite way. Let's reiterate how to think about the controls, and add a caveat: the Range controls set the output range of notes, but these may need adjusting with the Pitch controls so that they are not limited by the top and bottom (0 and 127) of the note numbers. 

Let's see what happens if we rewind a couple of steps and change Range1 down to 96:


This gives us one diagonal controlled by Range2, and another controlled by Range1. Okay, which means that the Range controls are separate. Got it.

Earlier I said that the Step controls changed the slope of the diagonals. If we change Step1 to -2, then this happens - but it shows that the Range 1 control might not have been doing what it seemed to be. Here's what it now looks like:


Yep, we have squashed two repeats into the space of one horizontally, and what looked like two little diagonals is now revealed to be just one. Unfortunately, just as you think you have got the hang of this, then there's a problem because when the diagonals get to a certain slope, then they 'alias', just like digital audio. Here's what this looks like:


There have been several changes to the Range and Step values, but what you see instead of the nice, neat diagonals, are more complex mappings between the input and the output. But the same principles apply: Range sets the output note range, Pitch puts the notes back into a usable range, and Step alters the diagonals - except that now we have individual aliased dots instead of diagonal lines. Here's another example of the sort of mapping that you can produce:


In the course of playing with the values, the two Pitch controls on the far right hand side have also been introduced, and they complete the user interface. Don't forget that the Scale device that follows allows you to constrain the output of the remapper so that it plays only the notes that you want, and remember that you could use the MIDI NoteScalery device instead of scale, so that you can have more scales, better folding, correct inverting, etc.:


One final thing to note: if you try to set the Step value to zero, then the rotary control background will turn red to remind you that you shouldn't use this value.

Theory 

The rectangle with all the sawtooth and dots in it is really just a squashed lookup table:


The diagonal line that we started with should really be like this: 128 values on the lower edge for the input note numbers from 0 to 127, and 128 values on the right hand edge for the output note numbers from 0 to 127. Because the diagonal sets how an input maps to an output, then in this case, any input number maps to the same output number. 42 in maps to 42 out, as shown on the diagram above.

Do you remember when Step2 was set to 64, and the Pitch2 was adjusted so that the two sawtooth shapes were in the middle of the display? Let's look at what this does to the mapping:


The two sawtooths set the mapping of input note numbers to output note numebrs, so when there are two shapes like this, there are two inputs for every output. So an input of 43 produces an output of 78, but so does an input of 98. The smaller the output range, the more there will be several notes on the input that produce the same output note number. If you tweak the settings, then you will probably find some that produce a horizontal line, and this is a special case: there is only one output note number, and every input note number maps to that number. This isn't very useful...

If you look up MIDIchromatixT, then you will see that it only has 12 inputs and outputs, and that it repeats that octave for the full 0-127 range. MIDIchromatixN has no repeats! All 128 note input numbers are mapped individually to the 128 output note numbers.

When the Range and Step values give us mappings that aren't anything like a nice simple diagonal line, then the mapping can be lots more complex. Here's a Random mode mapping:


This mapping has none of the obvious repeated patterns of previous examples, but you should now be able to confidently adjust the output range of notes by changing the Range values, and then using the Pitch values to get the pitches at the right place, and know that changing the Step values will alter where the dots are horizontally.

Inside

This time I'm not going to go very deep into how MIDIchromatixN works in Max For Live, and instead I'm going to show how one very useful bit of the UI is done, and show you where to find more related stuff.

The little red/green indicator light that shows when Live is stopped or running is the target. The code looks like this:

For when Live's transport is not running/playing. However, if you try to open the Help page for this, then you get the help page for a patcher object, which isn't quite a useful. instead, what you need to do is go to the 'Extras' menu in Max:


...and there is the M4L.api.ListOfAbstractions, which opens a window full of interesting objects:


,,,including the one that I used to find out if Live was running or stopped - there in the lower right hand box. Clicking on the text for Global.ObserveTransport opens the tiny little box on the far right hand side, which shows how to use it. Here's that same code, but this time with Live's transport running:


Each of those six boxes covers a topic, and there are all sorts of other interesting objects in there, ready for you to use!

Getting MIDIchromatixN_mr

You can get MIDIchromatixN_mr here:

     https://maxforlive.com/library/device/6263/midichromatixn

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

     https://synthesizerwriter.blogspot.co.uk/2017/12/where-do-i-put-downloaded-amxd.html

(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...

Getting MIDI Note Scalery 

MIDI Note Scalery can be downloaded from here, with documentation here.

    https://maxforlive.com/library/device/5260/midinotescalery

Modular Equivalents

In terms of basic modular equivalents, then implementing MIDIchromatixN_mr is quite awkward. The Make Noise 'Maths' module starts to get somewhere close, but not entirely. The Expert Sleepers 'Disting mk4' also gets close, and maybe the Quantizer can be tweaked suitably, or possibly the Waveform Animator, maybe. But I couldn't find a direct equivalent. This means, of course, that I will get a comment pointing me to a classic module that I have overlooked, or never heard of, or forgotten, or didn't know about - there are lots of modules out there. Anyway, until then, I don't have an ME for this device... (This is a first, I think!)

---

If you find my writing helpful, informative or entertaining, then please consider visiting this link:







2 comments:

  1. Hey, I'm looking for a way to scroll through samples chromatically 0-127 no matter what midi note is input to a track. Will this device allow me to do that? Thanks!

    ReplyDelete
  2. Sorry, but it won't - the Remapper just affects the note that is played, not the sample. You should use the standard drum selection technique (map a Macro to the note number) to select the sample in Simpler or Sampler. You can use this technique to provide 'per note' sample change, rather like the Elektron 'parameter lock' (not my favourite phrase in terms of clarity...).

    ReplyDelete