Browse Source

Change midi::Message::toString() to const. Clean up midi code.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
1b76dd5f07
7 changed files with 16 additions and 14 deletions
  1. +5
    -3
      include/engine/Engine.hpp
  2. +1
    -1
      include/midi.hpp
  3. +1
    -1
      src/core/MIDI_CC.cpp
  4. +3
    -3
      src/core/MIDI_CV.cpp
  5. +2
    -2
      src/core/MIDI_Gate.cpp
  6. +3
    -3
      src/core/MIDI_Map.cpp
  7. +1
    -1
      src/midi.cpp

+ 5
- 3
include/engine/Engine.hpp View File

@@ -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.


+ 1
- 1
include/midi.hpp View File

@@ -80,7 +80,7 @@ struct Message {
bytes[2] = value & 0x7f;
}

std::string toString();
std::string toString() const;
};

////////////////////


+ 1
- 1
src/core/MIDI_CC.cpp View File

@@ -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;


+ 3
- 3
src/core/MIDI_CV.cpp View File

@@ -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


+ 2
- 2
src/core/MIDI_Gate.cpp View File

@@ -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: {


+ 3
- 3
src/core/MIDI_Map.cpp View File

@@ -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


+ 1
- 1
src/midi.cpp View File

@@ -14,7 +14,7 @@ namespace midi {

static std::vector<std::pair<int, Driver*>> 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)


Loading…
Cancel
Save