| @@ -162,12 +162,13 @@ struct HostMIDI : Module { | |||||
| heldNotes.clear(); | heldNotes.clear(); | ||||
| } | } | ||||
| void process(const ProcessArgs& args, std::vector<rack::engine::Output>& outputs) | |||||
| bool process(const ProcessArgs& args, std::vector<rack::engine::Output>& outputs) | |||||
| { | { | ||||
| // Cardinal specific | // Cardinal specific | ||||
| const int64_t blockFrame = pcontext->engine->getBlockFrame(); | const int64_t blockFrame = pcontext->engine->getBlockFrame(); | ||||
| const bool blockFrameChanged = lastBlockFrame != blockFrame; | |||||
| if (lastBlockFrame != blockFrame) | |||||
| if (blockFrameChanged) | |||||
| { | { | ||||
| lastBlockFrame = blockFrame; | lastBlockFrame = blockFrame; | ||||
| @@ -261,6 +262,8 @@ struct HostMIDI : Module { | |||||
| outputs[START_OUTPUT].setVoltage(startPulse.process(args.sampleTime) ? 10.f : 0.f); | outputs[START_OUTPUT].setVoltage(startPulse.process(args.sampleTime) ? 10.f : 0.f); | ||||
| outputs[STOP_OUTPUT].setVoltage(stopPulse.process(args.sampleTime) ? 10.f : 0.f); | outputs[STOP_OUTPUT].setVoltage(stopPulse.process(args.sampleTime) ? 10.f : 0.f); | ||||
| outputs[CONTINUE_OUTPUT].setVoltage(continuePulse.process(args.sampleTime) ? 10.f : 0.f); | outputs[CONTINUE_OUTPUT].setVoltage(continuePulse.process(args.sampleTime) ? 10.f : 0.f); | ||||
| return blockFrameChanged; | |||||
| } | } | ||||
| void processMessage(const midi::Message& msg) { | void processMessage(const midi::Message& msg) { | ||||
| @@ -554,7 +557,10 @@ struct HostMIDI : Module { | |||||
| void process(const ProcessArgs& args) override | void process(const ProcessArgs& args) override | ||||
| { | { | ||||
| midiInput.process(args, outputs); | |||||
| if (midiInput.process(args, outputs)) | |||||
| midiOutput.frame = 0; | |||||
| else | |||||
| ++midiOutput.frame; | |||||
| // MIDI baud rate is 31250 b/s, or 3125 B/s. | // MIDI baud rate is 31250 b/s, or 3125 B/s. | ||||
| // CC messages are 3 bytes, so we can send a maximum of 1041 CC messages per second. | // CC messages are 3 bytes, so we can send a maximum of 1041 CC messages per second. | ||||
| @@ -564,8 +570,6 @@ struct HostMIDI : Module { | |||||
| if (rateLimiterTriggered) | if (rateLimiterTriggered) | ||||
| midiOutput.rateLimiterTimer.time -= rateLimiterPeriod; | midiOutput.rateLimiterTimer.time -= rateLimiterPeriod; | ||||
| midiOutput.setFrame(args.frame); | |||||
| for (int c = 0; c < inputs[PITCH_INPUT].getChannels(); c++) { | for (int c = 0; c < inputs[PITCH_INPUT].getChannels(); c++) { | ||||
| int vel = (int) std::round(inputs[VELOCITY_INPUT].getNormalPolyVoltage(10.f * 100 / 127, c) / 10.f * 127); | int vel = (int) std::round(inputs[VELOCITY_INPUT].getNormalPolyVoltage(10.f * 100 / 127, c) / 10.f * 127); | ||||
| vel = clamp(vel, 0, 127); | vel = clamp(vel, 0, 127); | ||||