(I've posted this over at the Steinberg Forum, I'm re-posting this here in the hopes that someone may be able to help)
I've written a very basic VST instrument (plain VST SDK 3.7.11) that just periodically outputs a MIDI noteOn event. I'd like to emphasise that the code below is working (beside the behaviour I'm observing)
I have an unused local variable double FOOBAR_1 in the code.
(*) Now to the peculiar behaviour: when I comment the unused local variable FOOBAR_1 (so it is not in the process() function anymore), the VST instrument stops outputting MIDI noteOn events, or at least I'm not receiving any MIDI noteOn events in Cubase.
(I've attached the Xcode debugger to Cubase and in fact see that the lines creating the Vst::Event event; and eventListOutput->addEvent(event); etc. do in fact still get perfectly executed. Just no MIDI noteOn events arriving in the host.)
I'm completely at a loss why this would happen?! Does anybody of you have an idea in what direction I should investigate this or how this could be solved? For reference, I'm using Xcode on an ARM Mac.
Thank you for your help and all the best!
Here's the process() code for reference:
Code: Select all (#)
tresult PLUGIN_API TestProcessor::process (Vst::ProcessData& data)
{
int bufferSize = data.numSamples;
// (!) Why does commenting this unused local variable cause event output to stop working?
double FOOBAR_1 = -1;
// Event input. Does nothing in this example
Vst::IEventList* eventListInput = data.inputEvents;
if (eventListInput) {
int32 numEvent = eventListInput->getEventCount ();
for (int32 i = 0; i < numEvent; i++) {
Vst::Event event;
if (eventListInput->getEvent (i, event) == kResultOk) {
}
}
}
// Event output. Periodically outputs a noteOn event
if (bufferSize > 0) {
if (samplesToNextBeat < bufferSize) {
Vst::IEventList* eventListOutput = data.outputEvents;
if (eventListOutput) {
Vst::Event event;
event.type = Vst::Event::kNoteOnEvent;
event.noteOn.channel = 1;
event.noteOn.pitch = 60;
event.noteOn.tuning = 0.f;
event.noteOn.velocity = 0.75f;
event.noteOn.noteId = 1;
event.sampleOffset = samplesToNextBeat;
eventListOutput->addEvent(event);
}
samplesToNextBeat += 22050;
}
samplesToNextBeat -= bufferSize;
}
// Unchanged project generator example code to output silence on the audio out
// ...
}