Gain in dB = (40 * log10(cc7/127)) + (40 * log10(cc11/127))
Reading the formula, it appears to me that even if I have expression set at 0 (no bellows movement), the controller will still play the notes, because volume is >0. Is my understanding correct?
Be aware that the output of the formula is gain in decibels, with a range of −∞ (silence) to 0 (maximum). log₁₀(0) is normally undefined, but is treated as −∞ in this formula. If one or both sides of the addition is −∞ then the output of the entire formula is also −∞.
Here are two places that the volume-and-expression formula appears:
General MIDI 2 Specification
, PDF page 12 (printed page 8):
Gain in dB = (40 * log₁₀(cc7/127)) + (40 * log₁₀(cc11/127))
General MIDI Level 1 Developer Guidelines
PDF page 13 (printed page 9):
L(dB) = 40 log (V/127²) where V = (volume × expression)
Ignoring the differences in variable names, these versions of the formula are mathematically equivalent because of the property log(a) + log(b) = log(ab). More specifically, I'll use the following variable names:
G is the gain in decibels from −∞ (silence) to 0 (maximum).
V is the MIDI volume value from 0 to 127.
E is the MIDI expression value from 0 to 127.
G = (40 × log₁₀(V/127)) + (40 × log₁₀(E/127))
then factoring out the 40 from both sides of the addition
G = 40 × ( log₁₀(V/127) + log₁₀(E/127) )
then using the property log(a) + log(b) = log(ab) gets
G = 40 × log₁₀( (V/127) × (E/127) )
I find this version of the formula easier to understand that if one or both of the velocity V or expression E is 0, then the result will be silence.
As the velocity is constant, shall I just use default 127 for note On, and 0 for note Off?
My understanding is that Note On velocity value mainly controls volume, but can also add other effects. On some MIDI devices, when the Note On velocity is 127 or otherwise very large, the resulting instrument sound might sound harsher or have some other exaggerated emphasis. If you use a constant Note On velocity of 127, you might always hear the harsher version of the instrument sound.
So if you want to be able to use various MIDI devices to generate the instrument sound, you may want to avoid a constant Note On velocity of 127, in case it causes an unwanted change in the instrument sound. When I make MIDI files, I usually use a Note On velocity of 100 as a default value.
On the other hand, if you know you are only going to use a specific MIDI device to make the instrument sound, you can test if Note On velocity 127 sounds okay to you and decide to use that if you want.
By the way, my understanding is the Note On velocity will combine the same way into the formula...
Y is the Note On velocity from 1 to 127
G = (40 × log₁₀(V/127)) + (40 × log₁₀(E/127)) + (40 × log₁₀(Y/127))
G = 40 × log₁₀( (V/127) × (E/127) × (Y/127) )
My understanding is Note Off velocity is rarely used by MIDI devices for anything. When I make MIDI files, I usually end notes with a Note On with velocity 0, or sometimes with a Note Off with velocity 0.
I am aware that there is a MIDI Master Volume Universal SysEx message that sets volume for all channels, but I cannot find how this variable is used in conjunction with the others (cc7 and cc11).
I believe the MIDI Master Volume value would combine in the same way...
M is the MIDI Master Volume value from 0 to 16383
G = (40 × log₁₀(M/16383)) + (40 × log₁₀(V/127)) + (40 × log₁₀(E/127)) + (40 × log₁₀(Y/127))
G = 40 × log₁₀( (M/16383) × (V/127) × (E/127) × (Y/127) )
...but I don't use the MIDI Master Volume System Exclusive message when I make MIDI files, so I have no experience with how consistently it behaves on various MIDI devices.