diff --git a/src/processors/chain/ProcessorChain.cpp b/src/processors/chain/ProcessorChain.cpp index 99fc3201..7fdb0255 100644 --- a/src/processors/chain/ProcessorChain.cpp +++ b/src/processors/chain/ProcessorChain.cpp @@ -69,9 +69,7 @@ void ProcessorChain::initializeProcessors() for (int i = procs.size() - 1; i >= 0; --i) { if (auto* proc = procs[i]) - { proc->prepareProcessing (osSampleRate, osSamplesPerBlock); - } } } diff --git a/src/processors/other/Delay.cpp b/src/processors/other/Delay.cpp index cd7088c9..1c249d1b 100644 --- a/src/processors/other/Delay.cpp +++ b/src/processors/other/Delay.cpp @@ -4,6 +4,7 @@ #include "processors/PlayheadHelpers.h" using namespace chowdsp::RhythmUtils; +//using namespace chowdsp::RhythmParameter; namespace { @@ -25,7 +26,7 @@ DelayModule::DelayModule (UndoManager* um) : BaseProcessor ("Delay", createParam loadParameterPointer (feedbackParam, vts, feedBackTag); loadParameterPointer (mixParam, vts, mixTag); loadParameterPointer (delayTimeMsParam, vts, delayTimeMsTag); - delayTimeTempoSyncParam = vts.getRawParameterValue (tempoSyncAmountTag); + loadParameterPointer (delayTimeRhythmParam, vts, tempoSyncAmountTag); tempoSyncOnOffParam = vts.getRawParameterValue (tempoSyncTag); delayTypeParam = vts.getRawParameterValue (delayTypeTag); pingPongParam = vts.getRawParameterValue (pingPongTag); @@ -50,11 +51,11 @@ ParamLayout DelayModule::createParameterLayout() createPercentParameter (params, feedBackTag, "Feedback", 0.0f); createPercentParameter (params, mixTag, "Mix", 0.5f); - emplace_param (params, - tempoSyncAmountTag, - "Tempo Sync Delay", - StringArray { "1/2", "1/4", "1/8", "1/8 dotted" }, - 0); + emplace_param( params, + tempoSyncAmountTag, + "Delay Rhythm", + std::initializer_list{HALF, QUARTER, EIGHTH, EIGHTH_DOT}, + HALF ); emplace_param (params, tempoSyncTag, "Tempo Sync", false); emplace_param (params, delayTypeTag, "Delay Type", StringArray { "Clean", "Lo-Fi" }, 0); emplace_param (params, pingPongTag, "Ping-Pong", false); @@ -238,30 +239,30 @@ void DelayModule::processAudio (AudioBuffer& buffer) { feedbackSmoothBuffer.process (std::pow (feedbackParam->getCurrentValue() * 0.67f, 0.9f), buffer.getNumSamples()); double tempo = playheadHelpers->bpm.load(); - auto tempoSync = (int) *tempoSyncOnOffParam; - if (! tempoSync) + const auto tempoSync = *tempoSyncOnOffParam == 1.0f; + if (!tempoSync) { delaySmooth.setTargetValue (fs * *delayTimeMsParam * 0.001f); } else { float delayInSamples = fs * 200 * 0.001f; - auto noteDivision = (int) *delayTimeTempoSyncParam; + auto noteDivision = (int)*delayTimeRhythmParam; if (noteDivision == 0) { - delayInSamples = calculateTempoSyncDelayTime (HALF.getTimeSeconds (tempo), fs); + delayInSamples = calculateTempoSyncDelayTime(HALF.getTimeSeconds(tempo), fs); } else if (noteDivision == 1) { - delayInSamples = calculateTempoSyncDelayTime (QUARTER.getTimeSeconds (tempo), fs); + delayInSamples = calculateTempoSyncDelayTime(QUARTER.getTimeSeconds(tempo), fs); } else if (noteDivision == 2) { - delayInSamples = calculateTempoSyncDelayTime (EIGHTH.getTimeSeconds (tempo), fs); + delayInSamples = calculateTempoSyncDelayTime (EIGHTH.getTimeSeconds(tempo), fs); } else if (noteDivision == 3) { - delayInSamples = calculateTempoSyncDelayTime (EIGHTH_DOT.getTimeSeconds (tempo), fs); + delayInSamples = calculateTempoSyncDelayTime (EIGHTH_DOT.getTimeSeconds(tempo), fs); } delaySmooth.setTargetValue (delayInSamples); } @@ -308,7 +309,7 @@ void DelayModule::processAudioBypassed (AudioBuffer& buffer) outputBuffers.getReference (0) = &buffer; } -float DelayModule::calculateTempoSyncDelayTime (const double timeInSeconds, const double sampleRate) const +float DelayModule::calculateTempoSyncDelayTime(const double timeInSeconds, const double sampleRate) { return static_cast (timeInSeconds * sampleRate); } @@ -323,7 +324,7 @@ bool DelayModule::getCustomComponents (OwnedArray& customComps, chowd : vts (vtState), tempoSyncSelectorAttach (vts, tempoSyncAmountTag, tempoSyncSelector), delayTimeSlider (*getParameterPointer (vts, delayTimeMsTag), hcp), - delayTimeAttach (vts, delayTimeMsTag, delayTimeSlider), + delayTimeAttach(vts, delayTimeMsTag, delayTimeSlider), tempoSyncOnOffAttach ( *vts.getParameter (tempoSyncTag), [this] (float newValue) @@ -333,7 +334,7 @@ bool DelayModule::getCustomComponents (OwnedArray& customComps, chowd addChildComponent (tempoSyncSelector); addChildComponent (delayTimeSlider); - const auto* modeChoiceParam = getParameterPointer (vts, tempoSyncAmountTag); + const auto* modeChoiceParam = getParameterPointer (vts, tempoSyncAmountTag); tempoSyncSelector.addItemList (modeChoiceParam->choices, 1); tempoSyncSelector.setSelectedItemIndex (0); tempoSyncSelector.setScrollWheelEnabled (true); @@ -366,7 +367,7 @@ bool DelayModule::getCustomComponents (OwnedArray& customComps, chowd void updateControlVisibility (bool tempoSyncOn) { tempoSyncSelector.setVisible (tempoSyncOn); - delayTimeSlider.setVisible (! tempoSyncOn); + delayTimeSlider.setVisible (!tempoSyncOn); setName (vts.getParameter (tempoSyncOn ? tempoSyncAmountTag : delayTimeMsTag)->name); if (auto* parent = getParentComponent()) @@ -384,10 +385,10 @@ bool DelayModule::getCustomComponents (OwnedArray& customComps, chowd delayTimeSlider.setTextBoxStyle (getTextBoxPosition(), false, getTextBoxWidth(), getTextBoxHeight()); const auto bounds = getLocalBounds(); - tempoSyncSelector.setBounds (bounds.proportionOfWidth (0.15f), - bounds.proportionOfHeight (0.1f), - bounds.proportionOfWidth (0.7f), - bounds.proportionOfHeight (0.25f)); + tempoSyncSelector.setBounds (bounds.proportionOfWidth(0.15f), + bounds.proportionOfHeight(0.1f), + bounds.proportionOfWidth(0.7f), + bounds.proportionOfHeight(0.25f)); delayTimeSlider.setBounds (bounds); } @@ -410,5 +411,5 @@ bool DelayModule::getCustomComponents (OwnedArray& customComps, chowd customComps.add (std::make_unique (vts, hcp)); - return false; + return true; } \ No newline at end of file diff --git a/src/processors/other/Delay.h b/src/processors/other/Delay.h index b6843d70..b007f225 100644 --- a/src/processors/other/Delay.h +++ b/src/processors/other/Delay.h @@ -1,7 +1,6 @@ #pragma once #include "../BaseProcessor.h" -#include "processors/PlayheadHelpers.h" class DelayModule : public BaseProcessor { @@ -16,7 +15,7 @@ class DelayModule : public BaseProcessor void releaseMemory() override; void processAudio (AudioBuffer& buffer) override; void processAudioBypassed (AudioBuffer& buffer) override; - float calculateTempoSyncDelayTime (const double timeInSeconds, const double sampleRate) const; + static float calculateTempoSyncDelayTime(const double timeInSeconds, const double sampleRate); private: template @@ -24,17 +23,6 @@ class DelayModule : public BaseProcessor template void processPingPongDelay (AudioBuffer& buffer, DelayType& delayLine); - struct SimpleAudioPlayHead : juce::AudioPlayHead - { - juce::Optional getPosition() const override - { - PositionInfo info; - return info; - } - }; - - SimpleAudioPlayHead audioPlayHead; - chowdsp::FloatParameter* freqParam = nullptr; chowdsp::FloatParameter* feedbackParam = nullptr; chowdsp::FloatParameter* mixParam = nullptr; @@ -42,7 +30,7 @@ class DelayModule : public BaseProcessor std::atomic* pingPongParam = nullptr; chowdsp::FloatParameter* delayTimeMsParam = nullptr; - std::atomic* delayTimeTempoSyncParam = nullptr; + chowdsp::RhythmParameter* delayTimeRhythmParam = nullptr; std::atomic* tempoSyncOnOffParam = nullptr; dsp::DryWetMixer dryWetMixer;