diff options
author | David Robillard <d@drobilla.net> | 2010-12-17 03:31:06 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-17 03:31:06 +0000 |
commit | 7d2d23dc6a2b20c99021da81f0e0b33429df442a (patch) | |
tree | 02565c9c21ab48b04a7aac01d4dcf360675cc354 /src/engine | |
parent | 7b61e7ac1fe67528c99efc2ff9fa5a6fed627978 (diff) | |
download | machina-7d2d23dc6a2b20c99021da81f0e0b33429df442a.tar.gz machina-7d2d23dc6a2b20c99021da81f0e0b33429df442a.tar.bz2 machina-7d2d23dc6a2b20c99021da81f0e0b33429df442a.zip |
Step recording.
git-svn-id: http://svn.drobilla.net/lad/trunk/machina@2733 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/JackDriver.cpp | 4 | ||||
-rw-r--r-- | src/engine/MachineBuilder.cpp | 15 | ||||
-rw-r--r-- | src/engine/Recorder.cpp | 4 | ||||
-rw-r--r-- | src/engine/SMFDriver.cpp | 4 | ||||
-rw-r--r-- | src/engine/machina/Driver.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/JackDriver.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/MachineBuilder.hpp | 5 | ||||
-rw-r--r-- | src/engine/machina/Recorder.hpp | 2 |
8 files changed, 21 insertions, 17 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 1be0036..3f705a9 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -333,10 +333,10 @@ JackDriver::stop() void -JackDriver::start_record() +JackDriver::start_record(bool step) { // FIXME: Choose an appropriate maximum ringbuffer size - _recorder = SharedPtr<Recorder>(new Recorder(1024, _beats_unit, _quantization.get())); + _recorder = SharedPtr<Recorder>(new Recorder(1024, _beats_unit, _quantization.get(), step)); _recorder->start(); _record_dur = 0; _recording = 1; diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp index 00d0891..7c65feb 100644 --- a/src/engine/MachineBuilder.cpp +++ b/src/engine/MachineBuilder.cpp @@ -29,13 +29,14 @@ using namespace Raul; namespace Machina { -MachineBuilder::MachineBuilder(SharedPtr<Machine> machine, double q) +MachineBuilder::MachineBuilder(SharedPtr<Machine> machine, double q, bool step) : _quantization(q) , _time(machine->time().unit()) // = 0 , _machine(machine) , _initial_node(new Node(_time, true)) // duration 0 , _connect_node(_initial_node) , _connect_node_end_time(_time) // = 0 + , _step(step) { } @@ -53,10 +54,7 @@ MachineBuilder::reset() bool MachineBuilder::is_delay_node(SharedPtr<Node> node) const { - if (node->enter_action() || node->exit_action()) - return false; - else - return true; + return !node->enter_action() && !node->exit_action(); } @@ -93,7 +91,7 @@ MachineBuilder::connect_nodes(SharedPtr<Machine> m, // Tail is a delay node, just accumulate the time difference into it set_node_duration(tail, tail->duration() + head_start_time - tail_end_time); tail->add_edge(SharedPtr<Edge>(new Edge(tail, head))); - } else if (head_start_time == tail_end_time) { + } else if (_step || (head_start_time == tail_end_time)) { // Connect directly tail->add_edge(SharedPtr<Edge>(new Edge(tail, head))); } else { @@ -174,7 +172,10 @@ MachineBuilder::event(Raul::TimeStamp time_offset, SharedPtr<Node> resolved = *i; resolved->set_exit_action(SharedPtr<Action>(new MidiAction(ev_size, buf))); - set_node_duration(resolved, t - resolved->enter_time()); + if (_step) + set_node_duration(resolved, TimeStamp(t.unit())); + else + set_node_duration(resolved, t - resolved->enter_time()); // Last active note if (_active_nodes.size() == 1) { diff --git a/src/engine/Recorder.cpp b/src/engine/Recorder.cpp index 8c68d04..d134d25 100644 --- a/src/engine/Recorder.cpp +++ b/src/engine/Recorder.cpp @@ -26,10 +26,10 @@ using namespace Raul; namespace Machina { -Recorder::Recorder(size_t buffer_size, TimeUnit unit, double q) +Recorder::Recorder(size_t buffer_size, TimeUnit unit, double q, bool step) : _unit(unit) , _record_buffer(buffer_size) - , _builder(new MachineBuilder(SharedPtr<Machine>(new Machine(unit)), q)) + , _builder(new MachineBuilder(SharedPtr<Machine>(new Machine(unit)), q, step)) { } diff --git a/src/engine/SMFDriver.cpp b/src/engine/SMFDriver.cpp index f072ea6..f1b8b6c 100644 --- a/src/engine/SMFDriver.cpp +++ b/src/engine/SMFDriver.cpp @@ -50,7 +50,7 @@ SMFDriver::learn(const string& filename, unsigned track, double q, Raul::TimeDur { //assert(q.unit() == max_duration.unit()); SharedPtr<Machine> m(new Machine(max_duration.unit())); - SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(new MachineBuilder(m, q)); + SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(new MachineBuilder(m, q, false)); Raul::SMFReader reader; if (!reader.open(filename)) { @@ -80,7 +80,7 @@ SharedPtr<Machine> SMFDriver::learn(const string& filename, double q, Raul::TimeStamp max_duration) { SharedPtr<Machine> m(new Machine(max_duration.unit())); - SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(new MachineBuilder(m, q)); + SharedPtr<MachineBuilder> builder = SharedPtr<MachineBuilder>(new MachineBuilder(m, q, false)); Raul::SMFReader reader; if (!reader.open(filename)) { diff --git a/src/engine/machina/Driver.hpp b/src/engine/machina/Driver.hpp index 1fca75e..f1251ae 100644 --- a/src/engine/machina/Driver.hpp +++ b/src/engine/machina/Driver.hpp @@ -42,7 +42,7 @@ public: virtual void stop() {} virtual bool recording() { return false; } - virtual void start_record() {} + virtual void start_record(bool step) {} virtual void finish_record() {} protected: diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp index 5fe4e0d..8e13d08 100644 --- a/src/engine/machina/JackDriver.hpp +++ b/src/engine/machina/JackDriver.hpp @@ -66,7 +66,7 @@ public: void stop(); bool recording() { return _recording.get(); } - void start_record(); + void start_record(bool step); void finish_record(); private: diff --git a/src/engine/machina/MachineBuilder.hpp b/src/engine/machina/MachineBuilder.hpp index 0c40cc8..d98d91c 100644 --- a/src/engine/machina/MachineBuilder.hpp +++ b/src/engine/machina/MachineBuilder.hpp @@ -30,7 +30,8 @@ class Node; class MachineBuilder { public: MachineBuilder(SharedPtr<Machine> machine, - double quantization); + double quantization, + bool step); void set_time(Raul::TimeStamp time) { _time = time; } @@ -63,6 +64,8 @@ private: SharedPtr<Node> _initial_node; SharedPtr<Node> _connect_node; Raul::TimeStamp _connect_node_end_time; + + bool _step; }; diff --git a/src/engine/machina/Recorder.hpp b/src/engine/machina/Recorder.hpp index 510b9a8..623dbfe 100644 --- a/src/engine/machina/Recorder.hpp +++ b/src/engine/machina/Recorder.hpp @@ -30,7 +30,7 @@ class MachineBuilder; class Recorder : public Raul::Slave { public: - Recorder(size_t buffer_size, TimeUnit unit, double q); + Recorder(size_t buffer_size, TimeUnit unit, double q, bool step); inline void write(Raul::TimeStamp time, size_t size, const unsigned char* buf) { _record_buffer.write(time, size, buf); |