diff --git a/source/Parameters.h b/source/Parameters.h index eba77bc..61801b4 100644 --- a/source/Parameters.h +++ b/source/Parameters.h @@ -11,6 +11,7 @@ class Parameters parameters.push_back(offThreshold); parameters.push_back(waitSamples); parameters.push_back(sensitivity); + parameters.push_back(drywet); } void add(juce::AudioProcessor& processor) const @@ -19,6 +20,7 @@ class Parameters processor.addParameter(offThreshold); processor.addParameter(waitSamples); processor.addParameter(sensitivity); + processor.addParameter(drywet); } // Free parameters -- this is here to support unit testing. @@ -29,15 +31,34 @@ class Parameters delete param; } - // Raw pointers. They will be owned by either the processor or the APVTS (if you use it) + // Raw pointers. + // They will be owned by the AudioProcessor in the application. juce::AudioParameterFloat* onThreshold = - new juce::AudioParameterFloat({ "onThreshold", 1 }, "On Threshold", 0.5f, 32.f, 16.0f); + new juce::AudioParameterFloat({ "onThreshold", 1 }, + "On Threshold", + 0.5f, + 32.f, + 16.0f); juce::AudioParameterFloat* offThreshold = - new juce::AudioParameterFloat({ "offThreshold", 1 }, "Off Threshold", 0.0f, 32.f, 4.66f); + new juce::AudioParameterFloat({ "offThreshold", 1 }, + "Off Threshold", + 0.0f, + 32.f, + 4.66f); juce::AudioParameterInt* waitSamples = - new juce::AudioParameterInt({ "waitSamples", 1 }, "Wait Samples", 0, 5000, 1000); + new juce::AudioParameterInt({ "waitSamples", 1 }, + "Wait Samples", + 0, + 5000, + 1000); juce::AudioParameterFloat* sensitivity = - new juce::AudioParameterFloat({ "sensitivity", 1 }, "Mapping Sensitivity", 0.f, 4.f, 1.0f); + new juce::AudioParameterFloat({ "sensitivity", 1 }, + "Mapping Sensitivity", + 0.f, + 4.f, + 1.0f); + juce::AudioParameterFloat* drywet = + new juce::AudioParameterFloat({ "drywet", 1 }, "Dry/Wet", 0.0f, 1.0f, 1.0f); private: std::vector parameters; diff --git a/source/PluginProcessor.cpp b/source/PluginProcessor.cpp index 8aa2905..40c27a9 100644 --- a/source/PluginProcessor.cpp +++ b/source/PluginProcessor.cpp @@ -27,10 +27,14 @@ void TorchDrumProcessor::processBlock(juce::AudioBuffer& buffer, // Parameters to update once per block auto& onsetDetection = synthController.getOnsetDetection(); - onsetDetection.updateParameters( - parameters.onThreshold->get(), - parameters.offThreshold->get(), - parameters.waitSamples->get()); + onsetDetection.updateParameters(parameters.onThreshold->get(), + parameters.offThreshold->get(), + parameters.waitSamples->get()); + + // Square Root 3dB Dry/Wet Mix + auto drywet = parameters.drywet->get(); + float dry = std::sqrt(1.0f - drywet); + float wet = std::sqrt(drywet); for (int sample = 0; sample < buffer.getNumSamples(); ++sample) { @@ -54,7 +58,7 @@ void TorchDrumProcessor::processBlock(juce::AudioBuffer& buffer, for (int channel = 0; channel < buffer.getNumChannels(); ++channel) { auto* channelData = buffer.getWritePointer(channel); - channelData[sample] = synthSample; + channelData[sample] = synthSample * wet + channelData[sample] * dry; } } } @@ -82,14 +86,14 @@ void TorchDrumProcessor::getStateInformation(juce::MemoryBlock& destData) // Save model path and feature normalizers juce::ValueTree modelPath("ModelPath"); - modelPath.setProperty("Path", juce::String(synthController.getModelPath()), nullptr); + modelPath.setProperty( + "Path", juce::String(synthController.getModelPath()), nullptr); pluginPreset.appendChild(modelPath, nullptr); copyXmlToBinary(*pluginPreset.createXml(), destData); } -void TorchDrumProcessor::setStateInformation(const void* data, - int sizeInBytes) +void TorchDrumProcessor::setStateInformation(const void* data, int sizeInBytes) { // Loads your parameters, and any other potential data from an XML: @@ -102,8 +106,7 @@ void TorchDrumProcessor::setStateInformation(const void* data, for (auto& param : getParameters()) { - auto paramTree = - params.getChildWithName(PluginHelpers::getParamID(param)); + auto paramTree = params.getChildWithName(PluginHelpers::getParamID(param)); if (paramTree.isValid()) param->setValueNotifyingHost(paramTree["Value"]);