All pastes #161762 Raw Edit

velocity in Csound

public text v1 · immutable
·published 2006-09-05 19:58 UTC
rendered paste body
Translate the MIDI key number in semitones with middle C = 60 to linear octaves
with middle C = 8, and translate the MIDI velocity number to range from 0 to 84
(roughly the dynamic range in decibels of a compact disc):
                                  instr 1
ikey                              =                    p4
ivelocity                         =                    p5
ioctave                           =                    ikey / 12 + 3
idb                               =                    ivelocity / 127 * 84
                                  endin