diff options
author | David Robillard <d@drobilla.net> | 2007-03-18 02:11:51 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-03-18 02:11:51 +0000 |
commit | 47f59aaad7a5ab8c189905544a761940ae9f8509 (patch) | |
tree | 67b6ec9ad915de327cda5007c8c1708a1e256c87 /src/engine/machina | |
parent | a716b2c0571f5bdcd817835cecb30cb7a4c745e0 (diff) | |
download | machina-47f59aaad7a5ab8c189905544a761940ae9f8509.tar.gz machina-47f59aaad7a5ab8c189905544a761940ae9f8509.tar.bz2 machina-47f59aaad7a5ab8c189905544a761940ae9f8509.zip |
Improved automata diagram drawing (include notes, use standard initial note notation).
Made compilation without Jack possible.
git-svn-id: http://svn.drobilla.net/lad/machina@363 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/machina')
-rw-r--r-- | src/engine/machina/Driver.hpp | 25 | ||||
-rw-r--r-- | src/engine/machina/Engine.hpp | 11 | ||||
-rw-r--r-- | src/engine/machina/JackDriver.hpp | 12 | ||||
-rw-r--r-- | src/engine/machina/Makefile.am | 7 | ||||
-rw-r--r-- | src/engine/machina/MidiDriver.hpp | 56 | ||||
-rw-r--r-- | src/engine/machina/SMFDriver.hpp | 18 |
6 files changed, 50 insertions, 79 deletions
diff --git a/src/engine/machina/Driver.hpp b/src/engine/machina/Driver.hpp index f2816ba..b900da0 100644 --- a/src/engine/machina/Driver.hpp +++ b/src/engine/machina/Driver.hpp @@ -15,22 +15,29 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef MACHINA_JACKDRIVER_HPP -#define MACHINA_JACKDRIVER_HPP +#ifndef MACHINA_DRIVER_HPP +#define MACHINA_DRIVER_HPP -#include <raul/JackDriver.h> +#include <raul/MIDISink.h> -namespace Machine { +namespace Machina { +class Machine; -class JackDriver : public Raul::JackDriver { + +class Driver : public Raul::MIDISink { public: - JackDriver(SharedPtr<Machine> machine); + Driver(SharedPtr<Machine> machine) : _machine(machine) {} + virtual ~Driver() {} - virtual void set_machine(SharedPtr<Machine> machine); + SharedPtr<Machine> machine() { return _machine; } + virtual void set_machine(SharedPtr<Machine> machine) { _machine = machine; } + + virtual void set_bpm(double bpm) = 0; + virtual void set_quantization(double quantization) = 0; -protected: - virtual void on_process(jack_nframes_t nframes); + virtual void activate() {} + virtual void deactivate() {} private: SharedPtr<Machine> _machine; diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp index 32fab23..82c21ba 100644 --- a/src/engine/machina/Engine.hpp +++ b/src/engine/machina/Engine.hpp @@ -20,22 +20,21 @@ #include <glibmm/ustring.h> #include <raul/SharedPtr.h> -#include "machina/JackDriver.hpp" +#include "machina/Driver.hpp" namespace Machina { class Machine; -class JackDriver; class Engine { public: - Engine(SharedPtr<JackDriver> driver) + Engine(SharedPtr<Driver> driver) : _driver(driver) { } - SharedPtr<JackDriver> driver() { return _driver; } - SharedPtr<Machine> machine() { return _driver->machine(); } + SharedPtr<Driver> driver() { return _driver; } + SharedPtr<Machine> machine() { return _driver->machine(); } SharedPtr<Machine> load_machine(const Glib::ustring& uri); SharedPtr<Machine> learn_midi(const Glib::ustring& uri); @@ -44,7 +43,7 @@ public: void set_quantization(double beat_fraction); private: - SharedPtr<JackDriver> _driver; + SharedPtr<Driver> _driver; }; diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp index 0754741..13005c0 100644 --- a/src/engine/machina/JackDriver.hpp +++ b/src/engine/machina/JackDriver.hpp @@ -18,14 +18,15 @@ #ifndef MACHINA_JACKDRIVER_HPP #define MACHINA_JACKDRIVER_HPP +#include <boost/enable_shared_from_this.hpp> #include <raul/JackDriver.h> #include <raul/SharedPtr.h> #include <raul/DoubleBuffer.h> #include <raul/Semaphore.h> #include <jack/midiport.h> #include "Machine.hpp" -#include "MidiDriver.hpp" -#include <boost/enable_shared_from_this.hpp> +#include "Driver.hpp" + namespace Machina { @@ -38,15 +39,18 @@ class Node; * "Ticks" are individual frames when running under this driver, and all code * in the processing context must be realtime safe (non-blocking). */ -class JackDriver : public Raul::JackDriver, public Machina::MidiDriver, +class JackDriver : public Raul::JackDriver, + public Machina::Driver, public boost::enable_shared_from_this<JackDriver> { public: JackDriver(SharedPtr<Machine> machine = SharedPtr<Machine>()); void attach(const std::string& client_name); void detach(); + + void activate() { Raul::JackDriver::activate(); } + void deactivate() { Raul::JackDriver::deactivate(); } - SharedPtr<Machine> machine() { return _machine; } void set_machine(SharedPtr<Machine> machine); void write_event(Raul::BeatTime time, diff --git a/src/engine/machina/Makefile.am b/src/engine/machina/Makefile.am index 4501028..ff8eab5 100644 --- a/src/engine/machina/Makefile.am +++ b/src/engine/machina/Makefile.am @@ -7,8 +7,11 @@ libmachinainclude_HEADERS = \ Edge.hpp \ Machine.hpp \ Loader.hpp \ - JackDriver.hpp \ MidiAction.hpp \ - MidiDriver.hpp \ + Driver.hpp \ LearnRequest.hpp \ Engine.hpp + +if WITH_JACK + JackDriver.hpp +endif diff --git a/src/engine/machina/MidiDriver.hpp b/src/engine/machina/MidiDriver.hpp deleted file mode 100644 index a4d712c..0000000 --- a/src/engine/machina/MidiDriver.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* This file is part of Machina. - * Copyright (C) 2007 Dave Robillard <http://drobilla.net> - * - * 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 St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MACHINA_MIDIDRIVER_HPP -#define MACHINA_MIDIDRIVER_HPP - -#include <raul/TimeSlice.h> -#include "machina/types.hpp" - -namespace Machina { - -class Node; - - -class MidiDriver : public Raul::MIDISink { -public: - virtual ~MidiDriver() {} - - /** Emit a MIDI event at the given time */ - /*virtual void write_event(Raul::BeatTime time, - size_t size, - const unsigned char* event) = 0; - */ - - /** Beginning of current cycle in absolute time. - */ - //virtual Raul::TickTime cycle_start() = 0; - - /** Length of current cycle in ticks. - * - * A "tick" is the smallest recognizable unit of (discrete) time. - * Ticks could be single audio frames, MIDI clock at a certain ppqn, etc. - */ - //virtual Raul::TickCount cycle_length() = 0; - -}; - - -} // namespace Machina - -#endif // MACHINA_MIDIDRIVER_HPP - diff --git a/src/engine/machina/SMFDriver.hpp b/src/engine/machina/SMFDriver.hpp index 3e74726..0d58db3 100644 --- a/src/engine/machina/SMFDriver.hpp +++ b/src/engine/machina/SMFDriver.hpp @@ -24,7 +24,7 @@ #include <raul/SMFWriter.h> #include <raul/SMFReader.h> #include "machina/types.hpp" -#include "machina/MidiDriver.hpp" +#include "machina/Driver.hpp" namespace Machina { @@ -32,15 +32,29 @@ class Node; class Machine; -class SMFDriver : public Raul::SMFWriter, +class SMFDriver : public Driver, public boost::enable_shared_from_this<SMFDriver> { public: + SMFDriver(SharedPtr<Machine> machine = SharedPtr<Machine>()); + SharedPtr<Machine> learn(const std::string& filename, Raul::BeatTime max_duration=0); SharedPtr<Machine> learn(const std::string& filename, unsigned track, Raul::BeatTime max_duration=0); void run(SharedPtr<Machine> machine, Raul::BeatTime max_time); + + void write_event(Raul::BeatTime time, + size_t ev_size, + const unsigned char* ev) throw (std::logic_error) + { _writer->write_event(time, ev_size, ev); } + + void set_bpm(double /*bpm*/) { } + void set_quantization(double /*quantization*/) { } + + SharedPtr<Raul::SMFWriter> writer() { return _writer; } private: + SharedPtr<Raul::SMFWriter> _writer; + void learn_track(SharedPtr<Machine> machine, Raul::SMFReader& reader, unsigned track, |