I am creating my parameters in the processor’s constructor. As far as I was aware this is the right approach. I’ve posted the relevant construction code below.
Constructor:
BeatboxVoxAudioProcessor::BeatboxVoxAudioProcessor()
: classifier(256, 48000, 2)
{
usingOSDTestSound.store(false);
setupParameters();
initialiseSynth();
}
Then my setupParameters function:
void BeatboxVoxAudioProcessor::setupParameters()
{
processorUndoManager = std::make_unique<UndoManager>();
processorState = std::make_unique<AudioProcessorValueTreeState>(*this, processorUndoManager.get());
processorState->createAndAddParameter(paramOSDNoiseRatio,
"OSD Noise Ratio",
"",
NormalisableRange<float> (0.01, 1.0, 0.01),
0.05,
nullptr,
nullptr);
processorState->addParameterListener(paramOSDNoiseRatio, this);
processorState->createAndAddParameter(paramOSDMeanCoeff,
"OSD Mean Coefficient",
"",
NormalisableRange<float> (0.01, 1.0, 0.01),
1.0,
nullptr,
nullptr);
processorState->addParameterListener(paramOSDMeanCoeff, this);
processorState->createAndAddParameter(paramOSDMedianCoeff,
"OSD Median Coefficient",
"",
NormalisableRange<float> (0.01, 1.0, 0.01),
1.0,
nullptr,
nullptr);
processorState->addParameterListener(paramOSDMedianCoeff, this);
processorState->createAndAddParameter(paramOSDMsBetweenOnsets,
"OSD Ms Between Onsets",
"ms",
NormalisableRange<float> (0.0, 50.0, 5.0),
20.0,
nullptr,
nullptr);
processorState->addParameterListener(paramOSDMsBetweenOnsets, this);
processorState->state = ValueTree (Identifier ("Beatbox Vox"));
auto onsetDetectMeanCallback = [this] (float newMeanCoeff) { this->classifier.setOnsetDetectorMeanCoeff(newMeanCoeff); };
auto onsetDetectMedianCallback = [this] (float newMedianCoeff) { this->classifier.setOnsetDetectorMedianCoeff(newMedianCoeff); };
auto onsetDetectNoiseCallback = [this] (float newNoiseRatio) { this->classifier.setOnsetDetectorNoiseRatio(newNoiseRatio); };
auto onsetDetectMsBetweenCallback = [this] (float newMsBetweenOnsets) { this->classifier.setOSDMsBetweenOnsets(newMsBetweenOnsets); };
paramCallbacks.insert(std::make_pair(paramOSDMeanCoeff, onsetDetectMeanCallback));
paramCallbacks.insert(std::make_pair(paramOSDMedianCoeff, onsetDetectMedianCallback));
paramCallbacks.insert(std::make_pair(paramOSDNoiseRatio, onsetDetectNoiseCallback));
paramCallbacks.insert(std::make_pair(paramOSDMsBetweenOnsets, onsetDetectMsBetweenCallback));
}
Am I making some kind of school boy error here ?
Thanks Tom
EDIT: There is no suspicious looking code in the processBlock or anything daft but I am missing something in regards to which thread may be calling this constructor ?