(max) mapping MIDI to audio synthesis

I’ve covered some basic audio synthesis in a previous post. Now it’s time to map MIDI note and velocity information to the synthesis process.

Note and Velocity Mapping

Download EnvelopeGraphicSustainNoteOnOff.maxpat.

The bulk of the patcher is the same as the graphic envelope series. The only addition is a MIDI note input section in the upper left corner, and corresponding changes in triggering the function envelopes.

The notein object sends key velocity to a select object, looking for 0 velocities (note off velocities). These 0 velocities will be used to trigger the release stage of the envelope. MIDI note and velocity feeds stripnote, with note numbers being converted from MIDI to frequency in the mtof object. The on velocity triggers the function envelope.

The preset object has been changed very slightly, as you no longer need to store the oscillator frequency in the preset.

Velocity Sensitivity

Download EnvelopeGraphicSustainVelAmp.maxpat.

This patcher adds velocity sensitivity to the NoteOnOff mapping patcher. It takes the noteon velocity, divides it by 127. and uses that result as a scaling factor for the amplitude envelope. The scaling factor is applied to the output of the envelope line~ object.

The weakness in this patcher is that the mapping of velocity to amplitude is linear, while we perceive amplitude to loudness in an exponential way.

Better Velocity Sensitivity

Download EnvelopeGraphicSustainVeldbAmp.maxpat.

To achieve better velocity to amplitude mapping it is more appropriate to scale velocity to dB. This patcher does that, and then converts dB to amplitude (dbtoa) before applying it to the envelope line~ output.

You can experiment with the low end of the output scaling to fine tune key velocity sensitivity. After some experimentation, I’ve settled on -48 dB, which provides at least some audibility for each note, but provides sufficient high amplitude sensitivity.