Many documents state that the MIDI standard gain is
40 * log10(CC7/127).
So why a factor of 40? What is the theory behind it? What is the nature of gain being addressed in the MIDI standard?
The answer will be important for me, because I am trying to match the volume of MIDI to an OPL4 device which has a logarithmic scale, and using the MIDI formula clearly gives an incorrect volume level for quiet notes. By comparing output produced by the MIDI formula, I clearly hear that Windows Media Player has higher volumes for quieter notes.
Linear volume boost does not help here, making the sound even uglier: making loud notes louder and not much affecting quiet notes.
thank you very much for the answers. It was somewhat hard to choose the best one. Therefore our conclusions are: simplicity in implementation (V * V * sample), covering broader dynamic range (96 dB instead of 48 dB).
My suspicion was actually about breaking the human perception of 20 * log having 40 * log, which has steeper curve. I replaced volume table 20 * log, and it now sounds very similar to other players I tried (including WMP).
Regarding questions asked: OPL4 is my own implementation, designed basing on YMF278B datasheet, therefore I have full access to its internals - here's the outcome of my work heavily using hardware acceleration playing more or less properly on the 3.58 MHz machine.
I suspect that at TL=127 chip must mute the output, however it is not declared in the datasheet, and my implementation does not make this assumption.
If total silence is required immediately, panpot=8 can be used until envelope reaches max 1023 under key off condition with appropriate RR=15.
OPL4 (YMF278B) contains OPL3 implementation, however slightly different than in OPL3 and earlier chips because of running at 49.515 instead of 49.715 kHz.