SynthesiserVoice Delay?

#1

So my end goal is to have a synth that can have its output delayed with a slider and I did the actual implementation of the circular buffer in the processBlock of my pluginProcessor however my synthesizerVoice sound still plays the same when I manipulate the delayTime to any value in the getFromDelay() method, can someone point me in a direction to go for achieving my end goal?

auto totalNumInputChannels  = getTotalNumInputChannels();
    auto totalNumOutputChannels = getTotalNumOutputChannels();
    
    
    for(int i = 0; i < magicSynth.getNumVoices(); i++){
        if(magicVoice = dynamic_cast<SynthesizerVoice*>(magicSynth.getVoice(i))){
            
            magicVoice->getEnvelopeParams(tree.getRawParameterValue("attack"), tree.getRawParameterValue("decay"), tree.getRawParameterValue("sustain"), tree.getRawParameterValue("release"));
            
            magicVoice->getWaveType(tree.getRawParameterValue("waveType"));
            magicVoice->getWaveType2(tree.getRawParameterValue("waveType2"));

            magicVoice->getFilterParams(tree.getRawParameterValue("filterType"),
                            tree.getRawParameterValue("filterCutOff"),
                                        tree.getRawParameterValue("filterRes"));
            
            magicVoice->getMasterParams(tree.getRawParameterValue("masterGain"),
                                    tree.getRawParameterValue("blend"));
        }
    }
    
    buffer.clear();
    
    const int bufferLength = buffer.getNumSamples();
    const int delayBufferLength = mDelayBuffer.getNumSamples();
    
    for (int channel = 0; channel < totalNumInputChannels; ++channel)
    {
        const float* bufferData = buffer.getReadPointer(channel);
        const float* delayBufferData = mDelayBuffer.getReadPointer(channel);
        float* dryBuffer = buffer.getWritePointer(channel);
        
        fillDelayBuffer(channel, bufferLength, delayBufferLength, bufferData, delayBufferData);
        getFromDelayBuffer(buffer, channel, bufferLength, delayBufferLength, bufferData, delayBufferData);
        feedbackDelay(buffer, channel, bufferLength, delayBufferLength, bufferData, delayBufferData, dryBuffer);
        
    }
    
    mWritePosition += bufferLength;
    mWritePosition %= delayBufferLength;

    magicSynth.renderNextBlock(buffer, midiMessages,0, buffer.getNumSamples());
    updateFilter();
    dsp::AudioBlock<float> block (buffer);
    stateVariableFilter.process(dsp::ProcessContextReplacing<float> (block));
    scopeDataCollector.process(buffer.getReadPointer(0), (size_t)buffer.getNumSamples());
}
#2

You’ve hidden the crucial information in some functions (fillDelayBuffer). However, seems to me you are delaying an empty buffer and after that filling it with your voice, should be the other way around.

Btw shouldn’t your Parameter methods be called set… instead of get…?

#3

For the parameter methods, I initially named it get because I interpreted it as getting the value from my synthvoice class, but I am setting the values in the processBlock() so it would make more sense to name it set. I am also still getting the sound returned without the delay effect, here goes my fillDelayBuffer()

void fillDelayBuffer (int channel, const int bufferLength, const int delayBufferLength, const float* bufferData, const float* delayBufferData)
{
    if (delayBufferLength > bufferLength + mWritePosition)
    {
        mDelayBuffer.copyFromWithRamp(channel, mWritePosition, bufferData, bufferLength, 0.1, 0.1);
    }
    else {
        const int bufferRemaining = delayBufferLength - mWritePosition;
        
        mDelayBuffer.copyFromWithRamp(channel, mWritePosition, bufferData, bufferRemaining, 0.1, 0.1);
        mDelayBuffer.copyFromWithRamp(channel, 0, bufferData, bufferLength - bufferRemaining, 0.1, 0.1);
    }
}

here is the fillDelayBuffer method