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 | |
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')
-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 | ||||
-rw-r--r-- | src/gui/MachinaGUI.cpp | 4 | ||||
-rw-r--r-- | src/gui/MachinaGUI.hpp | 1 | ||||
-rw-r--r-- | src/gui/machina.glade | 28 |
11 files changed, 49 insertions, 22 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); diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index 0d697b2..0e66f4c 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -70,6 +70,7 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine) xml->get_widget("help_about_menuitem", _menu_help_about); xml->get_widget("help_help_menuitem", _menu_help_help); xml->get_widget("canvas_scrolledwindow", _canvas_scrolledwindow); + xml->get_widget("step_record_checkbutton", _step_record_checkbutton); xml->get_widget("clock_checkbutton", _clock_checkbutton); xml->get_widget("bpm_spinbutton", _bpm_spinbutton); xml->get_widget("quantize_checkbutton", _quantize_checkbutton); @@ -166,6 +167,7 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine) _main_window->present(); + _step_record_checkbutton->show(); _clock_checkbutton->set_active(true); _quantize_checkbutton->set_active(false); update_toolbar(); @@ -653,7 +655,7 @@ void MachinaGUI::record_toggled() { if (_record_button->get_active() && ! _engine->driver()->recording()) { - _engine->driver()->start_record(); + _engine->driver()->start_record(_step_record_checkbutton->get_active()); } else if (_engine->driver()->recording()) { _engine->driver()->finish_record(); _canvas->build(_engine->machine(), _menu_view_labels->get_active()); diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp index 75d4c04..1b348fb 100644 --- a/src/gui/MachinaGUI.hpp +++ b/src/gui/MachinaGUI.hpp @@ -120,6 +120,7 @@ protected: Gtk::ScrolledWindow* _canvas_scrolledwindow; Gtk::TextView* _status_text; Gtk::Expander* _messages_expander; + Gtk::ToggleToolButton* _step_record_checkbutton; Gtk::CheckButton* _clock_checkbutton; Gtk::SpinButton* _bpm_spinbutton; Gtk::CheckButton* _quantize_checkbutton; diff --git a/src/gui/machina.glade b/src/gui/machina.glade index 775a6c0..4cfc5a7 100644 --- a/src/gui/machina.glade +++ b/src/gui/machina.glade @@ -256,6 +256,26 @@ </packing> </child> <child> + <widget class="GtkToggleToolButton" id="step_record_checkbutton"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip" translatable="yes">Step recording</property> + <property name="stock_id">gtk-add</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkSeparatorToolItem" id="separatortoolitem4"> + <property name="visible">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + <child> <widget class="GtkToolItem" id="toolitem1"> <property name="visible">True</property> <child> @@ -277,7 +297,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="tooltip" translatable="yes">Set internal tempo</property> - <property name="adjustment">120 1 640 1 10 10</property> + <property name="adjustment">120 1 640 1 10 0</property> <property name="climb_rate">1</property> </widget> <packing> @@ -339,7 +359,7 @@ <property name="visible">True</property> <property name="sensitive">False</property> <property name="can_focus">True</property> - <property name="adjustment">1 1 99 1 4 4</property> + <property name="adjustment">1 1 99 1 4 0</property> <property name="climb_rate">1</property> </widget> <packing> @@ -728,7 +748,7 @@ Selector nodes are shown in green. <property name="visible">True</property> <property name="can_focus">True</property> <property name="has_focus">True</property> - <property name="adjustment">1 0 999999 1 10 10</property> + <property name="adjustment">1 0 999999 1 10 0</property> <property name="climb_rate">1</property> <property name="digits">2</property> <property name="numeric">True</property> @@ -769,7 +789,7 @@ Selector nodes are shown in green. <widget class="GtkSpinButton" id="node_properties_note_spinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">60 0 127 1 10 10</property> + <property name="adjustment">60 0 127 1 10 0</property> <property name="climb_rate">1</property> <property name="numeric">True</property> </widget> |