From 183fdbfe09a381906bacf4abfff3f9974c30a039 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 5 Mar 2011 17:45:19 -0800 Subject: [PATCH] Load the default MIDI soundfont only when one isn't set by the app --- src/codec_fluidsynth.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/codec_fluidsynth.cpp b/src/codec_fluidsynth.cpp index c9b9c4d..38f425b 100644 --- a/src/codec_fluidsynth.cpp +++ b/src/codec_fluidsynth.cpp @@ -148,6 +148,7 @@ private: fluid_settings_t *fluidSettings; fluid_synth_t *fluidSynth; int fontID; + bool doFontLoad; public: static void Init() @@ -204,6 +205,14 @@ public: { ALuint ret; + if(doFontLoad) + { + doFontLoad = false; + const char *soundfont = getenv("FLUID_SOUNDFONT"); + if(soundfont && soundfont[0]) + fontID = pfluid_synth_sfload(fluidSynth, soundfont, true); + } + if(format == AL_FORMAT_STEREO16) { ALshort *ptr = reinterpret_cast(data); @@ -320,6 +329,7 @@ public: if(fontID != FLUID_FAILED) pfluid_synth_sfunload(fluidSynth, fontID, true); fontID = newid; + doFontLoad = false; return true; } @@ -327,7 +337,8 @@ public: fluidStream(std::istream *_fstream) : alureStream(_fstream), Divisions(100), format(AL_NONE), sampleRate(48000), samplesPerTick(1.), - fluidSettings(NULL), fluidSynth(NULL), fontID(FLUID_FAILED) + fluidSettings(NULL), fluidSynth(NULL), fontID(FLUID_FAILED), + doFontLoad(true) { if(!fsynth_handle) return; @@ -617,12 +628,6 @@ private: pfluid_settings_setnum(fluidSettings, "synth.sample-rate", (double)sampleRate); fluidSynth = pnew_fluid_synth(fluidSettings); - if(fluidSynth) - { - const char *soundfont = getenv("FLUID_SOUNDFONT"); - if(soundfont && soundfont[0]) - fontID = pfluid_synth_sfload(fluidSynth, soundfont, true); - } } } }; -- 2.11.4.GIT