Showing posts with label MIDI Processor. Show all posts
Showing posts with label MIDI Processor. Show all posts

Monday, 23 March 2020

Swapping MIDI Note Number and Velocity Value in a Max For Live plug-in for Ableton Live

When I produced the MIDI Note Filter recently, I realised that the internal processing would allow some other interesting MIDI processing functions to be carried out. One thing that I have always wanted to experiment with spans across two different topic areas: music and steganography (hiding data in other data), and it builds on my recent explorations of Note On and Off messages, as well as a recent twitter message that talked about security.

(I have also been busy producing material for Christian Henson's 'Pianobook Pianoday 2020' collaborative 'systems music' project due to be released on the 28th March 2020 as 'Music by 300 Strangers'. Search for '#pianobookpianoday2020' on YouTube to see some of the contributions... This has put me in a more experimental and explorative mode than my usual analytical one, so what follows is not my usual type of Max For Live plug-in... but this is a good thing!)



MIDIswapNVmr01 is a Max For Live plug-in that swaps the note number and the velocity value in MIDI Note On messages that pass through it, and it works with the implied Note Off messages that occur when the velocity value is zero. A button is provided that toggles between 'Swap' mode and 'Thru' mode, and the usual '!' panic button is also there to stop hanging notes (I have called it 'ANO' here because it flushes out hanging notes, but note that it does not send a MIDI 'All Notes Off' message - Ableton Live does that when you press 'Stop', which is why the dark blue ANO is shown by the monitor...). Yep, a minimal user interface!

One thing which I hadn't thought about until I created the MIDIfilterNOTEmr plug-in was what happens when you turn off a Max For Live plug-in using the 'Power' button in the top left hand corner. It turns out that if you turn a M4L plug-in off, then it is bypassed, so you can use the power button as a kind of secondary 'Thru' button. So I have included this in the screenshots!

Screenshots


The screenshot above shows the plug-in swapping note numbers and velocities. I have put two MIDI Monitor utilites before (on the left side) and after (on the right side) so that you can see what is happening. Looking at the very last note (just before the dark blue 'All Notes Off' ANO MIDI message), then you can see a Note On (shown as 'NON' in the Monitor utility) for E3 with a velocity of 65 goes through the plug-in and comes out as a Note On for F3 with a velocity of 64. You won't be surprised if I reveal that F3 is the note that corresponds to note number 65, so the incoming velocity of 65 has been converted to a note number (F3) as intended. The E3 incoming note is note number 64, and so this turns into the velocity of the outgoing note as 64.

Let's pause for a moment here whilst you get your head around this. The incoming note is E3 (65) with a velocity of 65. The outgoing note from the plug-in is F3 (64) with a velocity of 64. So the note number and the velocity value have been swapped.

A quick note about note offs. As I've mentioned several times recently, a MIDI Note On message with zero velocity is treated as if it is a Note Off message. So in MIDIswapNVmr01, a Note Number of 0 (C-2) turns into a velocity of zero, which means that whatever the value of the velocity of an incoming note, if the note number is zero (C-2), then the output will appear to be a Note Off message. As it happens, the 'hanging note' suppression mechanism that I use ignores Note Off messages that haven't ever had a preceding Note On, and so nothing comes out of the plug-in!


I wasn't sure how to capture 'nothing' happening, so for the screenshot above I played several C-2s and then an A-2, and then C-2 again. As you can see, the only output from the plug-in is an E6 with a velocity of 9, which is because the incoming note's A-2 is note number 9, and the incoming note's velocity of 100 maps to  E6 when it gets turned into a note number. The C-2 notes thus turn into pairs of 'Note Ons messages with zero velocity acting as Note Off messages', which are then stripped away by the hanging note protection, and so never even make it out of the plug-in.

So there's a caveat / warning / note for this plug-in:

If you input a C-2 into this plug-in, it will never get out!


The screenshot above shows the inputs and outputs in the 'Thru' mode - so the MIDI messages pass through with no changes.


And the 'Power Off' mode, where the power button in the top left hand corner is clicked to turn off the plug-in. This gives the same result as the 'Thru': the MIDI messages are not affected.

As an interesting extra, here's what happened when I tried the MIDI Monitor from the Max for Cats 'Gratis Hits' bundle pack of free Max For Live devices:


As you can see, the MIDIswapNVmr01 plug-in is disabled (powered off) and so the MIDI messages are unchanged, but the Monitor utility on the right has added an octave to each note number: C3 becomes C4, C4 becomes C5, and C5 becomes C6. I'm very used to seeing different octave numbers in MIDI software because there are various interpretations of the standard, and I tend to use whatever the software uses, which in the case of Ableton Live and Max is C3=60, so this has probably been fixed in an update, and I just don't have that update! One area that I steer well away from are any discussions about Middle C and MIDI.

Because this post has talked a lot about MIDI Note Numbers, then this seems like a good place to share two charts that I use a lot when I'm playing/programming. The first is a classic that you have probably seen in various forms before:


So the table above has notes along the top, and caves up and down, and lets you find the note number of any of the 128 MIDI notes. You can also use it in reverse - look up a number in the grid, and then read the note and octave from the two axes.

The second is more unusual...


This is a kind of 'inverted' version of the first table. It has decades (10s (tens)) on the vertical axis, and units (1s (ones)) on the horizontal axis. So to look up 65 (note F3 from earlier) you go down to the row that starts with 60, and then go across that row until you are in the column with 5 at the top. For 65 you get F 3 in the two boxes (note/octave). What is interesting about this are the patterns that you get when you take the usual '2 and 3' pattern of accidentals that you see on a normal music keyboard and wrap it around decimal numbers. The columns have either 3 and 3, or 2 and 4 patterns of notes, and the diagonals have more patterns: 3 and 4 and 2 and 3. if you are into patterns, then the last row of blocks of 2 always repeat the octave in the cell underneath, whilst blocks of 4 repeat the octave value of the cell above the first row. Block of 3 do different things depending on if they contain accidentals or not! If you are familiar with chess, then 'Knight's moves' on this table give you the cycle of fifths...

If you have ever seen one of my Tweets about cryptography, then my fascination with patterns now probably makes more sense. Music and cryptography both contain a lot of maths underneath, and so patterns are not unexpected!

Controllers and control

Swapping the note number for the velocity value renders makes it very difficult to play keyboards and MIDI controllers because the velocity value is often difficult to control with the same amount of precision as you would find on a keyboard where each key produces a specific note number. Velocity is determined by the rate at which the key is pressed down, and so is based on a time measurement. By swapping these two values, keyboards and MIDI controllers gain precise control over velocity (what used to be pitch control is now velocity control!), but lose the precision of pitch control.

Steganography


Steganography is all about hiding information in places where it is not visible. One example is in JPEG picture files, where it is possible to hide data inside them by spreading it across the whole picture in ways that are not obvious. So there might be slight and gradual changes to brightness, colours, levels of noise or other parameters, that are not visible o the human eye, but that can be detected.

In this case, MIDIswapNVmr01 increases the precision with which changes can be made to the velocity value, but the pitch becomes less precise - in fact, trying to control pitch by how quickly you press a key spreads out pitch control into a very imprecise form! In graphical form, this might be represented by the amount of blurring (as a metaphor for the spreading out of data):

So a conventional music keyboard has precise control over pitch, so the word 'Pitch' is in focus, whilst the velocity control is less precise, and so the word 'Velocity' is blurred.


What MIDIswapNVmr01 does is swap the blurring - so now the word 'Pitch' is blurred, whilst 'the word 'Velocity' is in focus.


At Synthfest UK 2019, I spoke to Paul Ward about some of the FM sounds that I had programmed anonymously for the UK DX Owners' Club (many of which are widely available in various Public Domain collections - one set of my sounds have distinctive titles like : '-=[V]=- 1', for example), where there was a high amount of velocity sensitivity built into many of them. Controlling them can be tricky for fast runs of notes, and so Paul said that he preferred to use controllers like Mod Wheels to give more precise control.


What MIDIswapNVmr01 provides is precise velocity control from a keyboard, but sacrifices pitch control. With a fixed velocity from a keyboard, then MIDIswapNVmr01 only outputs one pitch, but you have precise control over velocity - and in fact, even a 88-note keyboard is going to give you access to only part of the full 1-127 velocity range (in exactly the same ways as it only normally lets you play 88 of the 0-127 range of MIDI note numbers!).

Which is why I said right at the start that this was for experimental purposes. I'm not expecting a sudden change in workflow so that people enter pitches very precisely (as usual!) and then use MIDIswapNVmr01 to enable them to add precise velocity as well. But my thinking is that given recent developments with MPE, and with sophisticated controllers like the Roli Seaboard, Haken Continuum and Expressive E Osmose or Expressive E Touche (others are available!)  then it might make people think more about additional control other than the pitch, timing and a very imprecise velocity value that you get from a traditional music keyboard.

Real-world instruments often have a lot of ways that the timbre can be influenced in real-time, and their players know how to exploit this - so I reckon that electronic musical instruments should be controllable in multiple dimensions as well. One very interesting illustration of this is in sample libraries of sounds produced using FM synthesis - what you get are very nicely sampled 'snapshots' of specific timbres, but you lose a lot of the subtle velocity control that programmers like myself put into sounds, and so the timbral variation is missing. I always remember when the first mass-market sampled pianos came out in the 1980s (Technics et al) that they were described by many players as sounding like:

'A very good recording of a piano, but not a piano.' 

Inside

As I mentioned, this plug-in is based on the MIDI processing core of the MIDIfilterNOTEmr utility, so let's see how it works:


As usual, I have tidied my normally untidy code in the screenshot above. The right hand side is very similar to the MIDIfilterNOTEmr code, with the 'select' object switching between two values depending on the incoming value. But here the 'swap' object at the top is used to change the note number and velocity over (as well as changing their 'right=-to-left' processing order), and so the velocity value does the same switching depending on 'Note On' or 'Note Off', but now switches the note number value because that is what will end up in the middle 'velocity' input of the 'note out' object.

On the left hand side, the 'select' object is again doing switching, but this time it is actually making sure that the velocity value is stored. The velocity value that comes out of the 'swap' object contains two values, the velocity value from the incoming notes, or zeroes from the Note Off messages. So the left hand side is all about capturing the non-zero velocity value, and making sure that it is stored when the zero velocity is output by the 'swap' object. So the two grey message boxes are just two stores in series, and the trigger for the storing is produced by the 'select' object when it detects a Note On or Note Off message. Finally, that captured and stored velocity value is fed into the left hand 'Note number' input of the 'note out' object. 

This approach could be extended to longer serial chains, and might open up additional possibilities for doing more complex MIDI processing. Because some previous posts have talked about Max's sample-level lower-level programming, then the message box approach used here could be thought of as being kind of half-way between ordinary Max and Gen: MIDI-event-level, perhaps? 

Fun!

One unintentional side effect of MIDIswapNVmr01 is that it makes playing a music keyboard in the conventional way almost impossible... So if you are every visited by a highly skilled concert pianist, and they want to play one of your keyboards, then using MIDIswapNVmr (to swap the MIDI note number and the velocity value of their playing) will considerably impede them...

Alternatively, sometimes, changing a familiar constraint (like pitch control from a keyboard and changing it to being controlled by velocity) can break you out of creative road-blocks... Inverted keyboards are another way to do this, and I have produced a Max For Live plug-in that does 'proper' inverted MIDI keyboard mappings and lots more!), but just using a Scale utility over an octave can achieve a similar 'writer's block' mitigation.

Actually, combining the ideas in the previous paragraph - adding a Scale utility after MIDIswapNVmr01 so that the MIDI notes are constrained to a specific scale - is a very practical and useful way of using many of my weirder plug-ins (like my MIDI note range expander/compressor and offset utility). What the Scale utility is doing is constraining the variability from the velocity measurement, which takes us to the several variations of 'constrained randomness' in another of my plug-ins.

I'm wondering if I can find time to do a 'how to use my plug-ins in combination' tutorial...

Getting MIDIswapNVmr01

You can get MIDIswapNVmr01 here:

     https://maxforlive.com/library/device/6081/midiswapnvmr

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

Modular Equivalents

In terms of basic modular equivalents, then implementing MIDIswapNVmr01 depends on your MIDI/keyboard interface. If that produces CV outputs for Note Number (Pitch) and Velocity, then a couple of patch cables crossed over and connected to the output (with a gate cable as well) will do this directly, giving an ME of 1! This is the lowest modular equivalent so far, if my memory serves me correctly...

Links from this post:


Roll Seaboard (Company web-site)

Haken Continuum (Company web-site)

Expressive E Osmose (Company web-site)

Expressive E Touche (Company web-site)

MIDIfilterNOTE (MaxForLive.com)

MIDIfilterNOTE (Blog post)

Christian Henson (YouTube channel)

#pianobookpianoday2020 (YouTube search)

---

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











Saturday, 27 October 2018

Flamming, Fluttering and just plain echoes...

Lots of other people have already noted the 'slightly less immediately obvious' devices inside the Ableton Live 'Max For Live Essentials' pack (for Live9!), but there is often an interesting alternative angle, and that's where I come in. In particular, Note Echo caught my eye, because it is a MIDI-domain echo, and it is programmed in MaxForLive...

Here's what I'm working towards in this post:


But first, some more background... 

Note Echo looks very similar to the long-established, factory default 'Audio Effect' called 'Simple Delay', but instead of processing in the audio domain, it processes the MIDI messages that control the production of the audio itself. So instead of having an Instrument produce a note that then gets echoed, Note Echo gets the Instrument to play several notes, delayed in time. So the echo happens before the audio is produced (which makes me think of the amazing fictional substance called thiotimoline...). 

Sometime during my Live9 to Live 10 updates, I got two versions of Note Echo. (Notice that the two Note Echo devices are MIDI Effects, so they go BEFORE the Instrument, whereas Simple Delay is an Audio Effect, and so goes AFTER the Instrument):


Producing echoes in the MIDI-domain enables some interesting special effects that aren't easy to achieve in the audio domain. The 'Feed Delay' rotary control in Note Echo allows you to control the amount of the incoming note's velocity parameter that is used in the delay section, and if timbre is influenced by velocity, then this means that the echoes that are produced are going to sound different depending on the velocity! In the audio domain, then an echo can merely work with whatever audio it receives at its input, but Note Echo transcends that limitation. I often program lots of velocity sensitivity into my sounds, and so I tried a few of my more extreme DX7 FM sounds that use velocity to make radical changes to the timbre, and these sounded really interesting when driven by Note Echo.

Another advantage of doing delay in the MIDI-domain is that you can control precisely what it is applied to. A few edits (Note Echo is programmed in MaxForLive) later, and I had a stripped down version of Note Echo that only affects a single MIDI note and had the pitch shift removed. After adding an LFO and a control mapper, I had an M4L device that does flutter echoes, but only on a single chosen MIDI note number. Now, you could use a separate track with just a single note on it, and process that using 'Simple Delay', but having a purpose-built device that works on an ordinary track is much quicker and more convenient, and I quite like both of those features!

My grateful thanks go to Ableton and Cycling '74 for Live and Max For Live - having example devices like Note Echo are a great inspiration for further exploration, and the ability to extend/enhance/tweak existing devices is wonderful!

Drum Flammer - as shown up at the top of this post!

What I found my quickly-hacked-together device very good for was producing 'flams', something which I hadn't really used since back in the 1990s, when drum machines first started to have enough polyphony to allow clusters of time-overlapping sounds.  Back then I used to create flams by manually editing MIDI Notes to give notes that rapidly repeated, in a brute-force approximation of the drumming technique where the name 'flam' comes from - which is kind of a cue for some of the flam rudiments...


There's quite a lot going on in that user interface, so here's the same thing split out into the major sections:


As you can see, the left hand side is very similar to the source M4L device, Note Echo. I have added the lower set of electors, which control the range of time change that the LFO can make, plus at the very top, there is the incoming MIDI note number indicator (on the left), then a 'Copy' button, and then the 'Note Selector' (with the blue triangle) that lets you choose which note will be echoed. The 'Copy' button just lets you set the chosen MIDI note number to be the one that is being displayed. So you just play a MIDI controller or keyboard to send the appropriate MIDI Note On message, and then click on the 'Copy' button. (I first used the technique in my MIDIQuantCC controller quantiser... But this was for MIDI Controller numbers, of course!)

The middle section is the LFO. Having produced some wild and totally-over-the-top LFOs recently ( example 1, example 2 ), this one is rather ordinary by comparison. Perhaps the only feature of note is the 'Random' waveform, where I haven't used the traditional Sample-and-Hold waveform, but instead I have used a rate-multiplied piecewise-linear waveform that seems to give good results in this application (and now that I have it done and dusted, I may well use it when I next revisit my other LFOs...).

The right hand side is just the standard parameter mapping controls that I have gradually been adding to my devices. It allows you to use the LFO to control the internals of the device itself, AND to control another parameter somewhere else in Live. This can be very useful for all sorts of interesting and unusual effects.

User Tips

For flams, turn the Offset rotary control (in the middle of the device) almost all the way anti-clockwise ( the shortest times) and set the time buttons on the left to '1'. Use a little bit of LFO Depth to give some movement to the sound, and set the two feedback rotary controls as far clock-wise as you dare. You will find that Drum Flammer can eat up processing power, so you may find that little bar in the upper right hand corner of Ableton Live is higher than you normally see!  

For flutter echoes, then higher values of Offset and the time buttons will suffice. Even slower times will give echoes, but without many of the artefacts that you normally associate with delays. I have to say that Note Echo is a wonderful device, and well worth the processing power that it can consume sometimes - and Drum Flammer is slightly more specialised, but I love the way it can add all sorts of unexpected variability to sounds.

Despite the name, Drum Flammer can also be used for non-drum sounds! There's an example on my SoundCloud pages that very eloquently shows how you can bury an interesting sound in way too much echo... Blame it on my formative years being spent adding too much reverb to synths. 

The best tip is to get familiar with Ableton's 'Note Echo' device first. It can do some very cool effects on its own. Me, I just like to go that little bit further...

Examples

Here are links to two SoundCloud examples of Drum Flammer in action.


Coming Up

Yes, there's a typo in the UI. I will fix it in the next update. 

Getting Drum_Flammer_mr_0v01

You can download Drum_Flammer_mr_0v01 for free from MaxForLive.com.

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

Modular Equivalents

In terms of modular equivalents, then reproducing this functionality in my modulars just required the sort of MIDI note mapping to 'round-robin' synth 'voices' that is quite widely available, plus a digital delay, an LFO, and the usual Utility modules. Overall, the core is about 4 ME, but that flamming is going to eat up synth voice modules, so you would need to add 1 ME for a simplistic synth voice module per overlapping flam note... At a minimum, that would be 2 extra ME, making 6 ME in total.


Monday, 22 October 2018

Quick Transpose - a free MaxForLive utility device for Ableton Live

I'm doing some tidying up at the moment so that I'm kind of ready for the upgrade to Max 8, and so some of my older MaxForLive devices are getting a fresh lick of paint...

As you probably already know, Ableton Live comes with a 'Pitch' MIDI Effect - it has a minimalistic user interface that provides a rotary control for semitone shifting of incoming MIDI notes... Now I do lots of sound design and synthesis research inside Racks, and so do lots of octave and fifth transpositions - if you have seen me demo my RUSS residuals synthesis technique at NAMM or Synthfest UK then you will have seen me do lots of live transposes as I edit sounds), and so I have spent quite a bit of time clicking on the control and then using the up or down cursor keys to adjust the pitch of a layer. Twelve clicks per octave is a lot of clicks (Using the keyboard: 'Shift and Up arrow' jumps in octave steps, but I prefer using the mouse for just about everything), so I made a utility device that reduced the amount of clicking. My usual approach with controlling things in live performance with a mouse is that the number of mouse clicks should be as few as possible: single clicks if possible...


The original device was called 'Quick Transpose', and it was a simple device with a vaguely seasonal 'late December' colour scheme that didn't fit in with any of Live's skins, and looking at it again now, it definitely doesn't look good with Live 10's 'Dark' theme. Time for an update...


The new update (to 0v03!) adds a bit more explanation (The left hand side is for selecting Octaves, whilst the right hand side is for Fifths...) and tries to make things clearer.


There are two columns of buttons: Octave transpositions on the left, and Fifths on the right. The small grey box (with a '=') in the lower right hand corner shows the total transposition from the two columns, and the 'ANO!' button is a panic button that sends 'Notes Off' messages for any held notes in case any held notes occur (although I have tried to minimise the chances of this happening in the M4L code). Despite the name, it doesn't send an 'All Notes Off' message!



The screenshot above shows the obvious way to use Quick Transpose, and this is probably where most Live users would place it automatically - the last MIDI processing device just before the 'Instrument' in a track chain. (Also notice how my colour theme kind of works in a dark skin...)

But you can put Quick Transpose anywhere in the MIDI part of a track chain, which means that it can go in front of a synthesiser inside an Instrument Rack:



This allows you to quickly transpose one of a set of synthesisers to parallel fifths or octaves with a quick click of the mouse, and you could always put another instance of Quick Transpose in front of the whole Instrument Rack to avoid needing to select notes and shift-octave them in the piano roll view. (The 'Select, Shift-Arrow' octave transposing is another way of transposing the whole sequence, but splitting poly tracks apart into mono tracks is usually a bit fiddly and slow to do.)


Here's the 'Operator' of the three parallel synths in the Instrument Rack, transposed down by one octave.


And finally, the 'Wavetable' transposed up by one octave. I have often wondered about making a device that puts controls deep inside Racks up at the top level, but I'm still learning about the programming model for Live, and I don't think my knowledge is quite up to it yet...

Getting Quick_Transpose_mr_0v03

You can download Quick_Transpose_mr_0v0for free from MaxForLive.com.

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

Modular Equivalents

In terms of modular equivalents, then reproducing this functionality in my modulars was harder than I thought it would be. I settled on a step sequencer and a manual clock and ended up at about 3 or 4 ME. One of the interesting things about modulars is that the mundane labour-saving modules are often the hardest to find, and I end up designing my own, and then end up with something very custom and personalised - which is what my Ableton Live looks like too...

Alternatives

Yep, you can use the factory device from Ableton: 'Pitch', to do exactly the same function. But it requires setting the focus to the rotary pitch control (with a click on the control) and then using 'shift-up arrow' to jump in octave steps. Or you can type in '12'. As I say, my preference is to do just about everything using the mouse, not the keyboard, and for me, continually jumping back and forth between mouse and keyboard is a big switch in context each time. Your preferences may differ, of course.

(You could also use the 'Transpose' box in the 'Scale' device - the 'shift-up arrow' shortcut works there as well.)

Inside a Rack

As I said, when I'm doing sound design and synthesis research, I spend a lot of time inside an Instrument Rack, tweaking synths and sample players and transposing to get the right feels from the layered output. What I've been working on for quite a while is a single device that puts all of that transposing into a single UI, instead of it being spread throughout the layers of the Rack. But I have always wondered if this is too specialised a device for general use... Anyway, it turns out that you can use Macros to do this...



So here's a typical three-layer synth sound, using Analog, Operator and Simpler. I have added a Quick Transpose and a Pitch M4L device in each layer, and mapped Macro Controls to each of them. This undoes the burying of the transposition controls inside the Rack, and presents them at the top level, where they are very easy to get at...

( Of course, in a real-world Rack, only three of the Macros would be assigned to transposition - the other five would be to other parameters! I'm showing the two sets of macro assignments for comparison purposes only. )


As you can see, the 'use Ableton devices' method uses Pitch to do the transpositions, and so the basic mapping gives a range of +/-128 semitones for the Macro rotary control. A quick edit to the Mapping Browser, and this rename can be set to +/-12 semitones (see the screenshot collage below). Unfortunately, Macro rotary controls do not respond to the 'Shift and Up/Down' keyboard shortcuts, and so there's quite a lot of shifted cursor key presses required to transpose by octaves (12 presses per octave).


The 'Quick transpose' method maps the three Quick Transpose devices to the three rotary Macro controls, but this time, the 'live.tab' Max object isn't very well supported in the Mapping Browser - you can't change the range, and can't invert the range. As a result, transpositions downwards require the rotary control to go clockwise, and so high values of the 0-128 value indicate low transpose values. But the live.tab object quantises the values to octaves, and so there are really only five values for the rotary controls that matter: 0-15 maps to +24 semitones (+2 octaves), 15-47 makes to +12 semitones (+1 octave), 48-79 maps to zero (no transposition), 80-111 makes to -12 semitones (-1 octave), and 112-127 maps to -24 semitones (-2 octaves). So selecting one of the five octave transposition settings is very quick if your preference is to use a mouse for most editing in the Live user interface, but transposition is slower if you use the keyboard cursor keys to move up and down one semitone at a time...


You can see the effect of the lack of an 'invert' option in the screenshot above. The 'Ableton Pitch' method gives a rotary Macro Control that goes clockwise for transposing up in pitch, whereas the 'Quick Transpose' method results in a rotary Macro Control that transposes down in pitch for clockwise rotation. But the quantisation makes it easier to set the transposition because there are only five positions for the Macro that is mapped to the 'Quick Transpose' live.tab object - and the lack of a 'Shift-Up/Down' keyboard shortcut makes the 'Pitch' method more fiddly since it requires careful mousing to move the exact multiple of 12 semitones, or requires multiples of 12 ip/down cursor key presses to shift in octaves.



For completeness, the 2 octave view is shown above.

In conclusion, then there are advantages and disadvantages for each method. The 'Use Ableton devices like the Pitch device' method doesn't require an additional M4L device, but suffers from a missing keyboard shortcut and requires lots of key presses or precise mousing. The 'Quick Transpose' method requires an additional M4L device, but has a user interface that is easier and quicker to use with a mouse, but requires huge numbers of cursor key presses. It all depends on your preferred method of interacting with the Live user interface - my preference is for mousing, but I also use the cursor keys for precise control!















Sunday, 12 August 2018

Quantising MIDI controllers in a MaxForLive device for Ableton Live

Forums and Groups are interesting places to lurk. If you ignore the incessantly repeated questions and the obvious trolling, then you occasionally get a query from someone who wants to do something unusual and interesting, and can't see how to achieve it. Recently, just such an enquiry turned up on on one of the popular synthesizer forums, and here, belatedly, is a response.

The enquirer asked about how to make a movement-sensing MIDI controller more predictable or repeatable. If you have ever tried to use any location-dependent controller that relies on where you hold your hands in the open air, then you may already be resonating with the difficulty. If you have ever played a Theremin, then you probably already know one of the challenges: making rapid, precise and repeatable movements of your hand between a small number of locations in 3D space is difficult. There's also the 'two different actions at once' problem: making the 'pitch-controlling' movements as rapid as possible (but don't forget precise and repeatable!) with one hand, to reduce the portamento between notes (and making the pitching as accurate as possible), whilst at the same time, making slow back and forth 'volume-controlling' expression movements with the other hand. It's tricky to master, and one of the ways that the 'not in tune' pitch variability can be mitigated is to apply 'quantisation': constraining continuous values to a small set of fixed values. For note length then DAWs have quantisation as a standard function. For MIDI controller messages then I assumed that there would be lots of utilities readily available...

MIDIccQuant 


MIDIccQuant_mr is a utility device for Ableton Live, produced using MaxForLive, which quantises MIDI controller messages. Version 0v01 is the first release, and quantises to 4 levels, mainly because the UI for more than this starts to get awkward - but feedback should tell me if this is not enough levels.

Here's the overall flow diagram for what is happening, with the relevant bits of the UI above or below:


MIDIccQuant can process any one of 15 inputs, and the choices are the basic low-end simple controllers: Modulation, Breath Controllers, Foot Controller, Data Entry, Expression, and the general purpose controllers. These are the sort of controller numbers that a lot of MIDI Controller devices will be mapped to. I have always disliked the way that many utilities expect you to know what the controller numbers are, and so MIDIccQuant shows a number in the lower left hand corner that indicates what controller number incoming messages are from. Assuming that you don't have more than one controller active at once, then all you do is wiggle the MIDI Controller (or move your hand if it is a movement/position sensor) and look at the number that is displayed. To make it even easier, then clicking on the 'Copy' button will set the 15-button pad to that controller. If you prefer, and you already know the controller number, then you can just select the appropriate number on the pad!

The big 'CC' button controls the output of the processed controller value. When it is bright, then the controller value is quantised and sent out as a controller message. When it is dim, then the controller value is not quantised, and passes through the device unchanged. There's a big vertical indicator that shows the controller value.

There are seven rotary controls for the quantiser: three that set the levels at which the quantisation happens, and four that set what value is output for each of the four output states. This is slightly different to the way that note length quantisation does, because for that there is an assumption that you want to quantise a note to either slightly shorter or slightly longer, and so if you have an input that is just slightly longer than an 8th note, then you would expect it to be quantised to an 8th note, or a dotted 8th note, or maybe even a quarter note, depending on the quantiser settings. But MIDIccQuant allows the result of the quantisation to be any of the 128 MIDI controller values, and so if you set the lowest level to 15, then that output will be active for any incoming controller values between 0 and 15, and this could be set to output anything from 0-128. Rather like the Theremin, this might require some getting used to, and so the recommendation is that you set the outputs to get higher as you move up in the device UI.

Let's look at levels and outputs in more detail. The three 'Limit' rotary controls divide the 0-127 MIDI Controller values into 4 Levels:


So the lowest level (Level 1) is from 0 to Limit1 (0-18 in this example). The next level is Level 2, from Limit1 to Limit2 (19-65). Level 3 is from Limit2 to Limit3 (66-103) and finally, Level 4 is from Limit3 to 127 (104-127). Note that although the Levels are always arranged from 1 to 4, where Level 1 always starts at 0 and Level 4 always ends with 127, the same is not true for the Outputs - you can put any value you like (0-127!) for any level. If an output always has steps that increase as the input increases, then it is called 'Monotonic', and so this quantiser is non-monotonic. So if you want Level 1 to output 127, and Level 4 to output 0, then MIDIccQuant will do this.


In the above example, on the left hand side, as the input controller values increases, the output jumps UP from 30 to 48, then jumps UP to 82, then jumps UP to 101. So it always goes up as the input goes up - this is monotonic behaviour.

The right hand side has swapped the outputs for Levels 2 and 3, so Level 2 is 82, whilst Level 3 is 48. So as the incoming controller value increases, it starts out outputting 30, then when the input reaches 18, the output jumps UP to 82. As the incoming controller continues to increase, the output stays at 82 until the input is 65, at which point the output jumps DOWN to 48. When the input reaches 103, then the output jumps UP to 101. This is non-monotonic behaviour.

All you then need to do is make sure the whatever device you are controlling is getting the quantised controller value. Remember that if the 'CC' button is bright, then it will be receiving quantised controller values, and so the usual 'just testing' technique of waggling the mod wheel (et.) may not work if your quantisation is set with extreme values. So, slightly counterintuitively, you need to click the 'CC' button so that it goes dark, which bypasses the quantisation, and then do the testing. When the target device is confirmed to be receiving the controller values, then just click again on the 'CC' button to restore the quantisation.


To make the utility more useful, then there is a second output. The right hand side is my standard controller mapper, which lets you optionally invert the controller value, add an offset, scale it with the  'Depth' control, and map this to any controllable parameter in Ableton Live (and unmap it, of course). The 'Quant' button controls if the output from the parameter mapping is quantised or not, which can be useful if you want to have different consequences from the controller in two different places. The big 'Param' button disables the parameter output when dim, and enables the output when bright.

To visualise the quantisation levels, there's a display that shows the four levels - it builds up as you input values, so if you change the levels, then you can click on the 'Clear' button to clear the display. This can also be used as a simple MIDI controller debug facility.

More than just MIDI Controllers...

Version 0.02 adds a small input number at the top of the input bar indicator. This allows you to map any controller so that it can be processed by MIDIccQuant. So you can now take an LFO (or any other MaxForLive device that has a 'Map' button) and quantise its output! I'm expecting some interesting applications of this from my users...

Getting MIDIccQuant_mr_0v02

You can download MIDIccQuant_mr for free from MaxForLive.com.

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 the factory devices...)

Modular Equivalents

In terms of modular equivalents, then reproducing this functionality in my modulars was quite a challenge to achieve using standard 'basic' modules. My best simplistic solution required 4 separate 'brute force' quantisers plus several utility voltage processors, so I would rate this version as being about 9 ME. I'm intrigued that many modular quantisers assume that you want to quantise to fixed identical steps and monotonic levels, but I'm sure that there are loads of exception devices out there...


Buy me a coffeeBuy me a coffee