From 21caa98fd8b1c53f08f907ec65263f38b9191d2a Mon Sep 17 00:00:00 2001 From: Alex Birch Date: Tue, 30 Jul 2019 21:52:44 +0100 Subject: [PATCH] guess we shouldn't take the easy route of defaulting to 0, since the other parts of fluidsynthmodel are diligent enough to grab their initial values from the value tree (even if it's all-but-certain that the value tree won't have been inited yet) --- Source/FluidSynthModel.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/FluidSynthModel.cpp b/Source/FluidSynthModel.cpp index 9bde407..e04845e 100644 --- a/Source/FluidSynthModel.cpp +++ b/Source/FluidSynthModel.cpp @@ -82,11 +82,23 @@ void FluidSynthModel::initialise() { fluid_synth_set_gain(synth.get(), 2.0); // note: fluid_chan.c#fluid_channel_init_ctrl() - // all SOUND_CTRL are inited with value of 64, not zero. - // "Just like panning, a value of 64 indicates no change for sound ctrls" - // and yet, I'm finding that default modulators start at MIN, so we are forced to start at 0 and climb from there - for (const auto &[controller, param]: controllerToParam) { - setControllerValue(static_cast(controller), 0); + // > Just like panning, a value of 64 indicates no change for sound ctrls + // -- + // so, advice is to leave everything at 64 + // and yet, I'm finding that default modulators start at MIN, + // i.e. we are forced to start at 0 and climb from there + // -- + // let's loop through all audio params that we manage, + // restore them to whatever value we have stored for them + // (which by default would be 0) + // super likely to be 0 regardless, since JuicySFAudioProcessor::initialise() + // runs earlier than JuicySFAudioProcessor::setStateInformation() + for (const auto &[controller, parameterID]: controllerToParam) { + RangedAudioParameter *param{valueTreeState.getParameter(parameterID)}; + jassert(dynamic_cast(param) != nullptr); + AudioParameterInt* castParam{dynamic_cast(param)}; + int value{castParam->get()}; + setControllerValue(static_cast(controller), value); } // http://www.synthfont.com/SoundFont_NRPNs.PDF