diff options
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/Engine.cpp | 3 | ||||
-rw-r--r-- | src/engine/JackDriver.cpp | 11 | ||||
-rw-r--r-- | src/engine/Loader.cpp | 16 | ||||
-rw-r--r-- | src/engine/machina/Engine.hpp | 9 | ||||
-rw-r--r-- | src/engine/machina/JackDriver.hpp | 3 |
5 files changed, 28 insertions, 14 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 31c98f2..2054b56 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -30,7 +30,8 @@ Engine::load_machine(const Glib::ustring& uri) { Loader l; // FIXME: namespaces? SharedPtr<Machine> m = l.load(uri); - _machine = m; + m->activate(); + _driver->set_machine(m); return m; } diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 1056820..a52cd91 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -25,13 +25,16 @@ using namespace Raul; namespace Machina { -JackDriver::JackDriver() - : _input_port(NULL) +JackDriver::JackDriver(SharedPtr<Machine> machine) + : _machine(machine) + , _input_port(NULL) , _output_port(NULL) , _cycle_time(1/48000.0, 120.0) , _bpm(120.0) , _quantization(120.0) { + if (!_machine) + _machine = SharedPtr<Machine>(new Machine()); } @@ -59,6 +62,8 @@ JackDriver::attach(const std::string& client_name) if (!_output_port) std::cerr << "WARNING: Failed to create MIDI output port." << std::endl; + + _machine->activate(); } } @@ -66,6 +71,8 @@ JackDriver::attach(const std::string& client_name) void JackDriver::detach() { + _machine->deactivate(); + if (_input_port) { jack_port_unregister(jack_client(), _input_port); _input_port = NULL; diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp index 078d783..edc4ac4 100644 --- a/src/engine/Loader.cpp +++ b/src/engine/Loader.cpp @@ -57,12 +57,15 @@ Loader::load(const Glib::ustring& uri) rasqal_init(); - //unsigned char* document_uri_str = raptor_uri_filename_to_uri_string(filename.c_str()); - //assert(document_uri_str); - //raptor_uri* document_raptor_uri = raptor_new_uri(document_uri_str); - raptor_uri* document_raptor_uri = raptor_new_uri((const unsigned char*)uri.c_str()); + raptor_uri* base_uri = raptor_new_uri((const unsigned char*)"file:."); - if (!document_raptor_uri) + raptor_uri* document_raptor_uri = raptor_new_uri_relative_to_base( + base_uri, (const unsigned char*)uri.c_str()); + + //raptor_uri* document_raptor_uri = raptor_new_uri_for_retrieval(rel_uri); + //raptor_free_uri(rel_uri); + + if (!document_raptor_uri) return machine; // NULL machine = SharedPtr<Machine>(new Machine()); @@ -210,6 +213,9 @@ Loader::load(const Glib::ustring& uri) //free(document_uri_str); raptor_free_uri(document_raptor_uri); + raptor_free_uri(base_uri); + + machine->reset(); return machine; } diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp index cd4cf27..37aa2db 100644 --- a/src/engine/machina/Engine.hpp +++ b/src/engine/machina/Engine.hpp @@ -20,6 +20,7 @@ #include <glibmm/ustring.h> #include <raul/SharedPtr.h> +#include "machina/JackDriver.hpp" namespace Machina { @@ -29,13 +30,12 @@ class JackDriver; class Engine { public: - Engine(SharedPtr<JackDriver> driver, SharedPtr<Machine> machine) + Engine(SharedPtr<JackDriver> driver) : _driver(driver) - , _machine(machine) - {} + { } SharedPtr<JackDriver> driver() { return _driver; } - SharedPtr<Machine> machine() { return _machine; } + SharedPtr<Machine> machine() { return _driver->machine(); } SharedPtr<Machine> load_machine(const Glib::ustring& uri); @@ -44,7 +44,6 @@ public: private: SharedPtr<JackDriver> _driver; - SharedPtr<Machine> _machine; }; diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp index f78c1f1..91f4106 100644 --- a/src/engine/machina/JackDriver.hpp +++ b/src/engine/machina/JackDriver.hpp @@ -40,11 +40,12 @@ class Node; class JackDriver : public Raul::JackDriver, public Machina::MidiDriver, public boost::enable_shared_from_this<JackDriver> { public: - JackDriver(); + JackDriver(SharedPtr<Machine> machine = SharedPtr<Machine>()); void attach(const std::string& client_name); void detach(); + SharedPtr<Machine> machine() { return _machine; } void set_machine(SharedPtr<Machine> machine) { _machine = machine; } void write_event(Raul::BeatTime time, |