From da3ac16cbfbf66edebe929f8d9bf7d76ab24dd74 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 11 Feb 2007 01:26:07 +0000 Subject: Moved Maid from Ingen to Raul. Working machina MIDI learn, fixes, etc, etc. git-svn-id: http://svn.drobilla.net/lad/machina@302 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/machina/Action.hpp | 5 ++--- src/engine/machina/JackDriver.hpp | 8 +------- src/engine/machina/Machine.hpp | 16 +++++++++++++--- src/engine/machina/Makefile.am | 3 ++- src/engine/machina/MidiAction.hpp | 22 +++++++++++++++++----- src/engine/machina/Node.hpp | 22 +++++++++++----------- 6 files changed, 46 insertions(+), 30 deletions(-) (limited to 'src/engine/machina') diff --git a/src/engine/machina/Action.hpp b/src/engine/machina/Action.hpp index feb0e0b..984a1a0 100644 --- a/src/engine/machina/Action.hpp +++ b/src/engine/machina/Action.hpp @@ -20,6 +20,7 @@ #include #include +#include #include "types.hpp" namespace Machina { @@ -29,9 +30,7 @@ namespace Machina { * * Actions do not have time as a property. */ -struct Action { - virtual ~Action() {} - +struct Action : public Raul::Deletable { virtual void execute(Timestamp /*time*/) {} }; diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp index 9a72a62..e1f809f 100644 --- a/src/engine/machina/JackDriver.hpp +++ b/src/engine/machina/JackDriver.hpp @@ -50,8 +50,6 @@ public: Timestamp cycle_start() { return _current_cycle_start; } FrameCount cycle_length() { return _current_cycle_nframes; } - void learn(SharedPtr node); - void write_event(Timestamp time, size_t size, const unsigned char* event); @@ -66,13 +64,9 @@ private: SharedPtr _machine; - SharedPtr _learn_node; - SharedPtr _learn_enter_action; - SharedPtr _learn_exit_action; - jack_port_t* _input_port; jack_port_t* _output_port; - Timestamp _current_cycle_start; + Timestamp _current_cycle_start; ///< in machine relative time Timestamp _current_cycle_offset; ///< for split cycles FrameCount _current_cycle_nframes; }; diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 4036ef3..b53f55c 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -18,11 +18,10 @@ #ifndef MACHINA_MACHINE_HPP #define MACHINA_MACHINE_HPP -#include -#include #include #include #include "types.hpp" +#include "LearnRequest.hpp" #include "Node.hpp" namespace Machina { @@ -37,16 +36,24 @@ public: void activate() { _is_activated = true; } void deactivate() { _is_activated = false; } + bool is_empty() { return _nodes.empty(); } bool is_finished() { return _is_finished; } void add_node(SharedPtr node); + void learn(SharedPtr learn); // Audio context void reset(); - bool run(FrameCount nframes); + FrameCount run(FrameCount nframes); // Any context FrameCount time() { return _time; } + + + //LearnRequest pop_learn() { return _pending_learns.pop_front(); } + //SharedPtr first_learn() { return *_pending_learns.begin(); } + SharedPtr pending_learn() { return _pending_learn; } + void clear_pending_learn() { _pending_learn.reset(); } private: typedef Raul::List > Nodes; @@ -59,6 +66,9 @@ private: bool _is_finished; FrameCount _time; Nodes _nodes; + + //Raul::List > _pending_learns; + SharedPtr _pending_learn; }; diff --git a/src/engine/machina/Makefile.am b/src/engine/machina/Makefile.am index ffcae1e..7bdd1fd 100644 --- a/src/engine/machina/Makefile.am +++ b/src/engine/machina/Makefile.am @@ -10,4 +10,5 @@ libmachinainclude_HEADERS = \ NodeFactory.hpp \ JackNodeFactory.hpp \ MidiAction.hpp \ - MidiDriver.hpp + MidiDriver.hpp \ + LearnRequest.hpp diff --git a/src/engine/machina/MidiAction.hpp b/src/engine/machina/MidiAction.hpp index d362a63..7dff692 100644 --- a/src/engine/machina/MidiAction.hpp +++ b/src/engine/machina/MidiAction.hpp @@ -18,6 +18,7 @@ #ifndef MACHINA_MIDIACTION_HPP #define MACHINA_MIDIACTION_HPP +#include #include #include #include "types.hpp" @@ -30,18 +31,29 @@ class MidiDriver; class MidiAction : public Action { public: - MidiAction(WeakPtr driver, - size_t size, - const unsigned char* event); - ~MidiAction(); + + static SharedPtr + create(SharedPtr maid, + size_t size, const unsigned char* event) + { + SharedPtr ret(new MidiAction(size, event)); + maid->manage(ret); + return ret; + } + + static void set_driver(SharedPtr driver); bool set_event(size_t size, const byte* event); void execute(Timestamp time); private: - WeakPtr _driver; + MidiAction(size_t size, + const unsigned char* event); + + static WeakPtr _driver; + size_t _size; const size_t _max_size; Raul::AtomicPtr _event; diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp index d0e19db..243773f 100644 --- a/src/engine/machina/Node.hpp +++ b/src/engine/machina/Node.hpp @@ -43,11 +43,11 @@ public: Node(FrameCount duration=0, bool initial=false); - void add_enter_action(Action* action); - void remove_enter_action(Action* action); + void add_enter_action(SharedPtr action); + void remove_enter_action(SharedPtr action); - void add_exit_action(Action* action); - void remove_exit_action(Action* action); + void add_exit_action(SharedPtr action); + void remove_exit_action(SharedPtr action); void enter(Timestamp time); void exit(Timestamp time); @@ -67,13 +67,13 @@ public: const EdgeList& outgoing_edges() const { return _outgoing_edges; } private: - bool _is_initial; - bool _is_active; - Timestamp _enter_time; ///< valid iff _is_active - FrameCount _duration; - Action* _enter_action; - Action* _exit_action; - EdgeList _outgoing_edges; + bool _is_initial; + bool _is_active; + Timestamp _enter_time; ///< valid iff _is_active + FrameCount _duration; + SharedPtr _enter_action; + SharedPtr _exit_action; + EdgeList _outgoing_edges; }; -- cgit v1.2.1