Host information from Reaper? buffer.getNumSamples() returns 0?

I’m designing a VST3 midi effect that involves delaying when midi notes are triggered. Previously, I had been using the AudioPluginHost to debug it, but I’ve switched to Reaper because I have read that AudioPluginHost does not supply a playhead or other host information I need to debug, and that my version of Ableton does not support VST3 Midi Effects.

The beginning of my processBlock code looks like this:

void ProbCurvAudioProcessor::processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) { //audio buffer in a midi effect will have zero channels jassert(buffer.getNumChannels() == 0);
//buffer.clear();
int time;
MidiMessage m;

//keep a running list of which notes are included in the notebank
for (MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);) {
    if (m.isNoteOn()) {
        midiProcessor.addToNotebank(m);
    }
    else if (m.isNoteOff()) {
        midiProcessor.removeFromNotebank(m);
    }
}

int numSamples = buffer.getNumSamples();
int nextNoteDur = midiProcessor.popPulsebank();

int offset = 0;

when getNumSamples() is called, numSamples is set to 0, and my VST never sends any midi output because it appears that no time is elapsing to my processBlock thread. How do I get buffersize in code?

getNumSamples() will return 0 unless you have at least an Audio Input declared for your MIDI plugin. Many threads here on this. Even if you don’t use the Audio Input, you need to have one.

2 Likes

that worked, thx! numsamps now returns correctly