aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/JackDriver.cpp4
-rw-r--r--src/engine/MachineBuilder.cpp15
-rw-r--r--src/engine/Recorder.cpp4
-rw-r--r--src/engine/SMFDriver.cpp4
-rw-r--r--src/engine/machina/Driver.hpp2
-rw-r--r--src/engine/machina/JackDriver.hpp2
-rw-r--r--src/engine/machina/MachineBuilder.hpp5
-rw-r--r--src/engine/machina/Recorder.hpp2
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);