aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/Engine.cpp22
-rw-r--r--src/engine/Evolver.cpp7
-rw-r--r--src/engine/JackDriver.cpp2
-rw-r--r--src/engine/JackDriver.hpp (renamed from src/engine/machina/JackDriver.hpp)5
-rw-r--r--src/engine/MachineBuilder.cpp3
-rw-r--r--src/engine/MachineBuilder.hpp (renamed from src/engine/machina/MachineBuilder.hpp)2
-rw-r--r--src/engine/Problem.cpp8
-rw-r--r--src/engine/Problem.hpp (renamed from src/engine/machina/Problem.hpp)0
-rw-r--r--src/engine/Recorder.cpp7
-rw-r--r--src/engine/Recorder.hpp (renamed from src/engine/machina/Recorder.hpp)3
-rw-r--r--src/engine/Schrodinbit.hpp (renamed from src/engine/machina/Schrodinbit.hpp)0
-rw-r--r--src/engine/machina/Engine.hpp7
-rw-r--r--src/engine/machina/Evolver.hpp3
-rw-r--r--src/engine/machina/Node.hpp5
-rw-r--r--src/engine/machina/SMFDriver.hpp11
-rw-r--r--src/gui/NodePropertiesWindow.cpp5
-rw-r--r--src/gui/main.cpp18
-rw-r--r--src/machina.cpp3
18 files changed, 74 insertions, 37 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index b883c2e..30f5b68 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -16,14 +16,34 @@
*/
#include <glibmm/ustring.h>
+
+#include "machina-config.h"
#include "machina/Engine.hpp"
-#include "machina/JackDriver.hpp"
#include "machina/Loader.hpp"
#include "machina/Machine.hpp"
#include "machina/SMFDriver.hpp"
+#ifdef HAVE_JACK
+#include "JackDriver.hpp"
+#endif
namespace Machina {
+SharedPtr<Driver>
+Engine::new_driver(const std::string& name, SharedPtr<Machine> machine)
+{
+ #ifdef HAVE_JACK
+ if (name == "jack") {
+ JackDriver* driver = new JackDriver(machine);
+ driver->attach("machina");
+ return SharedPtr<Driver>(driver);
+ }
+ #endif
+ if (name == "smf")
+ return SharedPtr<Driver>(new SMFDriver(machine));
+
+ std::cerr << "Error: Unknown driver type `" << name << "'" << std::endl;
+ return SharedPtr<Driver>();
+}
/** Load the machine at @a uri, and run it (replacing current machine).
* Safe to call while engine is processing.
diff --git a/src/engine/Evolver.cpp b/src/engine/Evolver.cpp
index 10b2c11..a16f168 100644
--- a/src/engine/Evolver.cpp
+++ b/src/engine/Evolver.cpp
@@ -16,12 +16,15 @@
*/
#include <iostream>
-#include "eugene/Mutation.hpp"
+
#include "eugene/HybridMutation.hpp"
+#include "eugene/Mutation.hpp"
#include "eugene/TournamentSelection.hpp"
+
#include "machina/Evolver.hpp"
#include "machina/Mutation.hpp"
-#include "machina/Problem.hpp"
+
+#include "Problem.hpp"
using namespace std;
using namespace Eugene;
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 55b06e2..e274255 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -19,9 +19,9 @@
#include <iomanip>
#include "machina-config.h"
-#include "machina/JackDriver.hpp"
#include "machina/MidiAction.hpp"
+#include "JackDriver.hpp"
#include "LearnRequest.hpp"
#include "jack_compat.h"
diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/JackDriver.hpp
index 0b2851b..3c98394 100644
--- a/src/engine/machina/JackDriver.hpp
+++ b/src/engine/JackDriver.hpp
@@ -29,8 +29,9 @@
#include "raul/Semaphore.hpp"
#include "raul/SharedPtr.hpp"
-#include "Driver.hpp"
-#include "Machine.hpp"
+#include "machina/Driver.hpp"
+#include "machina/Machine.hpp"
+
#include "Recorder.hpp"
namespace Machina {
diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp
index 946b7f5..0c02c7c 100644
--- a/src/engine/MachineBuilder.cpp
+++ b/src/engine/MachineBuilder.cpp
@@ -23,10 +23,11 @@
#include "machina/Edge.hpp"
#include "machina/Machine.hpp"
-#include "machina/MachineBuilder.hpp"
#include "machina/MidiAction.hpp"
#include "machina/Node.hpp"
+#include "MachineBuilder.hpp"
+
using namespace std;
using namespace Raul;
diff --git a/src/engine/machina/MachineBuilder.hpp b/src/engine/MachineBuilder.hpp
index d98d91c..ad106c1 100644
--- a/src/engine/machina/MachineBuilder.hpp
+++ b/src/engine/MachineBuilder.hpp
@@ -19,7 +19,9 @@
#define MACHINA_MACHINEBUILDER_HPP
#include <list>
+
#include "raul/SharedPtr.hpp"
+#include "raul/TimeStamp.hpp"
namespace Machina {
diff --git a/src/engine/Problem.cpp b/src/engine/Problem.cpp
index c59088c..4824c07 100644
--- a/src/engine/Problem.cpp
+++ b/src/engine/Problem.cpp
@@ -21,14 +21,16 @@
#include <set>
#include <vector>
#include <iostream>
-#include "machina/Problem.hpp"
-#include "machina/Machine.hpp"
+
+#include "eugene/Problem.hpp"
#include "machina/ActionFactory.hpp"
#include "machina/Edge.hpp"
+#include "machina/Machine.hpp"
#include "raul/SMFReader.hpp"
#include "raul/midi_events.h"
-#include "eugene/Problem.hpp"
+
#include "machina-config.h"
+#include "Problem.hpp"
using namespace std;
diff --git a/src/engine/machina/Problem.hpp b/src/engine/Problem.hpp
index 182d61a..182d61a 100644
--- a/src/engine/machina/Problem.hpp
+++ b/src/engine/Problem.hpp
diff --git a/src/engine/Recorder.cpp b/src/engine/Recorder.cpp
index d134d25..a577368 100644
--- a/src/engine/Recorder.cpp
+++ b/src/engine/Recorder.cpp
@@ -15,10 +15,11 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <iostream>
#include <ios>
-#include "machina/Recorder.hpp"
-#include "machina/MachineBuilder.hpp"
+#include <iostream>
+
+#include "MachineBuilder.hpp"
+#include "Recorder.hpp"
using namespace std;
using namespace Raul;
diff --git a/src/engine/machina/Recorder.hpp b/src/engine/Recorder.hpp
index 623dbfe..fcb7e7d 100644
--- a/src/engine/machina/Recorder.hpp
+++ b/src/engine/Recorder.hpp
@@ -21,7 +21,8 @@
#include "raul/Slave.hpp"
#include "raul/SharedPtr.hpp"
#include "raul/EventRingBuffer.hpp"
-#include "Machine.hpp"
+
+#include "machina/Machine.hpp"
namespace Machina {
diff --git a/src/engine/machina/Schrodinbit.hpp b/src/engine/Schrodinbit.hpp
index 7fe1825..7fe1825 100644
--- a/src/engine/machina/Schrodinbit.hpp
+++ b/src/engine/Schrodinbit.hpp
diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp
index 355a50f..a8a7c9d 100644
--- a/src/engine/machina/Engine.hpp
+++ b/src/engine/machina/Engine.hpp
@@ -18,8 +18,12 @@
#ifndef MACHINA_ENGINE_HPP
#define MACHINA_ENGINE_HPP
+#include <string>
+
#include <glibmm/ustring.h>
+
#include "raul/SharedPtr.hpp"
+
#include "machina/Driver.hpp"
#include "machina/Loader.hpp"
@@ -39,6 +43,9 @@ public:
Redland::World& rdf_world() { return _rdf_world; }
+ static SharedPtr<Driver> new_driver(const std::string& name,
+ SharedPtr<Machine> machine);
+
SharedPtr<Driver> driver() { return _driver; }
SharedPtr<Machine> machine() { return _driver->machine(); }
diff --git a/src/engine/machina/Evolver.hpp b/src/engine/machina/Evolver.hpp
index 013067d..b633bfc 100644
--- a/src/engine/machina/Evolver.hpp
+++ b/src/engine/machina/Evolver.hpp
@@ -18,10 +18,11 @@
#ifndef MACHINA_EVOLVER_HPP
#define MACHINA_EVOLVER_HPP
+#include "eugene/GAImpl.hpp"
#include "raul/SharedPtr.hpp"
#include "raul/Thread.hpp"
#include "raul/TimeStamp.hpp"
-#include "eugene/GAImpl.hpp"
+
#include "Schrodinbit.hpp"
namespace Eugene { template <typename G> class HybridMutation; }
diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp
index 7d90265..730c82b 100644
--- a/src/engine/machina/Node.hpp
+++ b/src/engine/machina/Node.hpp
@@ -18,10 +18,11 @@
#ifndef MACHINA_NODE_HPP
#define MACHINA_NODE_HPP
-#include "raul/SharedPtr.hpp"
#include "raul/List.hpp"
-#include "raul/Stateful.hpp"
#include "raul/MIDISink.hpp"
+#include "raul/SharedPtr.hpp"
+#include "raul/Stateful.hpp"
+
#include "Action.hpp"
#include "Schrodinbit.hpp"
diff --git a/src/engine/machina/SMFDriver.hpp b/src/engine/machina/SMFDriver.hpp
index 8a22aaa..d66bfa3 100644
--- a/src/engine/machina/SMFDriver.hpp
+++ b/src/engine/machina/SMFDriver.hpp
@@ -20,12 +20,15 @@
#include <boost/enable_shared_from_this.hpp>
#include <glibmm/ustring.h>
-#include "raul/SharedPtr.hpp"
-#include "raul/SMFWriter.hpp"
+
#include "raul/SMFReader.hpp"
-#include "machina/types.hpp"
+#include "raul/SMFWriter.hpp"
+#include "raul/SharedPtr.hpp"
+
#include "machina/Driver.hpp"
-#include "machina/MachineBuilder.hpp"
+#include "machina/types.hpp"
+
+#include "MachineBuilder.hpp"
namespace Machina {
diff --git a/src/gui/NodePropertiesWindow.cpp b/src/gui/NodePropertiesWindow.cpp
index 2c8ecc2..a5a28a7 100644
--- a/src/gui/NodePropertiesWindow.cpp
+++ b/src/gui/NodePropertiesWindow.cpp
@@ -40,8 +40,7 @@ NodePropertiesWindow::NodePropertiesWindow(BaseObjectType* cobject, const Glib::
xml->get_widget("node_properties_ok_button", _ok_button);
_apply_button->signal_clicked().connect(sigc::mem_fun(this, &NodePropertiesWindow::apply_clicked));
- _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &NodePropertiesWindow::cancel_clicked));
- _ok_button->signal_clicked().connect(sigc::mem_fun(this, &NodePropertiesWindow::ok_clicked));
+ _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &NodePropertiesWindow::cancel_clicked)); _ok_button->signal_clicked().connect(sigc::mem_fun(this, &NodePropertiesWindow::ok_clicked));
}
@@ -64,7 +63,7 @@ NodePropertiesWindow::apply_clicked()
action->event()[1] = note;
}
- double duration_dbl = _duration_spinbutton->get_value();
+ const double duration_dbl = _duration_spinbutton->get_value();
TimeStamp duration(TimeUnit(TimeUnit::BEATS, 19200), duration_dbl);
_node->set_duration(duration);
_node->set_changed();
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index 58c8f25..5d5dedc 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -27,10 +27,6 @@
#include "machina/SMFDriver.hpp"
#include "MachinaGUI.hpp"
-#ifdef HAVE_JACK
-#include "machina/JackDriver.hpp"
-#endif
-
using namespace std;
using namespace Machina;
@@ -71,15 +67,13 @@ main(int argc, char** argv)
if (!machine)
machine = SharedPtr<Machine>(new Machine(TimeUnit(TimeUnit::BEATS, 19200)));
- // Build engine
- SharedPtr<Driver> driver;
-#ifdef HAVE_JACK
- driver = SharedPtr<Driver>(new JackDriver(machine));
- ((JackDriver*)driver.get())->attach("machina");
-#endif
- if (!driver)
- driver = SharedPtr<Driver>(new SMFDriver(machine));
+ std::string driver_name = "smf";
+ #ifdef HAVE_JACK
+ driver_name = "jack";
+ #endif
+ // Build engine
+ SharedPtr<Driver> driver(Engine::new_driver(driver_name, machine));
SharedPtr<Engine> engine(new Engine(driver, rdf_world));
Gnome::Canvas::init();
diff --git a/src/machina.cpp b/src/machina.cpp
index 93815a0..11148a9 100644
--- a/src/machina.cpp
+++ b/src/machina.cpp
@@ -22,7 +22,6 @@
#include "machina/Action.hpp"
#include "machina/Edge.hpp"
#include "machina/Engine.hpp"
-#include "machina/JackDriver.hpp"
#include "machina/Machine.hpp"
#include "machina/MidiAction.hpp"
#include "machina/Node.hpp"
@@ -30,6 +29,8 @@
#include "machina/Problem.hpp"
#endif
+#include "JackDriver.hpp"
+
using namespace std;
using namespace Machina;