Sunday, 27 November 2016

Tools to make tools...

One layer down...

Making audio effects in Max For Live (M4L) requires minimal setup in Ableton Live: put an instrument and the audio effect template into a track, and edit the template in Max, using the 'ASDF...' keys on the keyboard to hear what the result sounds like.

Developing a MIDI 'effect' utility like my recent MIDIf(x)_mr requires a bit more work, because the environment that Ableton Live provides lacks some features that ease and speed up working with the MIDI protocol and its fascinating quirks. Of course, M4L makes it easy to add things that compensate, but I realised recently that I have a personal toolbox of M4L 'tools' that I use a lot, but which I have never shared, because they have all been made just for the purpose of making something else - and at the time, that 'something else' was the focus of my attention and so was much more interesting.

A graphical representation of just one of the things that 'MIDIf(x)_mr' can do to MIDI Note numbers...

A long time ago, I learned that the word 'Never' is one of those key 'danger' words that will catch you unawares. As it happens, there are several new bits of M4L that I'm going to be releasing over the coming few months, and all of them depended on 'unshared' tools for their development. So, post-Loop, this looks like a good time to make those tools available to a wider audience, so that working with M4L is made easier for more people.

MIDI messages (from the MIDI In, the Virtual keyboard (the 'ASDF...' keys..., the piano roll... ) come from Live and passes through the MIDI Effect (shown here as 'MIDIf(x)_mr', and is then sent to the Instrument, where the MIDI messages are turned into sound.

Live allows MIDI Effects to be chained in just the same way as audio effects, and so there can be several effects in the processing chain.

Above we see one way that uses two of the built-in MIDI Effects inside Live: Pitch and Random. Pitch might be used to shift the incoming MIDI note numbers to check if the MIDIf(x)_mr 'Offset' rotary control is working properly, or maybe check if the 'Clip 0 127' Max command is working by setting very high values for note numbers. Putting 'Random' at the end of the processing chain turns the fixed, 'deterministic (predictable, the same every time)' output of MIDIf(x)_mr into just random notes. It is worth pointing out that this is the major difference between Random an MIDIf(x)_mr:

Random is not predictable - the output is different every time

MIDIf(x)_mr is just maths - the output is exactly the same every time

When you first start using MIDIf(x)_mr this difference may not be what you think is happening, of course! MIDIf(x)_mr does strange things to how you think a keyboard affects pitch...

To develop MIDIf(x)_mr, most of the time, I used this environment:

Here the two MIDI Effects are M4L tools that I have written, but they could be any M4L tools from the MaxForLive web-site (and there are lots of useful tools on there). So the actual screenshot looks like this:

Before the MIDIf(x)_mr processing tool, I have used my keyboard 'monitor' called 'KeyMon' to show what the notes that are played on the external MIDI keyboard are, or what the piano roll is producing. MIDIf(x)_mr is set to scale pitch by 2, so an octave is twice as wide at the output as it is at the input. You can see this in the second keyboard monitor: the minor chord has been stretched so that the D# has moved up to an F#, and the G has moved up to a D (overall, the C minor chord has been changed to something where the flattened third has become a flattened fifth, and the fifth has become a 9th). MIDIf(x)_mr understands mathematics but not music, and so the built-in 'Scale' effect is added at the end of the chain so that I can constrain things harmonically if I want to. (and 'choice' is a key part of creativity!)

The other thing that KeyMon helps with is when MIDIf(x)_mr outputs very high or low notes. The input KeyMon hows that the input note root is middle C, which is MIDI note number 60. Doubling this inside MIDF(x)_mr is going to mean that the output is going to start at MIDI note number 120, which is way to the right on a keyboard. One 'hidden' feature of MIDIf(x)_mr is that the note 'Offset' rotary control at the top also affects the input of the 'Warp' processor section, and so in the screenshot above this is set so that the input is transposed down by one octave, so the input to MIDIf(x)_mr is only note number 48, and the output 'Offset' rotary control in the 'Warp' section is set to -48 (down by 4 octaves) so that the output starts an octave below middle C. By using two KeyMon effects around the MIDIf(x)_mr processor, setting all of these offsets is much easier - you just set the offsets so that the output is on the keyboard display where you want it.

By using the 'Limit' rotary control, the stretching effect can be reversed, and once again the offset rotary control is used in combination with the KeyMon keyboard monitor effect. Notice that when the warping is limited to 17, then the output Offset has been changed to 48 so that the output is pitched in the same octave as before - and the notes have moved around again!

Choosing different values of limit will change the output notes again, of course. Here are two other outputs where the scale has been fixed to C major, and a third KeyMon shows the output visually:

A limit of 19...

(The extra C note was added on the piano roll, and gets limited into the 17 note range set by the limit control.)

A limit of 20...

The six buttons at the top of the KeyMon MIDI Effect set the lowest note displayed. In all of these diagrams it is set to '36', and so middle C is on the 'lower' keyboard. Note that the two keyboards flow from the lower one to the upper one, and so 6 octaves are shown in total. KeyMon is, as always, available from MaxForLive.com, and also comes in a dark version.