diff --git a/include/engine/Engine.hpp b/include/engine/Engine.hpp index dde89ec5..990e7d77 100644 --- a/include/engine/Engine.hpp +++ b/include/engine/Engine.hpp @@ -63,11 +63,13 @@ struct Engine { /** Returns the number of stepBlock() calls since the Engine was created. */ int64_t getBlock(); - /** Returns the number of audio samples since the Engine was created. + /** Returns the frame counter which increases every sample step. + Not necessarily monotonically increasing. Can be reset at any time. */ int64_t getFrame(); - /** Sets the frame of the next stepBlock() call. - There is no reason to reset the frame in standalone Rack. + /** Sets the frame counter. + Useful for when the DAW playhead position jumps to a new position. + Rack plugins and standalone Rack should not call this function. */ void setFrame(int64_t frame); /** Returns the frame when stepBlock() was last called. diff --git a/include/midi.hpp b/include/midi.hpp index 24178354..a9497e96 100644 --- a/include/midi.hpp +++ b/include/midi.hpp @@ -80,7 +80,7 @@ struct Message { bytes[2] = value & 0x7f; } - std::string toString(); + std::string toString() const; }; //////////////////// diff --git a/src/core/MIDI_CC.cpp b/src/core/MIDI_CC.cpp index bcd1dc90..5b9c409a 100644 --- a/src/core/MIDI_CC.cpp +++ b/src/core/MIDI_CC.cpp @@ -71,7 +71,7 @@ struct MIDI_CC : Module { void process(const ProcessArgs& args) override { while (!midiInput.queue.empty()) { - midi::Message& msg = midiInput.queue.front(); + const midi::Message& msg = midiInput.queue.front(); // Don't process MIDI message until we've reached its frame. if (msg.frame > args.frame) break; diff --git a/src/core/MIDI_CV.cpp b/src/core/MIDI_CV.cpp index e7fa7912..22372f6e 100644 --- a/src/core/MIDI_CV.cpp +++ b/src/core/MIDI_CV.cpp @@ -122,7 +122,7 @@ struct MIDI_CV : Module { void process(const ProcessArgs& args) override { while (!midiInput.queue.empty()) { - midi::Message& msg = midiInput.queue.front(); + const midi::Message& msg = midiInput.queue.front(); // Don't process MIDI message until we've reached its frame. if (msg.frame > args.frame) break; @@ -184,8 +184,8 @@ struct MIDI_CV : Module { outputs[CONTINUE_OUTPUT].setVoltage(continuePulse.process(args.sampleTime) ? 10.f : 0.f); } - void processMessage(const midi::Message &msg) { - // DEBUG("MIDI: %01x %01x %02x %02x", msg.getStatus(), msg.getChannel(), msg.getNote(), msg.getValue()); + void processMessage(const midi::Message& msg) { + // DEBUG("MIDI: %ld %s", msg.frame, msg.toString().c_str()); switch (msg.getStatus()) { // note off diff --git a/src/core/MIDI_Gate.cpp b/src/core/MIDI_Gate.cpp index 725b34a3..50801bd5 100644 --- a/src/core/MIDI_Gate.cpp +++ b/src/core/MIDI_Gate.cpp @@ -65,7 +65,7 @@ struct MIDI_Gate : Module { void process(const ProcessArgs& args) override { while (!midiInput.queue.empty()) { - midi::Message& msg = midiInput.queue.front(); + const midi::Message& msg = midiInput.queue.front(); // Don't process MIDI message until we've reached its frame. if (msg.frame > args.frame) break; @@ -91,7 +91,7 @@ struct MIDI_Gate : Module { } } - void processMessage(const midi::Message &msg) { + void processMessage(const midi::Message& msg) { switch (msg.getStatus()) { // note off case 0x8: { diff --git a/src/core/MIDI_Map.cpp b/src/core/MIDI_Map.cpp index b8d51fca..3ea2cfaf 100644 --- a/src/core/MIDI_Map.cpp +++ b/src/core/MIDI_Map.cpp @@ -83,7 +83,7 @@ struct MIDI_Map : Module { return; while (!midiInput.queue.empty()) { - midi::Message& msg = midiInput.queue.front(); + const midi::Message& msg = midiInput.queue.front(); // Don't process MIDI message until we've reached its frame. if (msg.frame > args.frame) break; @@ -130,7 +130,7 @@ struct MIDI_Map : Module { } } - void processMessage(const midi::Message &msg) { + void processMessage(const midi::Message& msg) { // DEBUG("MIDI: %01x %01x %02x %02x", msg.getStatus(), msg.getChannel(), msg.getNote(), msg.getValue()); switch (msg.getStatus()) { @@ -142,7 +142,7 @@ struct MIDI_Map : Module { } } - void processCC(const midi::Message &msg) { + void processCC(const midi::Message& msg) { uint8_t cc = msg.getNote(); int8_t value = msg.getValue(); // Learn diff --git a/src/midi.cpp b/src/midi.cpp index c2dd1b78..8f205494 100644 --- a/src/midi.cpp +++ b/src/midi.cpp @@ -14,7 +14,7 @@ namespace midi { static std::vector> drivers; -std::string Message::toString() { +std::string Message::toString() const { std::string s; for (size_t i = 0; i < bytes.size(); i++) { if (i > 0)