make sample rate changeable, probably
This commit is contained in:
parent
a82e7e450b
commit
b5a807fe91
@ -12,6 +12,7 @@ FluidSynthModel::FluidSynthModel(SharesParams& p)
|
||||
synth(nullptr),
|
||||
settings(nullptr),
|
||||
currentSoundFontAbsPath(),
|
||||
currentSampleRate(44100),
|
||||
initialised(false),
|
||||
sfont_id(0),
|
||||
channel(0)
|
||||
@ -38,6 +39,7 @@ void FluidSynthModel::initialise() {
|
||||
fluid_settings_setstr(settings, "synth.verbose", "yes");
|
||||
|
||||
synth = new_fluid_synth(settings);
|
||||
fluid_synth_set_sample_rate(synth, currentSampleRate);
|
||||
|
||||
if (sharesParams.getSoundFontPath().isNotEmpty()) {
|
||||
loadFont(sharesParams.getSoundFontPath());
|
||||
@ -202,4 +204,13 @@ void FluidSynthModel::addListener (FluidSynthModel::Listener* const newListener)
|
||||
void FluidSynthModel::removeListener (FluidSynthModel::Listener* const listener)
|
||||
{
|
||||
eventListeners.remove(listener);
|
||||
}
|
||||
|
||||
void FluidSynthModel::setSampleRate(float sampleRate) {
|
||||
currentSampleRate = sampleRate;
|
||||
if (!initialised) {
|
||||
// don't worry; we'll do this in initialise phase regardless
|
||||
return;
|
||||
}
|
||||
fluid_synth_set_sample_rate(synth, sampleRate);
|
||||
}
|
@ -59,6 +59,8 @@ public:
|
||||
*/
|
||||
void removeListener (Listener* listener);
|
||||
|
||||
void setSampleRate(float sampleRate);
|
||||
|
||||
const String& getCurrentSoundFontAbsPath();
|
||||
|
||||
private:
|
||||
@ -70,6 +72,8 @@ private:
|
||||
|
||||
String currentSoundFontAbsPath;
|
||||
|
||||
float currentSampleRate;
|
||||
|
||||
const fluid_preset_t getFirstPreset();
|
||||
void selectFirstPreset();
|
||||
unique_ptr<BankAndPreset> getFirstBankAndPreset();
|
||||
|
@ -111,6 +111,7 @@ void JuicySFAudioProcessor::prepareToPlay (double sampleRate, int /*samplesPerBl
|
||||
// initialisation that you need..
|
||||
synth.setCurrentPlaybackSampleRate (sampleRate);
|
||||
keyboardState.reset();
|
||||
fluidSynthModel.setSampleRate(static_cast<float>(sampleRate));
|
||||
|
||||
reset();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user