aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-03-31 07:04:04 +0000
committerDavid Robillard <d@drobilla.net>2007-03-31 07:04:04 +0000
commit7416f0b38e8eec05aea63604bdf23b5905c15754 (patch)
tree6ea8d7b3c063f2c782ce41a874f855ee1cebc2c5
parentf8883a56e44a42e97ca84392fdbff61e11540fcd (diff)
downloadmachina-7416f0b38e8eec05aea63604bdf23b5905c15754.tar.gz
machina-7416f0b38e8eec05aea63604bdf23b5905c15754.tar.bz2
machina-7416f0b38e8eec05aea63604bdf23b5905c15754.zip
Fixed tempo skew (record vs playback).
Recording/building algorithm fixes. Polished up GUI things. git-svn-id: http://svn.drobilla.net/lad/machina@384 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/engine/JackDriver.cpp4
-rw-r--r--src/engine/Machine.cpp4
-rw-r--r--src/engine/MachineBuilder.cpp29
-rw-r--r--src/engine/machina/Machine.hpp5
-rw-r--r--src/gui/MachinaCanvas.cpp2
-rw-r--r--src/gui/MachinaGUI.cpp13
-rw-r--r--src/gui/machina.glade79
7 files changed, 86 insertions, 50 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index ed40e2a..d19bdeb 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -235,7 +235,7 @@ JackDriver::on_process(jack_nframes_t nframes)
process_input(machine, _cycle_time);
- if (machine->is_empty())
+ if (machine->is_empty() || !machine->is_activated())
return;
while (true) {
@@ -285,7 +285,7 @@ JackDriver::start_record()
{
std::cerr << "START RECORD" << std::endl;
// FIXME: hardcoded size
- _recorder = SharedPtr<Recorder>(new Recorder(1024, 1.0/(double)sample_rate()));
+ _recorder = SharedPtr<Recorder>(new Recorder(1024, (1.0/(double)sample_rate()) * (_bpm.get() / 60.0)));
_recorder->start();
_record_time = 0;
_recording = 1;
diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp
index 43fd280..2857e8b 100644
--- a/src/engine/Machine.cpp
+++ b/src/engine/Machine.cpp
@@ -83,6 +83,10 @@ Machine::reset()
assert(! node->is_active());
}
}
+
+ for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) {
+ _active_nodes[i].reset();
+ }
_time = 0;
_is_finished = false;
diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp
index a1a6ed8..515f1a0 100644
--- a/src/engine/MachineBuilder.cpp
+++ b/src/engine/MachineBuilder.cpp
@@ -73,25 +73,30 @@ MachineBuilder::connect_nodes(SharedPtr<Machine> m,
SharedPtr<Node> delay_node;
- //cerr << "Connect nodes durations: " << tail->duration() << " .. " << head->duration() << endl;
- //cerr << "Connect nodes times: " << tail_end_time << " .. " << head_start_time << endl;
+ cerr << "******" << endl;
+ cerr << "Connect nodes durations: " << tail->duration() << " .. " << head->duration() << endl;
+ cerr << "Connect nodes times: " << tail_end_time << " .. " << head_start_time << endl;
- if (head_start_time == tail_end_time) {
- // Connect directly
- tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, head)));
- } else if (is_delay_node(tail)) {
+ if (is_delay_node(tail) && tail->outgoing_edges().size() == 0) {
// Tail is a delay node, just accumulate the time difference into it
+ cerr << "Accumulating delay " << tail_end_time << " .. " << head_start_time << endl;
tail->set_duration(tail->duration() + head_start_time - tail_end_time);
tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, head)));
+ } else if (head_start_time == tail_end_time) {
+ // Connect directly
+ cerr << "Connnecting directly " << tail_end_time << " .. " << head_start_time << endl;
+ tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, head)));
} else {
// Need to actually create a delay node
- //cerr << "Adding delay node for " << tail_end_time << " .. " << head_start_time << endl;
+ cerr << "Adding delay node for " << tail_end_time << " .. " << head_start_time << endl;
delay_node = SharedPtr<Node>(new Node());
delay_node->set_duration(head_start_time - tail_end_time);
tail->add_outgoing_edge(SharedPtr<Edge>(new Edge(tail, delay_node)));
delay_node->add_outgoing_edge(SharedPtr<Edge>(new Edge(delay_node, head)));
m->add_node(delay_node);
}
+
+ cerr << "******" << endl << endl;
return delay_node;
}
@@ -116,10 +121,10 @@ MachineBuilder::event(Raul::BeatTime time_offset,
SharedPtr<Node> delay_node = connect_nodes(_machine,
_connect_node, _connect_node_end_time, node, t);
- if (delay_node) {
+ /*if (delay_node) {
_connect_node = delay_node;
_connect_node_end_time = t;
- }
+ }*/
node->enter(SharedPtr<Raul::MIDISink>(), t);
_active_nodes.push_back(node);
@@ -144,9 +149,10 @@ MachineBuilder::event(Raul::BeatTime time_offset,
resolved->set_exit_action(SharedPtr<Action>(new MidiAction(ev_size, buf)));
resolved->set_duration(t - resolved->enter_time());
- _connect_node_end_time = t;
-
if (_active_nodes.size() == 1) {
+
+ _connect_node_end_time = t;
+
if (_poly_nodes.size() > 0) {
_connect_node = SharedPtr<Node>(new Node());
@@ -170,6 +176,7 @@ MachineBuilder::event(Raul::BeatTime time_offset,
if (is_delay_node(_connect_node) && _connect_node->duration() == 0
&& _connect_node->outgoing_edges().size() == 1
&& (*_connect_node->outgoing_edges().begin())->head() == resolved) {
+ cerr << "TRIMMING\n";
_connect_node->outgoing_edges().clear();
assert(_connect_node->outgoing_edges().empty());
_connect_node->set_enter_action(resolved->enter_action());
diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp
index 7424f31..14632f0 100644
--- a/src/engine/machina/Machine.hpp
+++ b/src/engine/machina/Machine.hpp
@@ -39,8 +39,9 @@ public:
void activate() { _is_activated = true; }
void deactivate() { _is_activated = false; }
- bool is_empty() { return _nodes.empty(); }
- bool is_finished() { return _is_finished; }
+ bool is_empty() { return _nodes.empty(); }
+ bool is_finished() { return _is_finished; }
+ bool is_activated() { return _is_activated; }
void add_node(SharedPtr<Node> node);
void remove_node(SharedPtr<Node> node);
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp
index f2a8ebf..134b885 100644
--- a/src/gui/MachinaCanvas.cpp
+++ b/src/gui/MachinaCanvas.cpp
@@ -230,7 +230,7 @@ MachinaCanvas::build(SharedPtr<Machina::Machine> machine)
Gtk::Main::iteration(false);
}
- //arrange();
+ arrange();
/*
while (Gtk::Main::events_pending())
Gtk::Main::iteration(false);
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index cf0b07f..3ddb13f 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -235,7 +235,7 @@ void
MachinaGUI::update_toolbar()
{
_record_button->set_active(_engine->driver()->recording());
- _play_button->set_active(true);
+ _play_button->set_active(_engine->machine()->is_activated());
_bpm_spinbutton->set_sensitive(_bpm_radiobutton->get_active());
_quantize_spinbutton->set_sensitive(_quantize_checkbutton->get_active());
}
@@ -631,6 +631,7 @@ MachinaGUI::record_toggled()
} else if (_engine->driver()->recording()) {
_engine->driver()->finish_record();
_canvas->build(_engine->machine());
+ update_toolbar();
}
}
@@ -638,8 +639,12 @@ MachinaGUI::record_toggled()
void
MachinaGUI::stop_clicked()
{
- if (_engine->driver()->recording())
+ if (_engine->driver()->recording()) {
_engine->driver()->finish_record();
+ } else {
+ _engine->machine()->deactivate();
+ _engine->machine()->reset();
+ }
update_toolbar();
}
@@ -648,6 +653,10 @@ MachinaGUI::stop_clicked()
void
MachinaGUI::play_toggled()
{
+ if (_play_button->get_active())
+ _engine->machine()->activate();
+ else
+ _engine->machine()->deactivate();
}
diff --git a/src/gui/machina.glade b/src/gui/machina.glade
index 01f8ec1..136d384 100644
--- a/src/gui/machina.glade
+++ b/src/gui/machina.glade
@@ -303,9 +303,10 @@
<child>
<widget class="GtkHBox" id="hbox1">
+ <property name="border_width">4</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">0</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkRadioButton" id="slave_radiobutton">
@@ -328,37 +329,50 @@
</child>
<child>
- <widget class="GtkRadioButton" id="bpm_radiobutton">
+ <widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">BPM: </property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">True</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- <property name="group">slave_radiobutton</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
- <child>
- <widget class="GtkSpinButton" id="bpm_spinbutton">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Set internal tempo</property>
- <property name="can_focus">True</property>
- <property name="climb_rate">1</property>
- <property name="digits">0</property>
- <property name="numeric">False</property>
- <property name="update_policy">GTK_UPDATE_ALWAYS</property>
- <property name="snap_to_ticks">False</property>
- <property name="wrap">False</property>
- <property name="adjustment">120 1 640 1 10 10</property>
+ <child>
+ <widget class="GtkRadioButton" id="bpm_radiobutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">BPM:</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">slave_radiobutton</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkSpinButton" id="bpm_spinbutton">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Set internal tempo</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">0</property>
+ <property name="numeric">False</property>
+ <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="snap_to_ticks">False</property>
+ <property name="wrap">False</property>
+ <property name="adjustment">120 1 640 1 10 10</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
@@ -389,14 +403,15 @@
</child>
<child>
- <widget class="GtkToolItem" id="toolitem2">
+ <widget class="GtkToolItem" id="toolitem3">
<property name="visible">True</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
<child>
- <widget class="GtkHBox" id="hbox2">
+ <widget class="GtkHBox" id="hbox4">
+ <property name="border_width">4</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>