diff options
author | David Robillard <d@drobilla.net> | 2007-03-31 07:04:04 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-03-31 07:04:04 +0000 |
commit | 7416f0b38e8eec05aea63604bdf23b5905c15754 (patch) | |
tree | 6ea8d7b3c063f2c782ce41a874f855ee1cebc2c5 /src/engine | |
parent | f8883a56e44a42e97ca84392fdbff61e11540fcd (diff) | |
download | machina-7416f0b38e8eec05aea63604bdf23b5905c15754.tar.gz machina-7416f0b38e8eec05aea63604bdf23b5905c15754.tar.bz2 machina-7416f0b38e8eec05aea63604bdf23b5905c15754.zip |
Fixed tempo skew (record vs playback).
Recording/building algorithm fixes.
Polished up GUI things.
git-svn-id: http://svn.drobilla.net/lad/machina@384 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/JackDriver.cpp | 4 | ||||
-rw-r--r-- | src/engine/Machine.cpp | 4 | ||||
-rw-r--r-- | src/engine/MachineBuilder.cpp | 29 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 5 |
4 files changed, 27 insertions, 15 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index ed40e2a..d19bdeb 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -235,7 +235,7 @@ JackDriver::on_process(jack_nframes_t nframes) process_input(machine, _cycle_time); - if (machine->is_empty()) + if (machine->is_empty() || !machine->is_activated()) return; while (true) { @@ -285,7 +285,7 @@ JackDriver::start_record() { std::cerr << "START RECORD" << std::endl; // FIXME: hardcoded size - _recorder = SharedPtr<Recorder>(new Recorder(1024, 1.0/(double)sample_rate())); + _recorder = SharedPtr<Recorder>(new Recorder(1024, (1.0/(double)sample_rate()) * (_bpm.get() / 60.0))); _recorder->start(); _record_time = 0; _recording = 1; diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index 43fd280..2857e8b 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -83,6 +83,10 @@ Machine::reset() assert(! node->is_active()); } } + + for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) { + _active_nodes[i].reset(); + } _time = 0; _is_finished = false; diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp index a1a6ed8..515f1a0 100644 --- a/src/engine/MachineBuilder.cpp +++ b/src/engine/MachineBuilder.cpp @@ -73,25 +73,30 @@ MachineBuilder::connect_nodes(SharedPtr<Machine> m, SharedPtr<Node> delay_node; - //cerr << "Connect nodes durations: " << tail->duration() << " .. " << head->duration() << endl; - //cerr << "Connect nodes times: " << tail_end_time << " .. " << head_start_time << endl; + cerr << "******" << endl; + cerr << "Connect nodes durations: " << tail->duration() << " .. " << head->duration() << endl; + cerr << "Connect nodes times: " << tail_end_time << " .. " << head_start_time << endl; - if (head_start_time == tail_end_time) { - // Connect directly - tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, head))); - } else if (is_delay_node(tail)) { + if (is_delay_node(tail) && tail->outgoing_edges().size() == 0) { // Tail is a delay node, just accumulate the time difference into it + cerr << "Accumulating delay " << tail_end_time << " .. " << head_start_time << endl; tail->set_duration(tail->duration() + head_start_time - tail_end_time); tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, head))); + } else if (head_start_time == tail_end_time) { + // Connect directly + cerr << "Connnecting directly " << tail_end_time << " .. " << head_start_time << endl; + tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, head))); } else { // Need to actually create a delay node - //cerr << "Adding delay node for " << tail_end_time << " .. " << head_start_time << endl; + cerr << "Adding delay node for " << tail_end_time << " .. " << head_start_time << endl; delay_node = SharedPtr<Node>(new Node()); delay_node->set_duration(head_start_time - tail_end_time); tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, delay_node))); delay_node->add_outgoing_edge(SharedPtr<Edge>(new Edge(delay_node, head))); m->add_node(delay_node); } + + cerr << "******" << endl << endl; return delay_node; } @@ -116,10 +121,10 @@ MachineBuilder::event(Raul::BeatTime time_offset, SharedPtr<Node> delay_node = connect_nodes(_machine, _connect_node, _connect_node_end_time, node, t); - if (delay_node) { + /*if (delay_node) { _connect_node = delay_node; _connect_node_end_time = t; - } + }*/ node->enter(SharedPtr<Raul::MIDISink>(), t); _active_nodes.push_back(node); @@ -144,9 +149,10 @@ MachineBuilder::event(Raul::BeatTime time_offset, resolved->set_exit_action(SharedPtr<Action>(new MidiAction(ev_size, buf))); resolved->set_duration(t - resolved->enter_time()); - _connect_node_end_time = t; - if (_active_nodes.size() == 1) { + + _connect_node_end_time = t; + if (_poly_nodes.size() > 0) { _connect_node = SharedPtr<Node>(new Node()); @@ -170,6 +176,7 @@ MachineBuilder::event(Raul::BeatTime time_offset, if (is_delay_node(_connect_node) && _connect_node->duration() == 0 && _connect_node->outgoing_edges().size() == 1 && (*_connect_node->outgoing_edges().begin())->head() == resolved) { + cerr << "TRIMMING\n"; _connect_node->outgoing_edges().clear(); assert(_connect_node->outgoing_edges().empty()); _connect_node->set_enter_action(resolved->enter_action()); diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 7424f31..14632f0 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -39,8 +39,9 @@ public: void activate() { _is_activated = true; } void deactivate() { _is_activated = false; } - bool is_empty() { return _nodes.empty(); } - bool is_finished() { return _is_finished; } + bool is_empty() { return _nodes.empty(); } + bool is_finished() { return _is_finished; } + bool is_activated() { return _is_activated; } void add_node(SharedPtr<Node> node); void remove_node(SharedPtr<Node> node); |