aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-25 06:08:54 +0000
committerDavid Robillard <d@drobilla.net>2007-02-25 06:08:54 +0000
commitd288ce4b8180e4c79f61bed85f0fa5d4cd36acc3 (patch)
treecc3ce435309750f3539efade34aa2655271e79ed /src
parent9d657891ea68ab979bb8c1877bfea656db0bdb1e (diff)
downloadmachina-d288ce4b8180e4c79f61bed85f0fa5d4cd36acc3.tar.gz
machina-d288ce4b8180e4c79f61bed85f0fa5d4cd36acc3.tar.bz2
machina-d288ce4b8180e4c79f61bed85f0fa5d4cd36acc3.zip
Command line app loads again.
Loading fixes, works now (except init is messed up). git-svn-id: http://svn.drobilla.net/lad/machina@339 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/engine/Engine.cpp3
-rw-r--r--src/engine/JackDriver.cpp11
-rw-r--r--src/engine/Loader.cpp16
-rw-r--r--src/engine/machina/Engine.hpp9
-rw-r--r--src/engine/machina/JackDriver.hpp3
-rw-r--r--src/gui/main.cpp7
-rw-r--r--src/main.cpp17
7 files changed, 37 insertions, 29 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,
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index 9928a90..4e4bc07 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -34,16 +34,11 @@ main(int argc, char** argv)
SharedPtr<JackDriver> driver(new JackDriver());
- SharedPtr<Machina::Machine> m(new Machine());
-
- m->activate();
-
MidiAction::set_driver(driver);
- driver->set_machine(m);
driver->attach("machina");
- SharedPtr<Engine> engine(new Engine(driver, m));
+ SharedPtr<Engine> engine(new Engine(driver));
// Launch GUI
try {
diff --git a/src/main.cpp b/src/main.cpp
index 4284456..9250738 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,7 +22,6 @@
#include "machina/Node.hpp"
#include "machina/Action.hpp"
#include "machina/Edge.hpp"
-#include "machina/Loader.hpp"
#include "machina/JackDriver.hpp"
#include "machina/MidiAction.hpp"
@@ -53,18 +52,18 @@ main(int argc, char** argv)
return -1;
}
- SharedPtr<JackDriver> driver(new JackDriver());
+ SharedPtr<JackDriver> driver(new JackDriver());
MidiAction::set_driver(driver);
- Loader l;
+ Engine engine(driver);
- SharedPtr<Machine> m = l.load(argv[1]);
+ // FIXME: Would be nice if this could take URIs on the cmd line
+ char* uri = (char*)calloc(6 + strlen(argv[1]), sizeof(char));
+ strcpy(uri, "file:");
+ strcat(uri, argv[1]);
+ engine.load_machine(uri);
+ free(uri);
- m->activate();
-
- Engine engine(driver, m);
-
- driver->set_machine(m);
driver->attach("machina");
signal(SIGINT, catch_int);