views:

23

answers:

2

[I am doing this work in Java, but I think the question is language-agnostic.]

I have a MIDI Note On volume (called "data2," it's 0-127) that I am adjusting with a fader (0 to 127). The "math" I am using is simple:

newData2 = oldData2 * faderVolume / 127;

Zero works perfectly, and 127 does too, but the volumes close to the bottom of the range are way too loud, especially the louder notes. What might be a different relationship than a linear one (in pseudo-code would be great)? I will have to plug them into the code and try them, of course.

I realize that this question depends on the instrument that is playing the Note Ons (a BFD Kit in Ableton Live, which doesn't inform much), but maybe not and perhaps there's a standard way to adjust a Midi Note On volume with a fader.

+1  A: 

As I said on my comment, when playing with sound or audio or any audible technologies, rather use doubles or floats (depending on the hardware or API specifications).

You are returning an integer on newData2. Rather convert it to a double or float (for precision).

e.g.

float newData2 = (float)oldData2 * (float)faderVolume / (float)127;

Hope this helps.

The Elite Gentleman
Thanks, this seems to help, but I will have to try it out empirically. Just trying out some numbers, the difference is never greater than 1, although it's more than 10% of final note volume in about 15% of all combinations. If this doesn't work, I will need something more curvaceous.
Yar