From bef1c2ea010da638ffbb437c37a6d32ddc99b568 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 Jan 2013 21:07:26 +0000 Subject: Bring Machina back into the fold (fix #844). git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4921 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/MachineBuilder.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/engine/MachineBuilder.cpp') diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp index 7157b8f..4f4d599 100644 --- a/src/engine/MachineBuilder.cpp +++ b/src/engine/MachineBuilder.cpp @@ -17,16 +17,17 @@ #include -#include "raul/midi_events.h" +#include "lv2/lv2plug.in/ns/ext/midi/midi.h" + #include "raul/SharedPtr.hpp" -#include "raul/Quantizer.hpp" #include "machina/Machine.hpp" #include "Edge.hpp" -#include "Node.hpp" #include "MachineBuilder.hpp" #include "MidiAction.hpp" +#include "Node.hpp" +#include "Quantizer.hpp" using namespace std; using namespace Raul; @@ -121,7 +122,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, if (ev_size == 0) return; - if ((buf[0] & 0xF0) == MIDI_CMD_NOTE_ON) { + if ((buf[0] & 0xF0) == LV2_MIDI_MSG_NOTE_ON) { SharedPtr node(new Node(TimeStamp(unit))); node->set_enter_action(SharedPtr(new MidiAction(ev_size, buf))); @@ -156,10 +157,10 @@ MachineBuilder::event(Raul::TimeStamp time_offset, _connect_node_end_time = t; } - node->enter(SharedPtr(), t); + node->enter(SharedPtr(), t); _active_nodes.push_back(node); - } else if ((buf[0] & 0xF0) == MIDI_CMD_NOTE_OFF) { + } else if ((buf[0] & 0xF0) == LV2_MIDI_MSG_NOTE_OFF) { for (ActiveList::iterator i = _active_nodes.begin(); i != _active_nodes.end(); ++i) { SharedPtr action = PtrCast((*i)->enter_action()); @@ -169,7 +170,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, const size_t ev_size = action->event_size(); const unsigned char* ev = action->event(); - if (ev_size == 3 && (ev[0] & 0xF0) == MIDI_CMD_NOTE_ON + if (ev_size == 3 && (ev[0] & 0xF0) == LV2_MIDI_MSG_NOTE_ON && (ev[0] & 0x0F) == (buf[0] & 0x0F) // same channel && ev[1] == buf[1]) // same note { @@ -217,7 +218,8 @@ MachineBuilder::event(Raul::TimeStamp time_offset, resolved->set_exit_action(SharedPtr()); set_node_duration(_connect_node, resolved->duration()); resolved = _connect_node; - if (_machine->nodes().find(_connect_node) == _machine->nodes().end()) + if (std::find(_machine->nodes().begin(), _machine->nodes().end(), _connect_node) + == _machine->nodes().end()) _machine->add_node(_connect_node); } else { @@ -234,7 +236,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, } if (resolved->is_active()) - resolved->exit(SharedPtr(), t); + resolved->exit(SharedPtr(), t); _active_nodes.erase(i); @@ -254,18 +256,18 @@ MachineBuilder::resolve() // Resolve stuck notes if ( ! _active_nodes.empty()) { for (list >::iterator i = _active_nodes.begin(); i != _active_nodes.end(); ++i) { - cerr << "WARNING: Resolving stuck note." << endl; + cerr << "WARNING: Resolving stuck note." << endl; SharedPtr action = PtrCast((*i)->enter_action()); if (!action) continue; const size_t ev_size = action->event_size(); const unsigned char* ev = action->event(); - if (ev_size == 3 && (ev[0] & 0xF0) == MIDI_CMD_NOTE_ON) { - unsigned char note_off[3] = { ((MIDI_CMD_NOTE_OFF & 0xF0) | (ev[0] & 0x0F)), ev[1], 0x40 }; + if (ev_size == 3 && (ev[0] & 0xF0) == LV2_MIDI_MSG_NOTE_ON) { + unsigned char note_off[3] = { ((LV2_MIDI_MSG_NOTE_OFF & 0xF0) | (ev[0] & 0x0F)), ev[1], 0x40 }; (*i)->set_exit_action(SharedPtr(new MidiAction(3, note_off))); set_node_duration((*i), _time - (*i)->enter_time()); - (*i)->exit(SharedPtr(), _time); + (*i)->exit(SharedPtr(), _time); _machine->add_node((*i)); } } @@ -274,7 +276,8 @@ MachineBuilder::resolve() // Add initial note if necessary if (_machine->nodes().size() > 0 - && _machine->nodes().find(_initial_node) == _machine->nodes().end()) + && (std::find(_machine->nodes().begin(), _machine->nodes().end(), _initial_node) + == _machine->nodes().end())) _machine->add_node(_initial_node); } -- cgit v1.2.1