diff --git a/hi_faust/FaustWrapper.h b/hi_faust/FaustWrapper.h index 2ff8ef9301..5eae620538 100644 --- a/hi_faust/FaustWrapper.h +++ b/hi_faust/FaustWrapper.h @@ -67,7 +67,7 @@ template struct faust_base_wrapper } // std::string code; - int sampleRate; + int sampleRate = 0; // This contains a faust instance for each voice PolyData<::faust::dsp*, NumVoices> faustDsp; @@ -111,9 +111,10 @@ template struct faust_base_wrapper return; if (_nChannels != specs.numChannels || _nFramesMax != specs.blockSize) { - DBG("Faust: Resizing buffers: nChannels=" << _nChannels << ", blockSize=" << _nFramesMax); + _nChannels = specs.numChannels; _nFramesMax = specs.blockSize; + DBG("Faust: Resizing buffers: nChannels=" << _nChannels << ", blockSize=" << _nFramesMax); resizeBuffer(); } @@ -145,6 +146,9 @@ template struct faust_base_wrapper // to encode both input and output channels into a single integer using a magic trick auto encodedChannelCount = 1000 * numInputs + numOutputs; + // Reset the sample rate so that it will be initialised the next prepare() call + sampleRate = 0; + scriptnode::Error::throwError(Error::IllegalFaustChannelCount, numHiseChannels, encodedChannelCount); } }