@@ -63,11 +63,13 @@ struct Engine { | |||||
/** Returns the number of stepBlock() calls since the Engine was created. | /** Returns the number of stepBlock() calls since the Engine was created. | ||||
*/ | */ | ||||
int64_t getBlock(); | 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(); | 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); | void setFrame(int64_t frame); | ||||
/** Returns the frame when stepBlock() was last called. | /** Returns the frame when stepBlock() was last called. | ||||
@@ -80,7 +80,7 @@ struct Message { | |||||
bytes[2] = value & 0x7f; | bytes[2] = value & 0x7f; | ||||
} | } | ||||
std::string toString(); | |||||
std::string toString() const; | |||||
}; | }; | ||||
//////////////////// | //////////////////// | ||||
@@ -71,7 +71,7 @@ struct MIDI_CC : Module { | |||||
void process(const ProcessArgs& args) override { | void process(const ProcessArgs& args) override { | ||||
while (!midiInput.queue.empty()) { | 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. | // Don't process MIDI message until we've reached its frame. | ||||
if (msg.frame > args.frame) | if (msg.frame > args.frame) | ||||
break; | break; | ||||
@@ -122,7 +122,7 @@ struct MIDI_CV : Module { | |||||
void process(const ProcessArgs& args) override { | void process(const ProcessArgs& args) override { | ||||
while (!midiInput.queue.empty()) { | 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. | // Don't process MIDI message until we've reached its frame. | ||||
if (msg.frame > args.frame) | if (msg.frame > args.frame) | ||||
break; | break; | ||||
@@ -184,8 +184,8 @@ struct MIDI_CV : Module { | |||||
outputs[CONTINUE_OUTPUT].setVoltage(continuePulse.process(args.sampleTime) ? 10.f : 0.f); | 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()) { | switch (msg.getStatus()) { | ||||
// note off | // note off | ||||
@@ -65,7 +65,7 @@ struct MIDI_Gate : Module { | |||||
void process(const ProcessArgs& args) override { | void process(const ProcessArgs& args) override { | ||||
while (!midiInput.queue.empty()) { | 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. | // Don't process MIDI message until we've reached its frame. | ||||
if (msg.frame > args.frame) | if (msg.frame > args.frame) | ||||
break; | break; | ||||
@@ -91,7 +91,7 @@ struct MIDI_Gate : Module { | |||||
} | } | ||||
} | } | ||||
void processMessage(const midi::Message &msg) { | |||||
void processMessage(const midi::Message& msg) { | |||||
switch (msg.getStatus()) { | switch (msg.getStatus()) { | ||||
// note off | // note off | ||||
case 0x8: { | case 0x8: { | ||||
@@ -83,7 +83,7 @@ struct MIDI_Map : Module { | |||||
return; | return; | ||||
while (!midiInput.queue.empty()) { | 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. | // Don't process MIDI message until we've reached its frame. | ||||
if (msg.frame > args.frame) | if (msg.frame > args.frame) | ||||
break; | 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()); | // DEBUG("MIDI: %01x %01x %02x %02x", msg.getStatus(), msg.getChannel(), msg.getNote(), msg.getValue()); | ||||
switch (msg.getStatus()) { | 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(); | uint8_t cc = msg.getNote(); | ||||
int8_t value = msg.getValue(); | int8_t value = msg.getValue(); | ||||
// Learn | // Learn | ||||
@@ -14,7 +14,7 @@ namespace midi { | |||||
static std::vector<std::pair<int, Driver*>> drivers; | static std::vector<std::pair<int, Driver*>> drivers; | ||||
std::string Message::toString() { | |||||
std::string Message::toString() const { | |||||
std::string s; | std::string s; | ||||
for (size_t i = 0; i < bytes.size(); i++) { | for (size_t i = 0; i < bytes.size(); i++) { | ||||
if (i > 0) | if (i > 0) | ||||