Tag Archives: MIDI

Some of you might be interested in the…

Some of you might be interested in the following bit of code to get bass notes to play louder (not at all Fletcher-Munson curve correction but that could be implemented too by using the a-weighting function).

:force-velocity can either be a fixed number or a function. If the latter then each consecutive event is passed to the function automatically by midi-play. Below we subtract the degree (equivalent to MIDI note number when using the chromatic scale) from 127 to make lower notes louder than higher notes, but we do restrict this to between 70 and 110, so there’ll be a hard cut-off—notes above MIDI 55 will have a velocity of 70 and those < 18 will have 110. Note that we do randomise/humanise the velocities by 10% for a less mechanical feeling (assuming your synth/sampler will distinguish significantly there); also that get-degree will return an average for chords.

(midi-play +jitterbug+ :force-velocity
           #'(lambda (event)
               (let* ((d (get-degree event :average t))
                      (v (when d
                             (min 110 (max 70 (- 127 d)))
                 (format t “~&~a –> ~a” d v)