aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/MachineBuilder.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-11 21:07:26 +0000
committerDavid Robillard <d@drobilla.net>2013-01-11 21:07:26 +0000
commitbef1c2ea010da638ffbb437c37a6d32ddc99b568 (patch)
tree3c40f06df385e40edd512247eda23b1f650623df /src/engine/MachineBuilder.cpp
parentd88a8a0a01baff2c4038c315672c6c670361b82c (diff)
downloadmachina-bef1c2ea010da638ffbb437c37a6d32ddc99b568.tar.gz
machina-bef1c2ea010da638ffbb437c37a6d32ddc99b568.tar.bz2
machina-bef1c2ea010da638ffbb437c37a6d32ddc99b568.zip
Bring Machina back into the fold (fix #844).
git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4921 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/MachineBuilder.cpp')
-rw-r--r--src/engine/MachineBuilder.cpp31
1 files changed, 17 insertions, 14 deletions
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 <algorithm>
-#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> node(new Node(TimeStamp(unit)));
node->set_enter_action(SharedPtr<Action>(new MidiAction(ev_size, buf)));
@@ -156,10 +157,10 @@ MachineBuilder::event(Raul::TimeStamp time_offset,
_connect_node_end_time = t;
}
- node->enter(SharedPtr<Raul::MIDISink>(), t);
+ node->enter(SharedPtr<MIDISink>(), 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<MidiAction> action = PtrCast<MidiAction>((*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<Action>());
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<Raul::MIDISink>(), t);
+ resolved->exit(SharedPtr<MIDISink>(), t);
_active_nodes.erase(i);
@@ -254,18 +256,18 @@ MachineBuilder::resolve()
// Resolve stuck notes
if ( ! _active_nodes.empty()) {
for (list<SharedPtr<Node> >::iterator i = _active_nodes.begin(); i != _active_nodes.end(); ++i) {
- cerr << "WARNING: Resolving stuck note." << endl;
+ cerr << "WARNING: Resolving stuck note." << endl;
SharedPtr<MidiAction> action = PtrCast<MidiAction>((*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<Action>(new MidiAction(3, note_off)));
set_node_duration((*i), _time - (*i)->enter_time());
- (*i)->exit(SharedPtr<Raul::MIDISink>(), _time);
+ (*i)->exit(SharedPtr<MIDISink>(), _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);
}