Giter VIP home page Giter VIP logo

Comments (11)

schellingb avatar schellingb commented on May 30, 2024 4

Ok, so there were some more values out of range which needed clamping.
Soundfont regions are summed up from global zone, preset zone and instrument zone, so it's easy to end up with values outside of the range (either intended or unintended).
So now we're clamping all values to the range according to the SF2 spec. And we even made the output binary 1K smaller. Magic!
I think this is what Fluidsynth is doing as well. Their code is unreadable though so I'm not exactly sure.
Looking forward to your listening results :-)
Thanks again.

from tinysoundfont.

schellingb avatar schellingb commented on May 30, 2024 4

Happy to hear!
When making this last update, I added a printf to the places where we're now clamping values and for some sf2 files it's quite a lot. Most of the clamps are only minor adjustments but I think TinySoundFont made a huge compatibility step with this.
Good thing that the initial fix wasn't enough :-)

from tinysoundfont.

schellingb avatar schellingb commented on May 30, 2024 1

Looking at the SF2 file some more, I realize that "Turtle Beach Montego II Aureal GM" uses custom modulators. For instance "Sawtooth Lead" instruments use a modulator which influences the attenuation (volume) depending on the pressed note key. Modulators are not supported by TSF and I have no plans of implementing them as their specs are quite big.

from tinysoundfont.

schellingb avatar schellingb commented on May 30, 2024

Hi again

So this soundfont sets an attenuation value of -997.5 while the value should be between 0 and 1440. The fix I committed clamps the value which makes it play nice.
Hopefully that was all that was wrong, it sounds ok to me.
Now, TSF only clamps a few of the incoming values to their legal ranges. It probably should have a full table of min and max values for all generators and have a generic way of limiting them all instead of just special handling like the one I added now. Hopefully that can be added in the future :-)

Thanks again for testing and reporting.

from tinysoundfont.

TerminX avatar TerminX commented on May 30, 2024

Well, it's improved, but still broken... you have to listen to about the halfway point before things really screw up, though. The commit you made does make the hack we had to clamp region->attenuation in tsf_note_on() unnecessary, but we're still needing to clamp the sustain value in tsf_region_envtosecs() to get the file to play correctly.

Do you think that maybe the .sf2 is out of spec in this way as well, or maybe stuff like FluidSynth uses out of range values in these fields in some way as extensions to the format? The file does work in applications using FluidSynth but I don't know if that's because the values indicate something or if it's just clamping the ranges upon load and whoever created the .sf2 made some mistakes.

from tinysoundfont.

TerminX avatar TerminX commented on May 30, 2024

That seems to have fixed the problem! Actually, I think most of the .sf2 files I've been testing with sound better now in ways that are hard to describe, even stuff like old 4MB Creative banks. It really seems like a marked improvement. Thank you so much for the quick fixes.

from tinysoundfont.

TerminX avatar TerminX commented on May 30, 2024

Hey, I've got another .sf2 that blows up. ;) I'm sorry!
Turtle Beach Montego II Aureal GM.zip

from tinysoundfont.

schellingb avatar schellingb commented on May 30, 2024

Mmh, that was embarrassing... thanks for pointing that out!
I assume many presets of many soundfonts were quite broken because of the failed "optimization" I sneaked into that previous commit.

With that fixed, I still feel like the fourth channel (Sawtooth Lead) is a bit loud, especially after the 35s mark. At least compared to the output of XMPlay's xmp-midi which sounds nicer to me (softer sawtooth lead). The calculation of midi channel volumes was always a bit of a mystery to me so I'm not sure if it's a problem with midi volume or with the soundfont parsing/rendering.

from tinysoundfont.

TerminX avatar TerminX commented on May 30, 2024

It does sound a bit loud. Say, have you ever seen this post: https://musescore.org/en/node/71881 ? It could be relevant here.

from tinysoundfont.

schellingb avatar schellingb commented on May 30, 2024

That post might seem relevant, not sure. Sadly the sample prepared by that poster are not for download anymore (the link somehow contains something different now).
I think what I would like to do, is to generate a midi that plays either a single note or a chord of that Sawtooth Lead preset at a velocity 80 (like in GRABBAG.MID at the 34 second mark).
Then we could render out test WAVs from Fluidsynth/BassMidi(XMPlay)/TSF of both the MIDI and directly playing the note (without going through MIDI) to find out if the problem is in the handling of MIDI volume/expression or if it is an issue how the SF2 itself is parsed. And go from there.

from tinysoundfont.

StrikerMan780 avatar StrikerMan780 commented on May 30, 2024

I wonder if it's possible to at least implement some of the modulator effects/opcodes used by the most commonly used soundfonts? Arachno comes to mind.

from tinysoundfont.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.