I noticed that something was wrong in the velocity values returned by my $VELCURVE macro. For example, in the keyboard widget, when you press a note key with the mouse in the middle of it, you don’t get a 0.5 value, even when you draw a perfectly linear curve 0-1 in the gentable widget. But the problem was not in the macro… The problem was in this csound flag:
–midi-velocity-amp=5
It converts the velocity values [0, 127] it receives from midi note-on events to [0, 0dbfs] amp values (0dbfs is the global csound variable). Usually 0dbfs=1, but the conversion from [0, 127] --> [0, 1] is not linear, because amp values are in decibel… So, for example, a velocity value of 64 doesn’t translate in 0.5, but in 0.2. This is a problem because the $VELCURVE macro expects linear velocity values, not decibel, so the curve you draw in the graph doesn’t correspond to the requested velocity.
I solved the problem by using the following flag instead of the above one:
–midi-velocity=5
that simply returns the original MIDI velocity values without alterations. Being that they are defined in [0, 127], you have to make other little mods to the code:
...
#define VELCURVE(vel) #
$vel tab_i floor((giVelCurveRes - 1) * $vel), giFT_velCurve
#
...
instr 1
iFreq = p4
iAmp = p5 / 127 ; <-- convert the MIDI velocity to [0, 1] values.
...
Now the curve will reflect exactly your desired velocity response behavior.

