rendered paste bodyvoid VstPlugin::processReplacing(float** inputs, float** outputs, VstInt32 sampleFrames)
{
float* output = outputs[0];
int i = sampleFrames;
unsigned int timeToProcess;
unsigned int timeStamp = this->timeStamp;
bufferInit(output, 0.0f, sampleFrames);
Event* e = this->eventQueue;
while(i) {
if((this->eventQueue == NULL) || (e->time >= (this->timeStamp + i))) {
goto processRemainder;
}
timeToProcess = e->time - this->timeStamp;
this->timeStamp += timeToProcess;
i -= timeToProcess;
processVoices(output, timeToProcess);
switch(e->type) {
case kNoteOnEvent:
NoteOnEvent* ee = (NoteOnEvent*) e;
// TODO: do something other than crash when no more voices
Voice* v = this->freeVoices;
this->freeVoices = v->next;
v->next = this->usedVoices;
this->usedVoices = v;
v->noteOn(ee->midiNote, ee->velocity);
this->noteVoiceMap[ee->midiNote] = v;
break;
case kNoteOffEvent:
NoteOffEvent* ee = (NoteOffEvent*) e;
Voice* v = this->noteVoiceMap[ee->midiNote];
v->noteOff();
break;
default:
break;
}
this->eventQueue = e->next;
e->next = this->freeEvents;
this->freeEvents = e;
e = this->eventQueue;
}
processRemainder:
processVoices(output, i);
bufferScale(outputs[0], 0.5, sampleFrames);
}