Mono voice midi crackling sounds


#1

I’m making a mono synth and have a button that will reset the voice, but when I send midi messages I get a lot of crackling sounds what is going on what the difference between the button that is triggering it cleanly and using a midi keyboard that makes it crackle.


#2

I guess I have to go inside the process block like the regular vst sdk rendering messages before with mono is no good


#3

I guess thats what tailoff is for


#4
indent preformatted text by 4 spacesvoid myRenderBlock(AudioBuffer<float>& outputBuffer, MidiBuffer& midiMessages,int startSample, int numSamples)
{
    auto *channelData0 = outputBuffer.getWritePointer(0);
    auto *channelData1 = outputBuffer.getWritePointer(1);
    SineWaveVoice *v = dynamic_cast<SineWaveVoice*>(getVoice(0));
    MidiBuffer processedMidi;
    int time = 0;
    MidiMessage m;
    startSample = 0;
    int size = numSamples;
    //for (MidiBuffer::Iterator i (midiMessages);i.getNextEvent (m, time);)
    //{
    MidiBuffer::Iterator it (midiMessages);
    it.getNextEvent(m,time);
    
    if(m.isNoteOff())
    {
        held = false;
    }
            while(startSample< numSamples)
            {
                if(m.isNoteOn() && !held)
                {
                    v->resetFunc();
                    held = true;
                }

                int index = startSample;
                //processing single voice
            }
            
        //}
       
    
    outputBuffer.applyGain(0, 0, size, v->ampModAmount.getNextValue());
    outputBuffer.applyGain(1, 0, size, v->ampModAmount.getNextValue());
    
    
     midiMessages.swapWith (processedMidi);
}

#5

a little preview