Comments (11)
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.
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.
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.
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.
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.
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.
Hey, I've got another .sf2 that blows up. ;) I'm sorry!
Turtle Beach Montego II Aureal GM.zip
from tinysoundfont.
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.
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.
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.
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)
- Line 59 of tsf.h HOT 1
- "conversion may change the value [-Werror=conversion]" compilation errors on MCST lcc compiler HOT 2
- Volume curve HOT 2
- this library wrote 3300 seconds of PCM audio in 4.9 seconds. (nice work) HOT 1
- Is it possible to use this library with SDL_mixer?
- How I can stop a note by fading the volume? HOT 2
- How many channels does this support? HOT 2
- white noise unexpected sound when playing the files HOT 2
- Stuck instrument with Windows XP onestop.mid HOT 1
- Incompatibility with ISO C++ HOT 2
- `TSF_MALLOC(...)` without non-NULL check/error handling HOT 3
- Design issue: having playback handling and soundfont in same structure incentivizes people to write memory hogs(?) HOT 3
- `tsf_set_max_voices()` should actually be enforced HOT 2
- Unicode open HOT 1
- Would be possible to sustain a note? HOT 2
- Is .sfz support something devs consider also thank you for the library HOT 6
- voices active for slightly longer than they should be
- Reading samples directly at runtime (port to STM32) HOT 1
- MIDI latency HOT 1
- Likely memory leak in use of TSF_REALLOC in new sf3 code in out of memory conditions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinysoundfont.