/* This file is part of Machina. * Copyright (C) 2007 Dave Robillard * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * Machina is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include "machina/Loader.hpp" #include "machina/Engine.hpp" #include "machina/JackDriver.hpp" #include "machina/SMFDriver.hpp" namespace Machina { /** Load the machine at @a uri, and run it (replacing current machine). * Safe to call while engine is processing. */ SharedPtr Engine::load_machine(const Glib::ustring& uri) { SharedPtr old_machine = _driver->machine(); // Hold a reference to current machine.. SharedPtr m = Loader().load(uri); if (m) { m->activate(); _driver->set_machine(m); } // .. and drop it in this thread (to prevent deallocation in the RT thread) return m; } /** Learn the SMF (MIDI) file at @a uri, and run the resulting machine * (replacing current machine). * Safe to call while engine is processing. */ SharedPtr Engine::learn_midi(const Glib::ustring& uri) { SharedPtr old_machine = _driver->machine(); // Hold a reference to current machine.. SharedPtr file_driver(new SMFDriver()); SharedPtr m = file_driver->learn(uri, 32.0); // FIXME: hardcoded m->activate(); _driver->set_machine(m); // .. and drop it in this thread (to prevent deallocation in the RT thread) return m; } void Engine::set_bpm(double bpm) { _driver->set_bpm(bpm); } void Engine::set_quantization(double q) { _driver->set_quantization(q); } } // namespace Machina