# Midi Volume "Compression"?

Suppose your midi instrument, say a piano vst, has 16 "layers". When you input a note at velocity "1", you'll hear a very quiet ppp note. When you input the same note at velocity "127", you'll hear a very different sound, both louder (fff) and of course with a different timbre or tone, as well. (Because the instrument vst has 16 layers, and let's assume that these "layers" approximate different levels of force applied to the keys of real piano.)

Here's the issue: how do you KEEP the same velocity range (1-127) but reduce the range of VOLUME within which this velocity range operates? Reducing the volume (cc7) doesn't do it, because that just makes ALL velocities quieter. What I'm trying to do is, for example, to keep velocity "1" the same, but as we move up the velocity layers, to end up with a quieter velocity at "127". You get all the same changes in timbre that velocity "layers" provide, but now with a narrower range of loudness or volume.

• If you compress by changing MIDI note velocities before the sampler, you don’t get ”all the same changes in timbre”, because the high-velocity notes will be mapped to a different sample layer in the sampler, so —> different timbre. What do you actually want? Is the timbre really supposed to be exactly the same? (A) Input velocity 127 ==> pp or mp or mf or whatever sample played louder than normally, or (B) input velocity 127 ==> ff sample played more quietly than normally? Should velocity 127 trigger the same sample file as before but not as loud, or a different sample file? Feb 25, 2020 at 0:33

You can weight velocities differently using a velocity curve. The curve is a function that alters the incoming velocity values. For a compression effect you want to weight the low velocities close to 1 (multiply them by one, leave them unaltered), and as you go up in velocity values the weighting decreases: a weighting of around 0.8 for values around 50 velocity, and a weighting of around 0.5 for values around 120 velocity, to give one example.

Depending on the weighting (the function, the curve), you can have a gate, expander, compressor, or limiter effect.

Many keyboards have velocity curve functionality natively. Ableton Live has a velocity midi effect that has this purpose, other DAWs must have similar tools, so you have some options on where to apply the curve.

• I assume (I hope) Kontakt 5 might have something along those lines.
– john
Feb 24, 2020 at 19:51
• @john It does! You can make your own velocity scripts, or use the ones included. Feb 24, 2020 at 20:12
• Your going to have to do this inside whatever is doing the actual sample playback, otherwise in value of 110 is always going to give the sample assigned to that input at the volume assigned to its output. tbh, unless you plan on setting up your own repeatable-use version of the sample set, I'd do it in audio with a compressor. Feb 25, 2020 at 12:13
• @Tetsujin The thresholds are variable, and so is the stuff being targeted by the velocity. I'm assuming OP needs to do this before DAW or synth, since it's dealing with MIDI directly. Once inside DAW you can choose from a ton of MIDI effects and script environments, and once inside synth it all depends on the synth you are using. Feb 25, 2020 at 22:22
• @Tetsujin Audio compression and velocity curves are not interchangeable. In synth environments you want velocity to trigger different things, in different ways. Both can be used for dynamic control of volume, buy they sound VERY different, potentially completely different, even if the velocity is only being used for control of amplitude. Feb 25, 2020 at 22:29

Theoretically speaking, if you used a different channel for all the different voices, you could change the channel volume before rendering every note.

For example, let's say you're going to play the notes C D E (MIDI 60, 62, 64) with velocity 30, 60, and 90 respectively. (Volume/velocity range is 0-127). And let's say that velocities 30, 60, and 90 trigger layers 3, 6, and 9 of your sampled instruments.

Now, to make each note sound similar in volume, even thought the velocities are increasing (30,60,90), you can change the channel volume just before playing each note. For example:

- Channel volume = 90
- Play C / note 60 at velocity 30
- Silence note 60
- Channel volume = 60
- Play D note 62 at velocity 60
- Silence note 62
- Channel volume = 30
- Play D note 64 at velocity 90
- Silence note 64


Obviously, to do this:

A) You cannot do it while playing, you must program it into the system somehow, or change the channel volume just before each note starts in post-production.

B) You must use a separate channel for every different note that plays at the same time.

Finally, notice that while this will effectively cap the volume at a certain level, it will sound different from using a compressor. The compressor alters each note's Attack-sustain-release envelope, flattening it to some extent. The above approach doesn't change the shape of the envelope, but simply inflates or deflates it so the peaks remain within a desired range.

Actually I'd be curious to listen to what something like this would sound like...