schellingb / TinySoundFont

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

Set a global panning value #7

Closed frabert closed 6 years ago

frabert commented 6 years ago

Would it be possible to set a global panning value for the player?

schellingb commented 6 years ago

Hi Thanks for the suggestion!

// Adjust global panning values. Mono output will apply the average of both.
//    pan_factor_left: volume gain factor for the left channel
//    pan_factor_right: volume gain factor for the right channel
TSFDEF void tsf_set_panning(tsf* f, float pan_factor_left, float pan_factor_right);

There you go :-) For some nicer panning curve you might want to call it with something like tsf_set_panning(f, sqrt(1.0 - pan), sqrt(pan));.

schellingb commented 6 years ago

Just a quick note here, the latest commit 40d48401892ddcb0a196dbcbea9261b92bfcf3c5 removed this function tsf_set_panning again as the same effect can be achieved with the new tsf_channel_set_pan. You can even just call this with just channel 0 and still use the non-channel variations of note_on and note_off because channel 0 will be used as the default.