Improve Accuracy of LFO Speed SF2 Modulators
The SF2 modulators that control LFO speed have been overhauled to be much more accurate. I closely studied the relationship between the LFOS parameter, BPM, and the resulting LFO speed in the MP2K sound engine on the GBA, and I tried to recreate it in midi and SF2.
There is now a cc115 event on every channel for each tempo change in the track. The purpose of these cc115 events is to allow the LFO to speed up and slow down with the tempo like on a GBA. The value of each cc115 event is the current BPM divided by 4 (The full range of BPM for MP2K songs is 1-510, but this can't fit in the 0-127 range allowed for a midi CC).
Although LFO speed should now be much more accurate, it still will never be perfect. This is because the SF2 modulator system is very restrictive, and it is impossible to recreate the exact curve of LFO speed values from MP2K in SF2. In general, low LFO speed and BPM values will be less accurate, and high values (greater than half of the maximum value) will be more accurate.
The formula for how LFO speed is calculated on GBA is something like this:
In 1-LFOS, it takes around 43 16th note beats for a single cycle of LFO to complete. 43 16th notes is the "base". This base is always divided by the LFOS: at 1 LFOS, the base remains 43; at 2 LFOS, the base is 43 / 2 = 21.5; at 3 LFOS, the base is 43 / 3 = 14 1/3.
The base after being divided by the LFOS will be called C.
C, which is a value in 16th note beats, will be converted into seconds (with milliseconds in the decimal place); this seconds value will be called S.
Thus, the formula is this (pseudo-code):
F(BPM, LFOS){
B = 43
C = B / LFOS
S = (C / 4) * (60 / BPM)
Hertz = 1 / S
return Hertz
}
Hertz is the number of cycles completed in a second. If the hertz is 8, then 8 LFO cycles will be completed in one second. If the hertz is 0.1, then one-tenth of an LFO cycle will be completed in one second (and it will take 10 seconds for a single LFO cycle to complete).