aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/main.cpp60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index 46cb21c..04d9e6d 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -14,15 +14,19 @@
along with Machina. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "machina_config.h"
#include <signal.h>
+
#include <iostream>
#include <string>
-#include "sord/sordmm.hpp"
+
+#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "machina/Engine.hpp"
#include "machina/Loader.hpp"
#include "machina/Machine.hpp"
#include "machina/URIs.hpp"
+#include "machina_config.h"
+#include "sord/sordmm.hpp"
+
#include "MachinaGUI.hpp"
using namespace std;
@@ -31,49 +35,55 @@ using namespace machina;
int
main(int argc, char** argv)
{
- if (!Glib::thread_supported()) {
- Glib::thread_init();
- }
+ Glib::thread_init();
+ machina::URIs::init();
Sord::World rdf_world;
+ rdf_world.add_prefix("", MACHINA_NS);
+ rdf_world.add_prefix("midi", LV2_MIDI_PREFIX);
- machina::URIs::init();
-
+ Raul::Forge forge;
SPtr<machina::Machine> machine;
+ Raul::TimeUnit beats(TimeUnit::BEATS, MACHINA_PPQN);
+
// Load machine, if given
-#if 0
if (argc >= 2) {
const string filename = argv[1];
- cout << "Building machine from MIDI file " << filename << endl;
- SPtr<machina::SMFDriver> file_driver(new machina::SMFDriver());
-
- if (argc >= 3) {
- float q = strtof(argv[2], NULL);
- cout << "Quantization: " << q << endl;
- machine = file_driver->learn(filename, q);
- } else {
- cout << "No quantization." << endl;
- machine = file_driver->learn(filename);
+ const string ext = filename.substr(filename.length() - 4);
+
+ if (ext == ".ttl") {
+ cout << "Loading machine from " << filename << endl;
+ machine = Loader(forge, rdf_world).load(filename);
+
+ } else if (ext == ".mid") {
+ cout << "Building machine from MIDI file " << filename << endl;
+
+ double q = 0.0;
+ if (argc >= 3) {
+ q = strtod(argv[2], NULL);
+ cout << "Quantization: " << q << endl;
+ }
+
+ machine = Loader(forge, rdf_world).load_midi(
+ filename, q, Raul::TimeDuration(beats, 0, 0));
}
if (!machine) {
- cout << "Not MIDI, attempting to load machine" << endl;
- machine = Loader(rdf_world).load(filename);
+ cerr << "Failed to load machine, exiting" << std::endl;
+ return 1;
}
}
-#endif
- Raul::Forge forge;
if (!machine) {
- machine = SPtr<Machine>(new Machine(TimeUnit(TimeUnit::BEATS, 19200)));
+ machine = SPtr<Machine>(new Machine(beats));
}
std::string driver_name = "smf";
- #ifdef HAVE_JACK
+#ifdef HAVE_JACK
driver_name = "jack";
- #endif
+#endif
// Build engine
SPtr<Driver> driver(Engine::new_driver(forge, driver_name, machine));