davy7125/polyphone

use of filter Q should incur sample attenuation

mrbumpy409 opened this issue · 2 comments

In section 9.1.3 of the SoundFont spec, regarding the filter resonance (Q): "The resonance is measured as a dB ratio of the resonant peak to the DC gain. The DC gain at any resonance is half of the resonance value below the DC gain at zero resonance; hence the peak height is half the resonance value above DC gain at zero resonance."

Basically this means that setting a sample to 6 dB filter resonance should result in 3 dB of attenuation. Setting it to 8 dB should result in 4 dB attenuation, etc., and this is how other SoundFont synths (e.g., FluidSynth, BASSMIDI, Audigy) behave.

Polyphone is not doing this, which can lead to some huge differences in playback between Polyphone and other SoundFont synths.

Here is a SoundFont for testing this. In preset 0, MIDI notes 60-71 play a sine wave with the filter cutoff set well above the frequency of the sine wave. Each note from 61 through 71 increases the filter resonance, though since the filter cutoff value is so high, no emphasis will be heard. However, the attenuation that accompanies the filter emphasis increase should be easily measurable.

Here is a table of each MIDI note in the test, its amount of filter emphasis, and the expected attenuation amount:

Note# Emphasis Expected Attenuation
60 0 dB 0 dB
61 5 dB 2.5 dB
62 10 dB 5 dB
63 15 dB 7.5 dB
64 20 dB 10 dB
65 25 dB 12.5 dB
66 30 dB 15 dB
67 35 dB 17.5 dB
68 40 dB 20 dB
69 50 dB 25 dB
70 70 dB 35 dB
71 96 dB 48 dB

Result

All of the MIDI notes sound at the same volume in Polyphone.

Expected Result

The MIDI notes should sound with the expected attenuation values from the table above.

Thank you for this finding

Thank you for this finding

Thank you for the fix! I just tested, and everything is working as expected. 😄