Skip to content

Commit

Permalink
MIDI: FluidSynth is now configured to load samples dynamically instea…
Browse files Browse the repository at this point in the history
…d of caching entire banks at once
  • Loading branch information
kode54 committed May 9, 2021
1 parent dffe888 commit b2a6a67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Plugins/MIDI/MIDI/SFPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SFPlayer::SFPlayer() : MIDIPlayer()
_synth[1] = 0;
_synth[2] = 0;
uInterpolationMethod = FLUID_INTERP_DEFAULT;
bDynamicLoading = true;

for (unsigned int i = 0; i < 3; ++i)
{
Expand All @@ -26,6 +27,7 @@ SFPlayer::SFPlayer() : MIDIPlayer()
fluid_settings_setnum(_settings[i], "synth.gain", 0.2);
fluid_settings_setnum(_settings[i], "synth.sample-rate", 44100);
fluid_settings_setint(_settings[i], "synth.midi-channels", 16);
fluid_settings_setint(_settings[i], "synth.dynamic-sample-loading", bDynamicLoading ? 1 : 0);
fluid_settings_setint(_settings[i], "synth.device-id", 0x10 + i);
}
}
Expand All @@ -41,12 +43,17 @@ SFPlayer::~SFPlayer()

void SFPlayer::setInterpolationMethod(unsigned method)
{
shutdown();
uInterpolationMethod = method;
for (unsigned int i = 0; i < 3; ++i)
if ( _synth[i] ) fluid_synth_set_interp_method( _synth[i], -1, method );
}

void SFPlayer::setDynamicLoading(bool enabled)
{
shutdown();
bDynamicLoading = enabled;
}

void SFPlayer::send_event(uint32_t b)
{
if (!(b & 0x80000000))
Expand Down Expand Up @@ -157,6 +164,7 @@ bool SFPlayer::startup()
for (unsigned int i = 0; i < 3; ++i)
{
fluid_settings_setnum(_settings[i], "synth.sample-rate", uSampleRate);
fluid_settings_setint(_settings[i], "synth.dynamic-sample-loading", bDynamicLoading ? 1 : 0);
_synth[i] = new_fluid_synth(_settings[i]);
if (!_synth[i])
{
Expand Down
2 changes: 2 additions & 0 deletions Plugins/MIDI/MIDI/SFPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SFPlayer : public MIDIPlayer
void setSoundFont( const char * in );
void setFileSoundFont( const char * in );
void setInterpolationMethod(unsigned method);
void setDynamicLoading(bool enabled);

const char * GetLastError() const;

Expand All @@ -44,6 +45,7 @@ class SFPlayer : public MIDIPlayer
std::string sFileSoundFontName;

unsigned uInterpolationMethod;
bool bDynamicLoading;
};

#endif /* SFPlayer_h */

0 comments on commit b2a6a67

Please sign in to comment.