moved midi around

This commit is contained in:
Gordon JC Pearce 2024-09-05 14:30:16 +01:00
parent fa30594239
commit 9f6525c918
2 changed files with 19 additions and 12 deletions

View File

@ -133,11 +133,23 @@ void Chassis::noteOff(uint8_t note) {
}
}
void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEvent *MidiEvents, uint32_t midiEventCount) {
void Chassis::doMidi(const MidiEvent *ev, uint32_t count, uint32_t timelimit ) {
for (uint32_t i = 0; i < count; i++) {
if (ev[i].data[0] == 0x90) {
noteOn(ev[i].data[1]);
}
if (ev[i].data[0] == 0x80) {
noteOff(ev[i].data[1]);
}
}
}
void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEvent *midiEvents, uint32_t midiEventCount) {
// if (midiEventCount > 0) printf("\n--------------------\n");
if (s.framesLeft == 0) s.framesLeft = frames;
s.framesLeft = frames;
while ( s.framesLeft != 0) {
uint32_t sizeThisTime = (frames <= s.blockLeft)?frames:s.blockLeft;
@ -149,6 +161,8 @@ void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEv
s.blockLeft -= sizeThisTime;
if (s.blockLeft == 0) {
s.blockLeft = 48000/238;
doMidi(midiEvents, midiEventCount, 201);
printf("compute params and reset block size\n");
}
if (s.framesLeft <= s.blockLeft) {
@ -162,14 +176,6 @@ void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEv
printf("and now run the rest of the process for %d frames\n\n", frames);
for (uint32_t i = 0; i < midiEventCount; i++) {
if (MidiEvents[i].data[0] == 0x90) {
noteOn(MidiEvents[i].data[1]);
}
if (MidiEvents[i].data[0] == 0x80) {
noteOff(MidiEvents[i].data[1]);
}
}
// run each synth voice
bzero(outputs[0], sizeof(float) * frames);

View File

@ -60,12 +60,13 @@ class Chassis : public Plugin {
// Processing
void activate() override;
void deactivate() override;
void run(const float **, float **outputs, uint32_t frames, const MidiEvent *MidiEvents, uint32_t midiEventCount) override;
void run(const float **, float **outputs, uint32_t frames, const MidiEvent *midiEvents, uint32_t midiEventCount) override;
void noteOn(uint8_t note);
void noteOff(uint8_t note);
private:
void doMidi(const MidiEvent *ev, uint32_t count, uint32_t timelimit ) ;
double sampleRate;
// Voice voice[NUM_VOICES];
uint8_t vPtr;