aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-13 09:23:42 +0000
committerDavid Robillard <d@drobilla.net>2013-01-13 09:23:42 +0000
commit448d6e329a55848e357d57f8ca225d987627ee08 (patch)
tree0153d22bedf929173b973b98c6840fd010b06aca /src
parent67a8adbc93991acfb688f378f52392995a272fac (diff)
downloadmachina-448d6e329a55848e357d57f8ca225d987627ee08.tar.gz
machina-448d6e329a55848e357d57f8ca225d987627ee08.tar.bz2
machina-448d6e329a55848e357d57f8ca225d987627ee08.zip
Move merge operation to Machine::merge().
Delete unused Engine::import_machine(). git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4956 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/engine/Engine.cpp9
-rw-r--r--src/engine/JackDriver.cpp11
-rw-r--r--src/engine/Machine.cpp15
-rw-r--r--src/engine/MachineBuilder.cpp1
-rw-r--r--src/engine/machina/Engine.hpp2
-rw-r--r--src/engine/machina/Machine.hpp6
-rw-r--r--src/gui/MachinaGUI.cpp1
7 files changed, 22 insertions, 23 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index 90aea9b..7807f87 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -97,15 +97,6 @@ Engine::load_machine_midi(const Glib::ustring& uri,
}
void
-Engine::import_machine(SPtr<Machine> machine)
-{
- _driver->machine()->nodes().insert(machine->nodes().begin(),
- machine->nodes().end());
- // FIXME: thread safe?
- // FIXME: announce
-}
-
-void
Engine::export_midi(const Glib::ustring& filename, Raul::TimeDuration dur)
{
SPtr<Machine> machine = _driver->machine();
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 0276cc5..c56e83d 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -437,16 +437,7 @@ JackDriver::finish_record()
_play_state = PlayState::PLAYING;
SPtr<Machine> machine = _recorder->finish();
_recorder.reset();
- for (const auto& m : machine->nodes()) {
- if (m->is_initial()) {
- for (const auto& e : m->edges()) {
- e->set_tail(_machine->initial_node());
- _machine->initial_node()->edges().insert(e);
- }
- } else {
- _machine->nodes().insert(m);
- }
- }
+ _machine->merge(*machine.get());
}
int
diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp
index a6abcff..b5cfb28 100644
--- a/src/engine/Machine.cpp
+++ b/src/engine/Machine.cpp
@@ -100,6 +100,21 @@ Machine::operator=(const Machine& copy)
return *this;
}
+void
+Machine::merge(const Machine& machine)
+{
+ for (const auto& m : machine.nodes()) {
+ if (m->is_initial()) {
+ for (const auto& e : m->edges()) {
+ e->set_tail(_initial_node);
+ _initial_node->edges().insert(e);
+ }
+ } else {
+ _nodes.insert(m);
+ }
+ }
+}
+
/** Always returns a node, unless there are none */
SPtr<Node>
Machine::random_node()
diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp
index 0a515a4..ff2ee77 100644
--- a/src/engine/MachineBuilder.cpp
+++ b/src/engine/MachineBuilder.cpp
@@ -45,7 +45,6 @@ void
MachineBuilder::reset()
{
_time = TimeStamp(_machine->time().unit()); // = 0
- _initial_node = SPtr<Node>(new Node(_time, true)); // duration 0
_connect_node = _initial_node;
_connect_node_end_time = _time; // = 0
}
diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp
index 7e0c9bc..39974f1 100644
--- a/src/engine/machina/Engine.hpp
+++ b/src/engine/machina/Engine.hpp
@@ -54,8 +54,6 @@ public:
double q,
Raul::TimeDuration dur);
- void import_machine(SPtr<Machine> machine);
-
void export_midi(const Glib::ustring& filename,
Raul::TimeDuration dur);
diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp
index 8a98e4c..d4eccea 100644
--- a/src/engine/machina/Machine.hpp
+++ b/src/engine/machina/Machine.hpp
@@ -51,7 +51,11 @@ public:
*/
Machine(const Machine& copy);
- Machine& operator=(const Machine& other);
+ /** Completely replace this machine's contents with a deep copy. */
+ Machine& operator=(const Machine& copy);
+
+ /** Merge another machine into this machine. */
+ void merge(const Machine& machine);
bool is_empty() { return _nodes.empty(); }
bool is_finished() { return _is_finished; }
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index f95eec2..beb7b3a 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -543,6 +543,7 @@ MachinaGUI::menu_import_midi()
dialog.hide();
machine->reset(NULL, machine->time());
_engine->driver()->set_machine(machine);
+ _canvas->clear();
rebuild_canvas();
} else {
Gtk::MessageDialog msg_dialog(dialog, "Error loading MIDI file",