aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-03-12 01:33:51 +0000
committerDavid Robillard <d@drobilla.net>2007-03-12 01:33:51 +0000
commitee76743c774f64759daef42d416d3fb7bbc4a473 (patch)
tree0b82b468d0433c3d5c1c68d28d3a2f78e32ce104
parent04c6f60d1f1fb94f6a9dca81439026db22ebb88e (diff)
downloadmachina-ee76743c774f64759daef42d416d3fb7bbc4a473.tar.gz
machina-ee76743c774f64759daef42d416d3fb7bbc4a473.tar.bz2
machina-ee76743c774f64759daef42d416d3fb7bbc4a473.zip
Flowcanvas resizing, auto-arrange resizes if necessary.
Per-track SMF reading (raul and machina) git-svn-id: http://svn.drobilla.net/lad/machina@354 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/engine/SMFDriver.cpp6
-rw-r--r--src/engine/machina/SMFDriver.hpp2
-rw-r--r--src/gui/MachinaGUI.cpp28
3 files changed, 29 insertions, 7 deletions
diff --git a/src/engine/SMFDriver.cpp b/src/engine/SMFDriver.cpp
index 181da52..3481222 100644
--- a/src/engine/SMFDriver.cpp
+++ b/src/engine/SMFDriver.cpp
@@ -36,7 +36,7 @@ namespace Machina {
* @return the resulting machine.
*/
SharedPtr<Machine>
-SMFDriver::learn(const Glib::ustring& uri)
+SMFDriver::learn(const Glib::ustring& uri, unsigned track)
{
const string filename = Glib::filename_from_uri(uri);
@@ -51,6 +51,10 @@ SMFDriver::learn(const Glib::ustring& uri)
Raul::SMFReader reader;
reader.open(filename);
+
+ if ( ! reader.seek_to_track(track) )
+ return SharedPtr<Machine>();
+
Raul::BeatTime t = 0;
unsigned char buf[4];
uint32_t ev_size;
diff --git a/src/engine/machina/SMFDriver.hpp b/src/engine/machina/SMFDriver.hpp
index e702534..f5d1229 100644
--- a/src/engine/machina/SMFDriver.hpp
+++ b/src/engine/machina/SMFDriver.hpp
@@ -34,7 +34,7 @@ class Machine;
class SMFDriver : public Raul::SMFWriter,
public boost::enable_shared_from_this<SMFDriver> {
public:
- SharedPtr<Machine> learn(const Glib::ustring& uri);
+ SharedPtr<Machine> learn(const Glib::ustring& uri, unsigned track=1);
void run(SharedPtr<Machine> machine, Raul::BeatTime max_time);
};
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index 1266147..8f8e607 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -445,15 +445,33 @@ MachinaGUI::menu_import_midi()
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+ Gtk::HBox* extra_widget = Gtk::manage(new Gtk::HBox());
+ Gtk::SpinButton* track_sb = Gtk::manage(new Gtk::SpinButton());
+ track_sb->set_increments(1, 10);
+ track_sb->set_range(1, 256);
+ extra_widget->pack_start(*Gtk::manage(new Gtk::Label("")), true, true);
+ extra_widget->pack_start(*Gtk::manage(new Gtk::Label("Track: ")), false, false);
+ extra_widget->pack_start(*track_sb, false, false);
+ dialog.set_extra_widget(*extra_widget);
+ extra_widget->show_all();
+
const int result = dialog.run();
if (result == Gtk::RESPONSE_OK) {
SharedPtr<Machina::SMFDriver> file_driver(new Machina::SMFDriver());
- SharedPtr<Machina::Machine> machine = file_driver->learn(dialog.get_uri());
- machine->activate();
- machine->reset();
- _engine->driver()->set_machine(machine);
- _canvas->build(machine);
+ SharedPtr<Machina::Machine> machine = file_driver->learn(dialog.get_uri(),
+ track_sb->get_value_as_int());
+
+ if (machine) {
+ machine->activate();
+ machine->reset();
+ _engine->driver()->set_machine(machine);
+ _canvas->build(machine);
+ } else {
+ Gtk::MessageDialog msg_dialog(*_main_window, "Error loading MIDI file",
+ false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
+ msg_dialog.run();
+ }
}
}