schellingb / TinySoundFont

SoundFont2 synthesizer library in a single C/C++ file
MIT License
608 stars 71 forks source link

Sustain and release issue #43

Open acoto87 opened 4 years ago

acoto87 commented 4 years ago

If I call tsf_channel_note_on(soundFont, channel, key, 0); internally the library call tsf_note_off(f, preset_index, key); which causes the notes for the channel to go off, but applying sustain (some kind of fading out I think).

I'm using that first call as a way to mute the music of my game, is there any way the sustain and release doesn't get applied? Or should I approach the muting of the music in another way?

I also have this problem when I change the music, say Music 1 is playing and the I as a player change it to Music 2, you can hear the fading out of Music 1 while the Music 2 starts to play.

Am I doing something wrong, using the library wrong or something?

tobybear commented 4 years ago

Maybe these make the difference: TSFDEF void tsf_channel_note_off_all(tsf f, int channel); //end with sustain and release TSFDEF void tsf_channel_sounds_off_all(tsf f, int channel); //end immediatly

acoto87 commented 4 years ago

Yeah, tsf_channel_sounds_off_all internally call tsf_voice_endquick which is what I would want in this case when I call tsf_channel_note_on(soundFont, channel, key, 0);. Maybe I'm not suppose to use 0 volume as a mean to mute a sound and instead I need to call some variant of tsf_channel_note_off_all or tsf_channel_sounds_off_all.

Thanks for the response :)