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

voices active for slightly longer than they should be #73

Open
magcius opened this issue Feb 8, 2022 · 0 comments
Open

voices active for slightly longer than they should be #73

magcius opened this issue Feb 8, 2022 · 0 comments

Comments

@magcius
Copy link

magcius commented Feb 8, 2022

TinySoundFont/tsf.h

Lines 970 to 971 in e763bd9

// I don't truly understand this; just following what LinuxSampler does.
float mysterySlope = -9.226f / e->samplesUntilNextSegment;

This "mystery slope" has the effect of scaling the slope by a factor of 9.226f, which means that it would hit the X axis sooner than it otherwise would. Why this specific constant was chosen, I'm not too sure, I suspect this is effectively replicating a bug in the original SF2 synths and measured by ear. Effectively, the specified release time duration is scaled down by 9.226f.

This same effect can also be calculated a different way, one which will allow the voice to cut off sooner:

e->samplesUntilNextSegment /= 9.226f;
e->slope = TSF_EXPF(1.0f / e->samplesUntilNextSegment);

This will allow the voice to end a bit earlier, meaning less to render. Whether you can do the same for decay, I'm not sure.

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

1 participant