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

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


Saturday, 9 September 2017

Mapping MIDI Velocity to Two Ableton Live Parameters

Dual Velocity Mapper_mr


Whilst there are quite a few M4L 'Velocity-to-Parameter Mapping' utilities available, I couldn't find many multi-channel versions, so I made a two channel utility, called 'Dual_Velocity_Mapper_mr' (DVM_mr), and available from MaxForLive.com as usual. DVM_mr has an easy setup mode, that lets you quickly set the offset and depth of the 'velocity to parameter' mapping, and re-uses the Ableton parameter mapping control from their LFO device. 

To use DVM_mr, you click on the 'Setup' button (in between the two big blue buttons near the centre) and then map each of the blue buttons to a parameter inside the synth you want to control. You then move the mouse from left to right and this causes notes to be generated at different velocities, so that you can see and hear the effect of the velocity changes on the parameters. Moving the mouse up and down (on the screen, forwards and backwards from the mouse-viewpoint!) changes the pitch of the notes. This speeds up the setup phase quite a lot, and makes it quick and easy to map velocity to two parameters. To clear the mapping, you just click on the 'X' buttons. The 'Invert' button inverts (turns 'upside-down') the MIDI velocity, so that higher velocities produces lower values. 

The mapped parameters shown in the DVM_mr screenshot might be a useful starting point for further exploration...


The Velocity Mapper_mr M4L MIDI Effect is available from MaxForLive.com

(Yes, this is extracted from a previous blog post, because it was hidden away at the end, and I thought that it deserved better visibility!)


Sunday, 3 January 2016

DIY MIDI Controller with LEDs

Possibly one of the least amazing titles for a blog articles! In these days where RGB LEDs feature on just about every specification list for MIDI Controllers, then the only difference is that it's a simple home-brew MIDI Controller - creatively mis-using a spare numeric keypad.


The numeric keypad is intended to be used with laptops that don't have separate number keys in a nice neat square form, and require the user to either use the buttons over the 'qwerty' row, or to do various extra key-presses to re-use other keys on the main qwerty keyboard. So the keys on the keypad just map into the standard key numbers as if this was a full external keyboard. To use the keypad as a controller, I have been working on a simple MaxForLive plug-in that intercepts the incoming key number messages and allocates them to functions in Ableton Live - this is still ongoing work, but the controller is finished, hence this blog entry!

The keypad as supplied is very boring: black plastic everywhere, and the only concession to RGB LED-ness is a red 'Num Lock' LED that isn't really relevant in this context. So this obviously needed augmenting. First task was to light up the keypad itself, and four blue LEDs did that very nicely. The numeric keypad came with a USB plug, so power was easily available, and I just added a few series resistors to the LEDs. I could have added more LEDs, but four was okay for this first iteration, and there is a definite limit to how much hot-melt glue you can use without waiting for it to cool down properly.

The flashing yellow circle came from a concert wristband that my son was about to throw away because the batteries had died, and so that was pressed into service (with an on/off switch). The flashing multi-coloured interior to the circle was one of those 'infinite mirror' displays where two mirrors bounce light back and forth many times giving an illusion of depth, and so that became the middle of the circle, again with a selector button to allow the choice of flashing mode.

The end result looks very flashy (deliberate pun!) but has one problem - the backspace and return key tend to be used in mot application UIs - and in Ableton Live the Backspace key deletes the active plug-in, which is usually the custom M4L plug-in, whilst the Return key tends to spawn a new version of the plug-in. Obviously these buttons are not very useful in a control context, and the simplest solution was to disable them - mechanically (you were expecting a software method, perhaps?).

 Disabling keys on keypads is relatively easy given the lack of travel of modern keypads - you just put lumps of blu-tack (or other similar slightly sticky substance) underneath them, so that pressing them doesn't result in any movement. Here are some photos showing bits of this process.





Prising keys off is usually pretty easy - I use a screwdriver. doing the blu-tack is easy, and putting the key back is normally just a question of pushing it back.

Please note that the lower cost the numeric keypad, the easier these types of mods tend to be. Levering out the keys on an expensive laptop (an Apple MacBook Pro for example) and trying to put them back with blu-tack underneath is definitely not recommended! (Just don't do it!)


To indicate that two of the keys were now disabled, I covered them with white typing correction fluid, something which used to be a standard home office accessory... I'm looking for a better solution, and 'sticky-back plastic' is definitely beckoning me!





And that's it. A spare (actually unwanted, although it sounded like a good idea at the time!) numeric keypad turned into something which looks like a MIDI Controller, and which may well be used when I iron the bugs out of the MaxForLive plug-in. In the meantime, it looks very good on stage, and isn't that one of the prime reasons behind all of those RGB LEDs anyway?

Now that I think about it, I probably didn't need to modify the keypad at all - I could have just assembled a few bits of LED toys and put them into a suitably technical-looking box and I'd have a stage box that smart-alecks and know-it-alls would look at and say things like: '...and there was this amazing home-brew controller...'. Maybe there's a business opportunity here?

[ Note that I'm not suggesting that you modify/wreck your own (or anyone else's) keypads, keyboards, laptops or anything else. I'm just showing that I sometimes do hardware as well as M4L! If you do make any modifications, then you assume full responsibility for them! ]