| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /*
- ==============================================================================
- CMLSDelay.cpp
- Created: 3 May 2025 5:39:35pm
- Author: Luigi
- ==============================================================================
- */
- #include "CMLSDelay.h"
- CMLSDelay::CMLSDelay() {
- //feedbackRange = new juce::NormalisableRange<float>(MIN_FEEDBACK, MAX_FEEDBACK);
- this->delayLength = 0.0f;
- this->feedback = 0.0f;
- this->amount = 0.0f;
- this->dryWetProp = 0.0f;
- }
- CMLSDelay::~CMLSDelay() {}
- void CMLSDelay::reset() {
- this->delayLine.reset();
- this->mixer.reset();
- }
- void CMLSDelay::prepare(const juce::dsp::ProcessSpec& spec) {
- this->maximumDelaySamples = spec.sampleRate * MAX_DELAY_LENGTH;
- this->delayRange = new juce::NormalisableRange<float>(0, this->maximumDelaySamples);
- this->delayRange
-
- this->delayLine.prepare(spec);
- this->delayLine.setMaximumDelayInSamples(this->maximumDelaySamples);
- this->mixer.prepare(spec);
- this->mixer.setMixingRule(juce::dsp::DryWetMixingRule::linear);
- }
- void CMLSDelay::process(const juce::dsp::ProcessContextReplacing<float>& context) {
- auto audioBlock = context.getOutputBlock();
- auto numChannels = audioBlock.getNumChannels();
- const auto numSamples = audioBlock.getNumSamples();
- this->mixer.pushDrySamples(context.getInputBlock());
- for (int channel = 0; channel < numChannels; ++channel)
- {
- for (int i = 0; i < numSamples; i++)
- {
- this->delayLine.pushSample(channel, context.getInputBlock().getSample(channel, i));
- audioBlock.setSample(
- channel,
- i,
- this->delayLine.popSample(channel, this->delayLength)
- );
- }
- }
- // Adding wet (elaborated) signal
- this->mixer.mixWetSamples(audioBlock);
- }
- void CMLSDelay::setDryWet(float value) {
- this->dryWetProp = value;
- this->mixer.setWetMixProportion(this->dryWetProp);
- }
- void CMLSDelay::setAmount(float value) {
- this->delayLength = this->delayRange->convertFrom0to1(value);
- }
- const float CMLSDelay::getDryWet() {
- return this->dryWetProp;
- }
- const float CMLSDelay::getAmount() {
- return this->amount;
- }
|