diff options
-rw-r--r-- | src/engine/JackDriver.cpp | 18 | ||||
-rw-r--r-- | src/engine/MachineBuilder.cpp | 3 | ||||
-rw-r--r-- | src/engine/machina/JackDriver.hpp | 2 |
3 files changed, 11 insertions, 12 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 134ca82..1be0036 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -38,7 +38,7 @@ JackDriver::JackDriver(SharedPtr<Machine> machine) , _cycle_time(48000, MACHINA_PPQN, 120.0) , _bpm(120.0) , _quantization(0.0f) - , _record_time(machine->time().unit()) + , _record_dur(_frames_unit) // = 0 , _recording(0) { } @@ -137,13 +137,16 @@ JackDriver::process_input(SharedPtr<Machine> machine, const TimeSlice& time) jack_midi_event_t ev; jack_midi_event_get(&ev, jack_buffer, i); - _recorder->write(_record_time + TimeStamp(_record_time.unit(), ev.time, 0), - ev.size, ev.buffer); + const TimeStamp rel_time_frames = TimeStamp(_frames_unit, ev.time); + const TimeStamp time_frames = _record_dur + rel_time_frames; + _recorder->write(time.ticks_to_beats(time_frames), ev.size, ev.buffer); } if (event_count > 0) _recorder->whip(); + _record_dur += time.length_ticks(); + } else { const jack_nframes_t nframes = time.length_ticks().ticks(); @@ -270,9 +273,6 @@ JackDriver::on_process(jack_nframes_t nframes) machine->set_sink(shared_from_this()); - if (_recording.get()) - _record_time += length_beats; - if (_stop.pending()) machine->reset(_cycle_time.start_beats()); @@ -336,10 +336,10 @@ void JackDriver::start_record() { // FIXME: Choose an appropriate maximum ringbuffer size - /*_recorder = SharedPtr<Recorder>(new Recorder(1024, _frames_unit, _quantization.get())); + _recorder = SharedPtr<Recorder>(new Recorder(1024, _beats_unit, _quantization.get())); _recorder->start(); - _record_time = 0; - _recording = 1;*/ + _record_dur = 0; + _recording = 1; } diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp index 004c478..00d0891 100644 --- a/src/engine/MachineBuilder.cpp +++ b/src/engine/MachineBuilder.cpp @@ -128,7 +128,7 @@ MachineBuilder::event(Raul::TimeStamp time_offset, Raul::TimeStamp this_connect_node_end_time(unit); // If currently polyphonic, use a poly node with no successors as connect node - // Results in patterns closes to what a human would choose + // Results in patterns closest to what a human would choose if ( ! _poly_nodes.empty()) { for (PolyList::iterator j = _poly_nodes.begin(); j != _poly_nodes.end(); ++j) { if (j->second->edges().empty()) { @@ -146,7 +146,6 @@ MachineBuilder::event(Raul::TimeStamp time_offset, this_connect_node_end_time = _connect_node_end_time; } - SharedPtr<Node> delay_node = connect_nodes(_machine, this_connect_node, this_connect_node_end_time, node, t); diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp index ac526c3..5fe4e0d 100644 --- a/src/engine/machina/JackDriver.hpp +++ b/src/engine/machina/JackDriver.hpp @@ -90,7 +90,7 @@ private: Raul::Command _stop; - Raul::TimeStamp _record_time; + Raul::TimeDuration _record_dur; Raul::AtomicInt _recording; SharedPtr<Recorder> _recorder; }; |