Sunday 26 September 2021

MIDI Velocity Splits

I've been playing with Dave Hilowitz's excellent Decent Sampler quite a lot recently. One of the things that I've been exploring is velocity-switching, that time-consuming process where you record the same pitch at various intonations, strengths, powers,...velocities! 

I've always been intrigued by the way that MIDI terminology has become so deeply embedded in electronic music making. Playing notes harder and softer may have given us an instrument name derived from the Italian for those words: the Piano-Forte (or just Piano for those who know it well.), but somehow, the MIDI output related to how quickly you hit a note has become synonymous with 'how hard you hit a note'. I had always though of pressing piano keys as being an 'amount of forc'e thing, but MIDI forced me to realise that to measure that force you needed to make a measurement of the speed of the key as it moved from one stationary position to the other. And so the posh word for speed: velocity, became the word for what your fingers do on a piano - they change the velocity of the keys: the harder you press the key down, the higher the velocity. Hence, you must be controlling the velocity of the keys with your fingers, because that's what the MIDI output says you are doing!

(Note: Okay, so when they aren't moving, then the 'velocity' of the keys is zero, unless you factor in the rotation of the Earth, and the movement of the Solar System, and... Lets just say that when the keys are 'at rest' they have no velocity relative to the rest of the keyboard...) 

In MIDI 2.0, of course, velocity is 'the same, but also different' - it's a 16-bit value, which allows for 16,384 different velocities. Which is a lot of fine detailed control. If I'm honest, I'm not sure that my fingers are capable of anywhere near that many levels of conscious or physical control!

For the rest of this blog post, I'm going to stay in MIDI 1.0 land, where velocity is only 7-bits, and so has a mere 128 different velocities (Now this sounds more like my abilities!). And, as so often happens, the very first thing that comes up is not actually correct. Nope, there are not 128 different velocity values in MIDI 1.0. There are only 127, because the velocity value of zero is special.

(I'm deliberately not going to try and figure out how many 'bits' a range of 127 values is equivalent to! 'Slightly less than 7 bits' is one imperfect way of expressing it. '7 bits, where 0 is a special value' is perhaps better.)

When you think about it, a velocity of zero makes no sense. No matter how lightly you press a key on a piano, it will always go from one stationary position to the other, and so the velocity has to be greater than zero. If the velocity was zero, then the key would not move! So, when the MIDI Specification was developed back in the 1980s, a velocity of zero was used as an optional 'special purpose' shortcut that avoided needing a Note Off message to accompany every Note On message. Under ideal circumstances, this 'Running Status' tweak means that you can reduce the amount of data required to send single channel MIDI information by up to a third. So instead of sending this:

Note On Status

     Note On Number    60 (Middle C)

     Note On Velocity 1-127

<time the note stays on>

Note Off Status

     Note Off Number 60 (Middle C)

     Note Off Velocity (0, but could be up to 127)

then the next note...

What gets sent instead is:

Note On Status

     Note On Number   60 (Middle C)

     Note On Velocity 1-127

<time the note stays on>

     Note On Number 60 (Middle C)

     Note On Velocity 0 (equivalent of a 'Note Off' message)

Yep, there's no Note Off messages at all when you are using the Running Status' mode', and a velocity value of 0 turns what looks a lot like a Note On message (but without the initial status 'byte) into the equivalent of a Note Off message. So instead of 6 MIDI bytes, only 5 need to be transmitted. But for longer sets of notes, then you don't need to send any status bytes, and so instead of sending 6 bytes (3 bytes for the Note On message, and 3 bytes for the Note Off message) then you only need to send 4 bytes. Of course, any messages that require a change of status will require a new Note On status byte to re-establish what channel the notes are playing on - one example would be notes on a different channel, or MIDI Controller messages (which aren't Note On messages!). 

A quick aside about MIDI Implementation Charts:

Keyboards that implement the 'release' velocity when you stop pressing a key down are not very common, but not as rare as you might think, by the way... And often, this feature is not documented. Yes, many MIDI keyboards send MIDI Note Off messages containing release velocity, and they don't always mention it in the user manual. The place to look is the MIDI Implementation Chart: in the 'Velocity' section...

So this MIDI device implements Note On Velocity (the 'O' in the second column ('Transmitted') and the third column ('Received'), but does NOT implement Note Off (aka 'Release') Velocity (the 'X' in the second and third columns). 

What you are looking for 'transmits and receives release velocity' could be something like this:

Velocity  Note On       O 9nH, v=1-127      O 9nH, v=1-127
          Note Off      O 8nH, v=1-127      O 8nH, v=1-127

My Yamaha Montage 7 looks like this:

Velocity  Note On       O 9nH, v=1-127      O 9nH, v=1-127
          Note Off      X 8nH, v=0          X

Which means it doesn't send Note Off (Release) velocity, but it does clarify that it sends 0 (zero) for a Note Off message!

Some devices don't send a velocity of 0 (zero) for Note Off messages. here's a Roland TD-50 drum module:

Velocity  Note On       O 9nH, v=1-127      O
          Note Off      X 8nH, v=64         X

And, just in case you were wondering what does implement Note Off (Release) Velocity, here's just one example: the Kurzweil PC-4:

Velocity  Note On       O                   O
          Note Off      O                   O

And back to the main story:

So, now that we know that a MIDI Velocity of zero isn't the lowest value, but instead 1 is the lowest value, we know that there are 127 different velocity values in MIDI 1.0 - that's from 1 to 127, just to be precise. Luckily, it isn't necessary to sample every possible velocity, and as I said above, my fingers are not good enough to play exact velocities anyway. 

Velocity switching allows a sampler to play different samples depending on what the MIDI input velocity is. Sometimes people assume that this means that the samples which are going to be used for lower velocities have to be quieter, but this isn't the case. All of the samples have about the same volume level, but the velocity value in the MIDI message will determine how loud they sound when they are played. Velocity switching is not about volume - it is about timbre...

Woah! Velocity switching is not about volume? Absolutely. Let's take the example of no velocity switching, so there's a single sample, and it plays for any incoming MIDI message with a velocity between 1 to 127. (For a velocity of zero, then it won't sound at all!) Now you can think of this either as 'No Velocity Switching', or alternatively, as 'Velocity Switching with One Zone'. Whatever you call it, the sampler plays that sample, regardless of the incoming MIDI Velocity value in the Note On message, BUT it will play it louder or quieter depending on the Velocity value. 

For two zones of velocity switching, then there are two samples. Typically, one of them will be for the sound that you want when playing hard (high velocities!), and the other for playing softly (low velocities). So the loud/hard sample might play for MIDI velocity values of 127 to 64 (inclusive), whilst the soft/quiet sample would play for MIDI velocity values of 63 to 1 (inclusive). If you listened to the samples themselves with the same velocity value, then they would be similar volumes, but the timbres would be different. (One interesting thing to explore is to reverse the samples for a velocity-switched instrument like a piano, so that the hard samples play for low velocities, and the soft samples for high velocities. The result is a very strange piano...)

One important thing here is those two values where the sample switch over: the 63 and 64 numbers.  I chose these values because they are approximately half-way between the 1 and 127 limits of velocity value: 64-1 = 63, and 127-64 = 63. So, really, 63.5 is half-way, but MIDI 1.0 doesn't work like that, so convenient ranges for the two velocity zones are 1 to 63, and 64 to 127. The full range from 1 to 127 is covered, and there is no overlap. If the ranges were 1 to 64 and 64 to 127, then both samples would play for a MIDI Velocity value of 64, which would probably make that single sound much louder (by about 3dB, but there's another whole story about how that would work...) and that would sound silly. So 1 to 62 and 63 to 127 would also work, and this would mean that there would be a very slight bias to the hard sample instead of the soft sample - assuming that I could play a range covering all the available MIDI Velocities. 

For two zones, then it is quite easy to look at the 1-127 range and figure out that 63 or 64 is about half-way. When you have more zones, the it isn't quite so obvious. For three zones, then the starting point would be to use 127/3, which is 42 and a bit. For four zones, then 127/4 is slightly less than 32.  For five zones, then I decided that I would use a spreadsheet.

I also decided that since my fingers don't do precise MIDI Velocities anyway, then the nearest 10 or 5 was probably going to be fine. So here are the ideal values, which are absolutely not very memorable numbers in most cases:

Remember that the values show are for the low (Lo) and high (Hi) thresholds of the velocity split points. So the two zone section on the left hand side has 1 to 63, and 64 to 127. 

And here are those values converted to the nearest 10 and 5:

More than 8 zones of velocity switching is probably only relevant to very high quality piano samples, and would probably require some quite sophisticated mechanical systems to play notes with consistently repeatable MIDI Velocities. If you need more zones, then a spreadsheet, or even paper and pencil, is all you require, plus some time. Of course, based on some of the posts I have seen on various music-oriented Facebook groups, then you could just ask there, and I'm sure someone will say 'Buy a PC!', someone else will say 'DAWless rules!', and someone else will say 'Here's a spreadsheet with all of the values for zones from 2 to 127, and if you could just subscribe to my YouTube channel...'.   

For me, the 'nearest 10' values suffice for the two, three and four zones of velocity switching that are the limits of my patience. When I recorded the samples for my 'VacuumTap' Virtual instrument, then I did 8 zones, and I am not keen to repeat the process! If you look at the Decent Sampler XML file, then you will find that I used a variety of different velocity splits. Consistent: me?


All of the velocity splits shown here assume that the 1 to 127 range needs to be split linearly into zones. Human beings tend to interpret many things with non-linear scales: frequency doubles for every octave you go upwards in pitch, sound gets quieter with the square of the distance from the source, and so on. Most MIDI keyboards have a way to adjust the 'Velocity' 'Law' or 'Scaling' or 'Curve' so that it feels right to your own preferences, and so after setting that so it suits my playing style, then splitting the output into linear ranges (same sized!) feels right to my hands and ears. There's nothing (pencil & paper, or a spreadsheet) to stop you calculating your own custom non-linear zone split values, if you want.   


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

Synthesizerwriter's Store (New 'Modular thinking' designs now available!)

Buy me a coffeeBuy me a coffee (Encourage me to write more posts like this one!)

No comments:

Post a Comment