diff options
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/Engine.cpp (renamed from src/engine/machina/Machina.hpp) | 21 | ||||
-rw-r--r-- | src/engine/JackDriver.cpp | 76 | ||||
-rw-r--r-- | src/engine/JackNodeFactory.cpp | 49 | ||||
-rw-r--r-- | src/engine/Loader.cpp | 36 | ||||
-rw-r--r-- | src/engine/Machine.cpp | 12 | ||||
-rw-r--r-- | src/engine/Makefile.am | 2 | ||||
-rw-r--r-- | src/engine/MidiAction.cpp | 6 | ||||
-rw-r--r-- | src/engine/Node.cpp | 8 | ||||
-rw-r--r-- | src/engine/machina/Action.hpp | 8 | ||||
-rw-r--r-- | src/engine/machina/Engine.hpp (renamed from src/engine/machina/JackNodeFactory.hpp) | 32 | ||||
-rw-r--r-- | src/engine/machina/JackDriver.hpp | 20 | ||||
-rw-r--r-- | src/engine/machina/LearnRequest.hpp | 8 | ||||
-rw-r--r-- | src/engine/machina/Loader.hpp | 5 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 16 | ||||
-rw-r--r-- | src/engine/machina/Makefile.am | 5 | ||||
-rw-r--r-- | src/engine/machina/MidiAction.hpp | 3 | ||||
-rw-r--r-- | src/engine/machina/MidiDriver.hpp | 6 | ||||
-rw-r--r-- | src/engine/machina/Node.hpp | 28 | ||||
-rw-r--r-- | src/engine/machina/NodeFactory.hpp | 40 | ||||
-rw-r--r-- | src/engine/machina/types.hpp | 4 |
20 files changed, 147 insertions, 238 deletions
diff --git a/src/engine/machina/Machina.hpp b/src/engine/Engine.cpp index 6cefcc5..a621a8a 100644 --- a/src/engine/machina/Machina.hpp +++ b/src/engine/Engine.cpp @@ -15,14 +15,25 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <list> +#include "machina/Engine.hpp" +#include "machina/JackDriver.hpp" namespace Machina { -class Machina { -private: - std::list<Node> _nodes; -}; + +void +Engine::set_bpm(double bpm) +{ + _driver->set_bpm(bpm); +} + + +void +Engine::set_quantization(double) +{ +} } // namespace Machina + + diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 6dc2153..9236fd9 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -20,14 +20,16 @@ #include "machina/JackDriver.hpp" #include "machina/MidiAction.hpp" +using namespace Raul; + namespace Machina { JackDriver::JackDriver() : _input_port(NULL) , _output_port(NULL) - , _current_cycle_start(0) - , _current_cycle_nframes(0) + , _cycle_time(1/48000.0, 120.0) + , _bpm(120.0) { } @@ -38,6 +40,9 @@ JackDriver::attach(const std::string& client_name) Raul::JackDriver::attach(client_name); if (jack_client()) { + + _cycle_time.set_tick_rate(1/(double)sample_rate()); + _input_port = jack_port_register(jack_client(), "in", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, @@ -73,17 +78,6 @@ JackDriver::detach() } -Timestamp -JackDriver::stamp_to_offset(Timestamp stamp) -{ - assert(stamp >= _current_cycle_start); - - Timestamp ret = stamp - _current_cycle_start + _current_cycle_offset; - assert(ret < _current_cycle_offset + _current_cycle_nframes); - return ret; -} - - void JackDriver::process_input(jack_nframes_t nframes) { @@ -131,14 +125,17 @@ JackDriver::process_input(jack_nframes_t nframes) void -JackDriver::write_event(Timestamp time, - size_t size, - const byte* event) +JackDriver::write_event(Raul::BeatTime time, + size_t size, + const byte* event) { - const FrameCount nframes = _current_cycle_nframes; - const FrameCount offset = stamp_to_offset(time); + const TickCount nframes = _cycle_time.length_ticks(); + const TickCount offset = _cycle_time.offset_ticks() + + _cycle_time.beats_to_ticks(time); assert(_output_port); + assert(offset < nframes); + jack_midi_event_write( jack_port_get_buffer(_output_port, nframes), offset, event, size, nframes); @@ -151,8 +148,11 @@ JackDriver::on_process(jack_nframes_t nframes) using namespace std; //std::cerr << "> ======================================================\n"; - _current_cycle_offset = 0; - _current_cycle_nframes = nframes; + _cycle_time.set_bpm(_bpm.get()); + + // Start time set at end of previous cycle + _cycle_time.set_offset(0); + _cycle_time.set_length(nframes); assert(_output_port); jack_midi_clear_buffer(jack_port_get_buffer(_output_port, nframes), nframes); @@ -166,34 +166,36 @@ JackDriver::on_process(jack_nframes_t nframes) while (true) { - const FrameCount run_duration = _machine->run(_current_cycle_nframes); + const BeatCount run_dur_beats = _machine->run(_cycle_time); + const TickCount run_dur_ticks = _cycle_time.beats_to_ticks(run_dur_beats); // Machine didn't run at all (empty, or no initial states) - if (run_duration == 0) { + if (run_dur_ticks == 0) { _machine->reset(); // Try again next cycle - _current_cycle_start = 0; + _cycle_time.set_start(0); return; - } - // Machine ran for portion of cycle - else if (run_duration < _current_cycle_nframes) { - const Timestamp finish_time = _machine->time(); - const FrameCount finish_offset = stamp_to_offset(finish_time); - - if (finish_offset >= _current_cycle_nframes) - break; - - _current_cycle_offset = stamp_to_offset(finish_time); - _current_cycle_nframes -= _current_cycle_offset; - _current_cycle_start = 0; + // Machine ran for portion of cycle (finished) + } else if (run_dur_ticks < _cycle_time.length_ticks()) { + const TickCount finish_offset = _cycle_time.offset_ticks() + run_dur_ticks; + assert(finish_offset < nframes); + + _cycle_time.set_start(0); + _cycle_time.set_length(nframes - finish_offset); + _cycle_time.set_offset(finish_offset); + _machine->reset(); // Machine ran for entire cycle } else { - if (_machine->is_finished()) + if (_machine->is_finished()) { _machine->reset(); + _cycle_time.set_start(0); + } else { + _cycle_time.set_start( + _cycle_time.start_ticks() + _cycle_time.length_ticks()); + } - _current_cycle_start += _current_cycle_nframes; break; } } diff --git a/src/engine/JackNodeFactory.cpp b/src/engine/JackNodeFactory.cpp deleted file mode 100644 index 826d205..0000000 --- a/src/engine/JackNodeFactory.cpp +++ /dev/null @@ -1,49 +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 - */ - -#include "machina/JackNodeFactory.hpp" -#include "machina/MidiAction.hpp" -#include "machina/Node.hpp" -#include "machina/JackDriver.hpp" - -namespace Machina { - - -SharedPtr<Node> -JackNodeFactory::create_node(Node::ID, byte /*note*/, FrameCount duration) -{ - // FIXME: obviously leaks like a sieve - - //size_t event_size = 3; - //static const byte note_on[3] = { 0x80, note, 0x40 }; - - Node* n = new Node(duration); - /*SharedPtr<MidiAction> a_enter = MidiAction::create(event_size, note_on); - - - static const byte note_off[3] = { 0x90, note, 0x40 }; - SharedPtr<MidiAction> a_exit = MidiAction::create(event_size, note_off); - - n->add_enter_action(a_enter); - n->add_exit_action(a_exit); -*/ - return SharedPtr<Node>(n); -} - - -} // namespace Machina - diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp index 3b58537..ec884eb 100644 --- a/src/engine/Loader.cpp +++ b/src/engine/Loader.cpp @@ -25,7 +25,6 @@ #include "machina/Node.hpp" #include "machina/Edge.hpp" #include "machina/Machine.hpp" -#include "machina/NodeFactory.hpp" using namespace Raul; using std::cerr; using std::cout; using std::endl; @@ -33,29 +32,8 @@ using std::cerr; using std::cout; using std::endl; namespace Machina { -/* -// FIXME: remove -Node* create_debug_node(const Node::ID& id, FrameCount duration) -{ - // leaks like a sieve, obviously - - Node* n = new Node(duration); - PrintAction* a_enter = new PrintAction(string("\t> ") + id); - PrintAction* a_exit = new PrintAction(string("\t< ") + id); - - n->add_enter_action(a_enter); - n->add_exit_action(a_exit); - - cerr << "dur: " << duration << endl; - - return n; -} -*/ - -Loader::Loader(SharedPtr<NodeFactory> node_factory, - SharedPtr<Namespaces> namespaces) - : _node_factory(node_factory) - , _namespaces(namespaces) +Loader::Loader(SharedPtr<Namespaces> namespaces) + : _namespaces(namespaces) { if (!_namespaces) _namespaces = SharedPtr<Namespaces>(new Namespaces()); @@ -123,16 +101,19 @@ Loader::load(const Glib::ustring& filename) //cout << "Initial: " << node_name << ": " << midi_note << " - " << duration << endl; + cerr << "FIXME: load\n"; +/* SharedPtr<Node> node = SharedPtr<Node>(_node_factory->create_node( node_name, strtol(midi_note.c_str(), NULL, 10), strtol(duration.c_str(), NULL, 10))); - + node->set_initial(true); //machine->add_node(string(node_name).substr(1), node); // (chop leading "#") machine->add_node(node); created.insert(std::make_pair(node_uri.collate_key(), node)); + */ raptor_free_uri(node_raptor_uri); free(node_name); @@ -163,18 +144,21 @@ Loader::load(const Glib::ustring& filename) raptor_uri_to_relative_uri_string(document_raptor_uri, node_raptor_uri); + cerr << "FIXME: load (2)\n"; + /* SharedPtr<Node> node = SharedPtr<Node>(_node_factory->create_node( node_name, strtol(midi_note.c_str(), NULL, 10), strtol(duration.c_str(), NULL, 10))); + if (created.find(node_uri) == created.end()) { //cout << "Node: " << node_name << ": " << midi_note << " - " << duration << endl; //machine->add_node(string(node_name).substr(1), node); // (chop leading "#") machine->add_node(node); created.insert(std::make_pair(node_uri.collate_key(), node)); } - + */ raptor_free_uri(node_raptor_uri); free(node_name); } diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index 142ea37..bbe343c 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -110,8 +110,8 @@ Machine::exit_node(const SharedPtr<Node> node) * machine actually finished on (so it can be restarted immediately * with sample accuracy if necessary). */ -FrameCount -Machine::run(FrameCount nframes) +BeatCount +Machine::run(const Raul::TimeSlice& time) { using namespace std; if (_is_finished) { @@ -119,7 +119,7 @@ Machine::run(FrameCount nframes) return 0; } - const FrameCount cycle_end = _time + nframes; + const BeatCount cycle_end = _time + time.length_beats(); //std::cerr << "Start: " << _time << std::endl; @@ -146,7 +146,7 @@ Machine::run(FrameCount nframes) } } - FrameCount this_time = 0; + BeatCount this_time = 0; while (true) { @@ -166,7 +166,7 @@ Machine::run(FrameCount nframes) // Earliest active state ends in the future, done this cycle } else { _time = cycle_end; - this_time = nframes; // ran the entire cycle + this_time = time.length_beats(); // ran the entire cycle break; } @@ -174,7 +174,7 @@ Machine::run(FrameCount nframes) //std::cerr << "Done: " << this_time << std::endl; - assert(this_time <= nframes); + assert(this_time <= time.length_beats()); return this_time; } diff --git a/src/engine/Makefile.am b/src/engine/Makefile.am index c21935f..833d39c 100644 --- a/src/engine/Makefile.am +++ b/src/engine/Makefile.am @@ -14,4 +14,4 @@ libmachina_la_SOURCES = \ MidiAction.cpp \ JackDriver.h \ JackDriver.cpp \ - JackNodeFactory.cpp + Engine.cpp diff --git a/src/engine/MidiAction.cpp b/src/engine/MidiAction.cpp index aca4b75..b1dfa95 100644 --- a/src/engine/MidiAction.cpp +++ b/src/engine/MidiAction.cpp @@ -91,18 +91,16 @@ MidiAction::set_event(size_t size, const byte* new_event) * Safe to call concurrently with set_event. */ void -MidiAction::execute(Timestamp time) +MidiAction::execute(Raul::BeatTime time) { const byte* const event = _event.get(); - using namespace std; - if (event) { SharedPtr<MidiDriver> driver = _driver.lock(); if (driver) driver->write_event(time, _size, event); } else { - cerr << "NULL MIDI ACTION"; + std::cerr << "NULL MIDI ACTION"; } } diff --git a/src/engine/Node.cpp b/src/engine/Node.cpp index c0e0ce6..a7aa453 100644 --- a/src/engine/Node.cpp +++ b/src/engine/Node.cpp @@ -23,7 +23,7 @@ namespace Machina { -Node::Node(FrameCount duration, bool initial) +Node::Node(BeatCount duration, bool initial) : _is_initial(initial) , _is_active(false) , _enter_time(0) @@ -63,7 +63,7 @@ Node::remove_exit_action(SharedPtr<Action> /*action*/) //using namespace std; void -Node::enter(Timestamp time) +Node::enter(BeatTime time) { //cerr << "ENTER " << time << endl; _is_active = true; @@ -74,7 +74,7 @@ Node::enter(Timestamp time) void -Node::exit(Timestamp time) +Node::exit(BeatTime time) { //cerr << "EXIT " << time << endl; if (_exit_action) @@ -111,7 +111,7 @@ Node::write_state(Raul::RDFWriter& writer) writer.write(_id, RdfId(RdfId::RESOURCE, "machina:duration"), - Raul::Atom((int)_duration)); + Raul::Atom((float)_duration)); } diff --git a/src/engine/machina/Action.hpp b/src/engine/machina/Action.hpp index 984a1a0..2bffaa3 100644 --- a/src/engine/machina/Action.hpp +++ b/src/engine/machina/Action.hpp @@ -21,17 +21,16 @@ #include <string> #include <iostream> #include <raul/Deletable.h> +#include <raul/TimeSlice.h> #include "types.hpp" namespace Machina { /** An Action, executed on entering or exiting of a state. - * - * Actions do not have time as a property. */ struct Action : public Raul::Deletable { - virtual void execute(Timestamp /*time*/) {} + virtual void execute(Raul::BeatTime /*time*/) {} }; @@ -39,7 +38,8 @@ class PrintAction : public Action { public: PrintAction(const std::string& msg) : _msg(msg) {} - void execute(Timestamp time) { std::cout << "t=" << time << ": " << _msg << std::endl; } + void execute(Raul::BeatTime time) + { std::cout << "t=" << time << ": " << _msg << std::endl; } private: std::string _msg; diff --git a/src/engine/machina/JackNodeFactory.hpp b/src/engine/machina/Engine.hpp index 017cc6d..fcb75d3 100644 --- a/src/engine/machina/JackNodeFactory.hpp +++ b/src/engine/machina/Engine.hpp @@ -12,32 +12,40 @@ * * 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 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef MACHINA_JACKNODEFACTORY_HPP -#define MACHINA_JACKNODEFACTORY_HPP +#ifndef MACHINA_ENGINE_HPP +#define MACHINA_ENGINE_HPP -#include <raul/WeakPtr.h> -#include "NodeFactory.hpp" +#include <raul/SharedPtr.h> namespace Machina { +class Machine; class JackDriver; -class JackNodeFactory : public NodeFactory { +class Engine { public: - JackNodeFactory(WeakPtr<JackDriver> driver) : _driver(driver) {} + Engine(SharedPtr<JackDriver> driver, SharedPtr<Machine> machine) + : _driver(driver) + , _machine(machine) + {} + + SharedPtr<JackDriver> driver() { return _driver; } + SharedPtr<Machine> machine() { return _machine; } + + void set_bpm(double bpm); + + void set_quantization(double beat_fraction); - SharedPtr<Node> create_node(Node::ID id, - unsigned char note, - FrameCount duration); private: - WeakPtr<JackDriver> _driver; + SharedPtr<JackDriver> _driver; + SharedPtr<Machine> _machine; }; } // namespace Machina -#endif // MACHINA_JACKNODEFACTORY_HPP +#endif // MACHINA_ENGINE_HPP diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp index e1f809f..e52af88 100644 --- a/src/engine/machina/JackDriver.hpp +++ b/src/engine/machina/JackDriver.hpp @@ -20,6 +20,7 @@ #include <raul/JackDriver.h> #include <raul/SharedPtr.h> +#include <raul/DoubleBuffer.h> #include <jack/midiport.h> #include "Machine.hpp" #include "MidiDriver.hpp" @@ -46,19 +47,13 @@ public: void set_machine(SharedPtr<Machine> machine) { _machine = machine; } - // Audio context - Timestamp cycle_start() { return _current_cycle_start; } - FrameCount cycle_length() { return _current_cycle_nframes; } - - void write_event(Timestamp time, + void write_event(Raul::BeatTime time, size_t size, const unsigned char* event); -private: - // Audio context - Timestamp subcycle_offset() { return _current_cycle_offset; } - Timestamp stamp_to_offset(Timestamp stamp); + void set_bpm(double bpm) { _bpm.set(bpm); } +private: void process_input(jack_nframes_t nframes); virtual void on_process(jack_nframes_t nframes); @@ -66,9 +61,10 @@ private: jack_port_t* _input_port; jack_port_t* _output_port; - Timestamp _current_cycle_start; ///< in machine relative time - Timestamp _current_cycle_offset; ///< for split cycles - FrameCount _current_cycle_nframes; + + Raul::TimeSlice _cycle_time; + + Raul::DoubleBuffer<double> _bpm; }; diff --git a/src/engine/machina/LearnRequest.hpp b/src/engine/machina/LearnRequest.hpp index 60f1b27..f485560 100644 --- a/src/engine/machina/LearnRequest.hpp +++ b/src/engine/machina/LearnRequest.hpp @@ -44,7 +44,7 @@ public: } // Add the learned actions to the node - void finish(Timestamp time) + void finish(BeatTime time) { _node->add_enter_action(_enter_action); _node->add_exit_action(_exit_action); @@ -52,8 +52,8 @@ public: std::cerr << "LEARN DURATION: " << _node->duration() << std::endl; } - void start(Timestamp time) { _started = true; _start_time = time; } - bool started() { return _started; } + void start(BeatTime time) { _started = true; _start_time = time; } + bool started() { return _started; } const SharedPtr<Node>& node() { return _node; } const SharedPtr<MidiAction>& enter_action() { return _enter_action; } @@ -69,7 +69,7 @@ private: } bool _started; - Timestamp _start_time; + BeatTime _start_time; SharedPtr<Node> _node; SharedPtr<MidiAction> _enter_action; SharedPtr<MidiAction> _exit_action; diff --git a/src/engine/machina/Loader.hpp b/src/engine/machina/Loader.hpp index c3ce013..af35c56 100644 --- a/src/engine/machina/Loader.hpp +++ b/src/engine/machina/Loader.hpp @@ -28,18 +28,15 @@ using Raul::Namespaces; namespace Machina { class Machine; -class NodeFactory; class Loader { public: - Loader(SharedPtr<NodeFactory> node_factory, - SharedPtr<Namespaces> = SharedPtr<Namespaces>()); + Loader(SharedPtr<Namespaces> = SharedPtr<Namespaces>()); SharedPtr<Machine> load(const Glib::ustring& filename); private: - SharedPtr<NodeFactory> _node_factory; SharedPtr<Namespaces> _namespaces; }; diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 3e63530..a7b92c8 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -21,6 +21,7 @@ #include <raul/SharedPtr.h> #include <raul/List.h> #include <raul/RDFWriter.h> +#include <raul/TimeSlice.h> #include "types.hpp" #include "LearnRequest.hpp" #include "Node.hpp" @@ -46,12 +47,11 @@ public: void write_state(Raul::RDFWriter& writer); // Audio context - void reset(); - FrameCount run(FrameCount nframes); + void reset(); + BeatCount run(const Raul::TimeSlice& time); // Any context - FrameCount time() { return _time; } - + Raul::BeatTime time() { return _time; } //LearnRequest pop_learn() { return _pending_learns.pop_front(); } //SharedPtr<LearnRequest> first_learn() { return *_pending_learns.begin(); } @@ -65,10 +65,10 @@ private: SharedPtr<Node> earliest_node() const; void exit_node(const SharedPtr<Node>); - bool _is_activated; - bool _is_finished; - FrameCount _time; - Nodes _nodes; + bool _is_activated; + bool _is_finished; + Raul::BeatTime _time; + Nodes _nodes; //Raul::List<SharedPtr<LearnRequest> > _pending_learns; SharedPtr<LearnRequest> _pending_learn; diff --git a/src/engine/machina/Makefile.am b/src/engine/machina/Makefile.am index 7bdd1fd..1e8c6c3 100644 --- a/src/engine/machina/Makefile.am +++ b/src/engine/machina/Makefile.am @@ -7,8 +7,7 @@ libmachinainclude_HEADERS = \ Machine.hpp \ Loader.hpp \ JackDriver.hpp \ - NodeFactory.hpp \ - JackNodeFactory.hpp \ MidiAction.hpp \ MidiDriver.hpp \ - LearnRequest.hpp + LearnRequest.hpp \ + Engine.hpp diff --git a/src/engine/machina/MidiAction.hpp b/src/engine/machina/MidiAction.hpp index 7dff692..6467659 100644 --- a/src/engine/machina/MidiAction.hpp +++ b/src/engine/machina/MidiAction.hpp @@ -21,6 +21,7 @@ #include <raul/Maid.h> #include <raul/WeakPtr.h> #include <raul/AtomicPtr.h> +#include <raul/TimeSlice.h> #include "types.hpp" #include "Action.hpp" @@ -46,7 +47,7 @@ public: bool set_event(size_t size, const byte* event); - void execute(Timestamp time); + void execute(Raul::BeatTime time); private: MidiAction(size_t size, diff --git a/src/engine/machina/MidiDriver.hpp b/src/engine/machina/MidiDriver.hpp index 7f6dca1..a4d9f51 100644 --- a/src/engine/machina/MidiDriver.hpp +++ b/src/engine/machina/MidiDriver.hpp @@ -30,20 +30,20 @@ public: virtual ~MidiDriver() {} /** Emit a MIDI event at the given time */ - virtual void write_event(Timestamp time, + virtual void write_event(Raul::BeatTime time, size_t size, const unsigned char* event) = 0; /** Beginning of current cycle in absolute time. */ - virtual Timestamp cycle_start() = 0; + //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 FrameCount cycle_length() = 0; + //virtual Raul::TickCount cycle_length() = 0; }; diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp index 10d4ed4..c4d9dee 100644 --- a/src/engine/machina/Node.hpp +++ b/src/engine/machina/Node.hpp @@ -22,12 +22,14 @@ #include <raul/SharedPtr.h> #include <raul/List.h> #include <raul/Stateful.h> -#include "types.hpp" +#include <raul/TimeSlice.h> #include "Action.hpp" namespace Machina { class Edge; +using Raul::BeatCount; +using Raul::BeatTime; /** A node is a state (as in a FSM diagram), or "note". @@ -42,7 +44,7 @@ class Node : public Raul::Stateful, public boost::noncopyable { public: typedef std::string ID; - Node(FrameCount duration=0, bool initial=false); + Node(BeatCount duration=0, bool initial=false); void add_enter_action(SharedPtr<Action> action); void remove_enter_action(SharedPtr<Action> action); @@ -50,21 +52,21 @@ public: void add_exit_action(SharedPtr<Action> action); void remove_exit_action(SharedPtr<Action> action); - void enter(Timestamp time); - void exit(Timestamp time); + void enter(BeatTime time); + void exit(BeatTime time); void add_outgoing_edge(SharedPtr<Edge> edge); void remove_outgoing_edge(SharedPtr<Edge> edge); void write_state(Raul::RDFWriter& writer); - bool is_initial() const { return _is_initial; } - void set_initial(bool i) { _is_initial = i; } - bool is_active() const { return _is_active; } - Timestamp enter_time() const { return _enter_time; } - Timestamp exit_time() const { return _enter_time + _duration; } - FrameCount duration() { return _duration; } - void set_duration(FrameCount d) { _duration = d; } + bool is_initial() const { return _is_initial; } + void set_initial(bool i) { _is_initial = i; } + bool is_active() const { return _is_active; } + BeatTime enter_time() const { return _enter_time; } + BeatTime exit_time() const { return _enter_time + _duration; } + BeatCount duration() { return _duration; } + void set_duration(BeatCount d) { _duration = d; } typedef Raul::List<SharedPtr<Edge> > EdgeList; const EdgeList& outgoing_edges() const { return _outgoing_edges; } @@ -72,8 +74,8 @@ public: private: bool _is_initial; bool _is_active; - Timestamp _enter_time; ///< valid iff _is_active - FrameCount _duration; + BeatTime _enter_time; ///< valid iff _is_active + BeatCount _duration; SharedPtr<Action> _enter_action; SharedPtr<Action> _exit_action; EdgeList _outgoing_edges; diff --git a/src/engine/machina/NodeFactory.hpp b/src/engine/machina/NodeFactory.hpp deleted file mode 100644 index f38fd92..0000000 --- a/src/engine/machina/NodeFactory.hpp +++ /dev/null @@ -1,40 +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_NODEFACTORY_HPP -#define MACHINA_NODEFACTORY_HPP - -#include <raul/SharedPtr.h> -#include "types.hpp" -#include "Node.hpp" - -namespace Machina { - - -class NodeFactory { -public: - virtual ~NodeFactory() {} - - virtual SharedPtr<Node> create_node(Node::ID id, - unsigned char note, - FrameCount duration) = 0; -}; - - -} // namespace Machina - -#endif // MACHINA_NODEFACTORY_HPP diff --git a/src/engine/machina/types.hpp b/src/engine/machina/types.hpp index 1236f65..70eae7d 100644 --- a/src/engine/machina/types.hpp +++ b/src/engine/machina/types.hpp @@ -23,8 +23,8 @@ namespace Machina { -typedef jack_nframes_t FrameCount; -typedef jack_nframes_t Timestamp; +//typedef jack_nframes_t FrameCount; +//typedef jack_nframes_t Timestamp; typedef unsigned char byte; |