diff options
Diffstat (limited to 'src/engine/Engine.cpp')
-rw-r--r-- | src/engine/Engine.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 5da3289..69402a3 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -36,6 +36,7 @@ Engine::load_machine(const Glib::ustring& uri) if (m) { m->activate(); _driver->set_machine(m); + //_driver->machine()->nodes().append(m->nodes()); } // .. and drop it in this thread (to prevent deallocation in the RT thread) @@ -44,6 +45,26 @@ Engine::load_machine(const Glib::ustring& uri) } +/** Load the machine at @a uri, and insert it into the current machine.. + * Safe to call while engine is processing. + */ +SharedPtr<Machine> +Engine::import_machine(const Glib::ustring& uri) +{ + SharedPtr<Machine> old_machine = _driver->machine(); // Hold a reference to current machine.. + + SharedPtr<Machine> m = Loader().load(uri); + if (m) { + m->activate(); + _driver->machine()->nodes().append(m->nodes()); + } + + // .. and drop it in this thread (to prevent deallocation in the RT thread) + + return _driver->machine(); +} + + /** Learn the SMF (MIDI) file at @a uri, and run the resulting machine * (replacing current machine). * Safe to call while engine is processing. @@ -56,7 +77,8 @@ Engine::learn_midi(const Glib::ustring& uri) SharedPtr<SMFDriver> file_driver(new SMFDriver()); SharedPtr<Machine> m = file_driver->learn(uri, 32.0); // FIXME: hardcoded m->activate(); - _driver->set_machine(m); + //_driver->set_machine(m); + _driver->machine()->nodes().append(m->nodes()); // .. and drop it in this thread (to prevent deallocation in the RT thread) |