Question

[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.

Was it helpful?

Solution

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.

OTHER TIPS

Your equation is correct. You are figuring up the note-on velocity relative to the fader in a linear fashion. A couple notes...

The parameter you are adjusting is velocity. This does not necessarily mean volume! The two do have a correlation for most synths (including your drum kit in Ableton) but it might not be as volume related as you might think.

0-velocity is equivalent to note-off and will never play a sound. I say this because if the difference between 0 and 1 is signficant, itmight be that volume isn't affect as much by the velocity parameter as you might think.

Finally, traditional mixer faders use logarithmic law. You might experiment with this, but again I think you are barking up the wrong tree with volume.

There is a MIDI message for channel volume that you should use for volume, and that is CC 7.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top