Key Sensitivity (or velocity)

BigAl2121

2008-12-11 23:29:57

I am trying hook up a midi keyboard to my computer workstation so I can hear the output on my computer speakers. The problem is that if I don't strike my piano keys hard enough, it sounds really quite (barely audible). When I hit the keys hard it is way too loud. The keyboard itself (with headphones on) has a more realistic feel compared to my computer rig. When running through Bome's Mouse Keyboard it sounds as if there are only 3 or 4 different volumes, instead of a logarithm ... or x/y function.

I want a nice sliding-scale for key-strike velocity, relative to volume. I know that I need to create rule(s) within the Midi Translator to adjust the output on my computer. I have the Midi Translator hooked into the Mouse Keyboard properly.

Can you give me clue what type of rules I should add? Here is a rough example of something I would do in an emacs scripting language.

// Returns a number between 1 and 100.
var volumePercentage = getKeyStrokeVelocity();

if( volumePercentage < 10){
volumePercentage += 15;
}
else if( volumePercentage < 20){
volumePercentage += 10;
}
else if( volumePercentage < 30){
volumePercentage += 5;
}

// Takes a number between 0 and 100
setMasterVolume(volumePercentage);

florian

2009-01-04 20:13:12

Hi BigAl,

sorry for the late reply.

This depends a lot on the different velocity values that the keyboard generates.

In general, the third number of NOTE ON messages is the velocity (i.e. how hard you press down), so you will want to modify that one. Also make sure to uncheck "output both incoming and outgoing MIDI message" in the Outgoing action.

The general scheme is:

Translator:
INCOMING: MIDI 90 pp qq
RULES:
[modify qq to have a nicer velocity response curve]
OUTGOING: MIDI 90 pp qq

Now for modifying: qq has a total range of zero to 127 (or hexadecimal: 00 to 7F). In the rules, you typically use decimal values.
Now you can e.g. use a scheme like this for increasing low values of qq:

Code: Select all

IF qq=0 THEN GOTO "End"
IF qq>64 THEN GOTO "MakeSofter"
LABEL "MakeLouder"
qq=qq*100
qq=qq/64
GOTO "End"
LABEL "MakeSofter"
qq=qq-64
qq=qq*27
qq=qq/63
qq=qq+100
LABEL "End"
Exit Rules, Execute Outgoing Action
This code above will "spread" the velocity range from 1..64 to 1..100 and shrink the range from 65..127 to 101..127. Note the explicit exception handling for velocity 0: that should always be kept, since that is often used for NOTE OFF.

Hope that makes sense, let us know how it works.

Regards,
Florian