Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sample attenuation levels are not "correct" #96

Open
mrbumpy409 opened this issue Oct 14, 2024 · 1 comment
Open

sample attenuation levels are not "correct" #96

mrbumpy409 opened this issue Oct 14, 2024 · 1 comment

Comments

@mrbumpy409
Copy link

When Creative Labs/E-MU implemented SoundFont support into their hardware, there were a few limitations and deviations from the official spec. In a few cases, these deviations should be emulated in order correct playback of existing SoundFonts. One such deviation involves the handling of instrument and preset level attenuation values. For compatibility with existing SoundFonts, each 1 dB specified in this manner should only attenuate the sound by 0.4 dB.

Here is the documentation for Test 11 in the SoundFont Spec Implementation Test, which checks for this compatibility:

Test #11: Attenuation amount

Each 1 dB of attenuation set at the instrument or preset level should only attenuate the sound by 0.4 dB. This is a quirk of the Sound Blaster hardware that should be emulated for compatibility with existing SoundFonts. Recent versions of Polyphone translate this value in the editor so you can see the actual attenuation amount.

For this test, you will hear a series of tones getting progressively quieter, based on the table below:

dB in SoundFont actual dB attenuated
0 0
5 2
10 4
15 6
20 8
25 10
30 12

When measured, the volume decrease between each tone should be exactly 2 dB.

Here is a screenshot from Audacity showing the test results, comparing TinySoundFont (top) and FluidSynth (bottom):

image

You can see that TinySoundFont is applying too much attenuation compared to FluidSynth (and Sound Blaster, BASSMIDI, etc.). This often leads to preset levels being badly balanced against one another, and some samples within an instrument being too loud or too soft.

@alessandropetrolati
Copy link

        // Special case because of an extra coeff 0.4 (historical error)

#define DB_SF2_TO_REAL_DB 0.4f

        voice->noteGainDB = region->attenuation * DB_SF2_TO_REAL_DB;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants