aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-14 02:42:29 +0000
committerDavid Robillard <d@drobilla.net>2013-01-14 02:42:29 +0000
commit08e702ada89b951466c7b9c787663e0a57846e5a (patch)
treeebc017225112c6245caeb310859b16cabf50fab0 /src/engine
parentf111891cfbc183339e3119d5ff3718184cdedd21 (diff)
downloadmachina-08e702ada89b951466c7b9c787663e0a57846e5a.tar.gz
machina-08e702ada89b951466c7b9c787663e0a57846e5a.tar.bz2
machina-08e702ada89b951466c7b9c787663e0a57846e5a.zip
Make quantize spinner control step record and new node length.
Only quantize non-step recording if quantize checkbox is enabled. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4977 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/JackDriver.cpp7
-rw-r--r--src/engine/JackDriver.hpp7
-rw-r--r--src/engine/MachineBuilder.cpp2
-rw-r--r--src/engine/SMFDriver.hpp5
-rw-r--r--src/engine/machina/Driver.hpp22
5 files changed, 19 insertions, 24 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 840573e..8eada7c 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -41,8 +41,6 @@ JackDriver::JackDriver(Raul::Forge& forge, SPtr<Machine> machine)
, _context(forge, 48000, MACHINA_PPQN, 120.0)
, _frames_unit(TimeUnit::FRAMES, 48000)
, _beats_unit(TimeUnit::BEATS, 19200)
- , _bpm(120.0)
- , _quantization(0.0f)
, _stop(0)
, _stop_flag(false)
, _record_dur(_frames_unit) // = 0
@@ -421,17 +419,18 @@ JackDriver::set_play_state(PlayState state)
finish_record();
}
}
- _play_state = state;
+ Driver::set_play_state(state);
}
void
JackDriver::start_record(bool step)
{
+ const double q = (step || _quantize_record) ? _quantization.get() : 0.0;
switch (_play_state) {
case PlayState::STOPPED:
case PlayState::PLAYING:
_recorder = SPtr<Recorder>(
- new Recorder(_forge, 1024, _beats_unit, _quantization.get(), step));
+ new Recorder(_forge, 1024, _beats_unit, q, step));
_recorder->start();
_record_dur = 0;
break;
diff --git a/src/engine/JackDriver.hpp b/src/engine/JackDriver.hpp
index 14ed626..a67afbc 100644
--- a/src/engine/JackDriver.hpp
+++ b/src/engine/JackDriver.hpp
@@ -22,7 +22,6 @@
#include <jack/jack.h>
#include <jack/midiport.h>
-#include "raul/DoubleBuffer.hpp"
#include "raul/Semaphore.hpp"
#include "machina/Context.hpp"
@@ -61,9 +60,6 @@ public:
size_t size,
const unsigned char* event);
- void set_bpm(double bpm) { _bpm.set(bpm); }
- void set_quantization(double q) { _quantization.set(q); }
-
void set_play_state(PlayState state);
void start_transport() { jack_transport_start(_client); }
@@ -112,9 +108,6 @@ private:
Raul::TimeUnit _frames_unit;
Raul::TimeUnit _beats_unit;
- Raul::DoubleBuffer<double> _bpm;
- Raul::DoubleBuffer<double> _quantization;
-
Raul::Semaphore _stop;
bool _stop_flag;
diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp
index 566944e..d812b06 100644
--- a/src/engine/MachineBuilder.cpp
+++ b/src/engine/MachineBuilder.cpp
@@ -37,7 +37,7 @@ MachineBuilder::MachineBuilder(SPtr<Machine> machine, double q, bool step)
, _initial_node(machine->initial_node()) // duration 0
, _connect_node(_initial_node)
, _connect_node_end_time(_time) // = 0
- , _step_duration(machine->time().unit(), 1, 0)
+ , _step_duration(_time.unit(), q)
, _step(step)
{}
diff --git a/src/engine/SMFDriver.hpp b/src/engine/SMFDriver.hpp
index 1e40ab6..6199fc1 100644
--- a/src/engine/SMFDriver.hpp
+++ b/src/engine/SMFDriver.hpp
@@ -52,11 +52,6 @@ public:
const unsigned char* ev) throw (std::logic_error)
{ _writer->write_event(time, ev_size, ev); }
- void set_bpm(double /*bpm*/) {}
- void set_quantization(double /*quantization*/) {}
-
- void set_play_state(PlayState state) {}
-
SPtr<SMFWriter> writer() { return _writer; }
private:
diff --git a/src/engine/machina/Driver.hpp b/src/engine/machina/Driver.hpp
index 1fad9b3..f21bb07 100644
--- a/src/engine/machina/Driver.hpp
+++ b/src/engine/machina/Driver.hpp
@@ -19,6 +19,7 @@
#include <atomic>
+#include "raul/DoubleBuffer.hpp"
#include "raul/RingBuffer.hpp"
#include "machina/types.hpp"
@@ -36,6 +37,9 @@ public:
: _forge(forge)
, _machine(machine)
, _play_state(PlayState::STOPPED)
+ , _bpm(120.0)
+ , _quantization(0.125)
+ , _quantize_record(0)
{}
enum class PlayState {
@@ -59,9 +63,10 @@ public:
_updates = b;
}
- virtual void set_bpm(double bpm) = 0;
- virtual void set_quantization(double q) = 0;
- virtual void set_play_state(PlayState state) = 0;
+ virtual void set_bpm(double bpm) { _bpm.set(bpm); }
+ virtual void set_quantization(double q) { _quantization.set(q); }
+ virtual void set_quantize_record(bool q) { _quantize_record = q; }
+ virtual void set_play_state(PlayState state) { _play_state = state; }
virtual bool is_activated() const { return false; }
virtual void activate() {}
@@ -70,10 +75,13 @@ public:
PlayState play_state() const { return _play_state.load(); }
protected:
- Raul::Forge& _forge;
- SPtr<Machine> _machine;
- SPtr<Raul::RingBuffer> _updates;
- std::atomic<PlayState> _play_state;
+ Raul::Forge& _forge;
+ SPtr<Machine> _machine;
+ SPtr<Raul::RingBuffer> _updates;
+ std::atomic<PlayState> _play_state;
+ Raul::DoubleBuffer<double> _bpm;
+ Raul::DoubleBuffer<double> _quantization;
+ bool _quantize_record;
};
} // namespace machina