What's your favourite way to use MIDI velocity values for volume changes?

Masa's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi all, the below is how I use MIDI velocity values for volume changes.
The drawbacks are:
1. It doesn't have the control of adjusting how much velocity affects volume (how sensitive volume is to velocity)
2. It does not consider how we perceive loudness from the aspect of psychoacoustics
I would love to know and learn how people are patching for this simple necessity.

velocity_to_volume.maxpat
Max Patch
Christopher Dobrian's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You can use any formula or transfer function you'd like to map note-on velocity to amplitude. It's really a question of how loud you want the softest note (velocity 1) to be, how loud you want velocity 64 to be, etc. For any given sound played at different amplitudes, loudness perception roughly corresponds to the decibel scale, so if you want the softest sound to be -40 dB relative to the loudest sound, for example, you can do something like this.

Masa's icon

Hi Christopher, thanks a lot for your reply and the example. The simplicity of using of scale and dbtoa objects in your patch is beautiful! I will introduce that to my patch.

Masa's icon

Is there any reason you made the output of the scale object integer, rather than float?

Christopher Dobrian's icon

No. Just laziness. Float would be better.

Masa's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thanks, I have improved mine thanks to yours. Is the '0 100' message ( rather than using the '$1 5' message from the right part) connected to 'line~' just for making very sure to avoid clipping?

Christopher Dobrian's icon

I chose a pretty short attack time of 5 ms and a slightly longer release time of 100 ms, to achieve a quick percussive attack and a slightly gentler release. The attack and release times can be anything you want, depending on the sound you're trying to make.

Masa's icon

Thank you very much for your detailed explanation. That helps me a lot!