aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/machina
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-11 01:26:07 +0000
committerDavid Robillard <d@drobilla.net>2007-02-11 01:26:07 +0000
commitda3ac16cbfbf66edebe929f8d9bf7d76ab24dd74 (patch)
tree8371f2d2e46925df9337be9b578cfb74d671d285 /src/engine/machina
parentcee33ba4c0859b117be94df6ccbf3eb756a850af (diff)
downloadmachina-da3ac16cbfbf66edebe929f8d9bf7d76ab24dd74.tar.gz
machina-da3ac16cbfbf66edebe929f8d9bf7d76ab24dd74.tar.bz2
machina-da3ac16cbfbf66edebe929f8d9bf7d76ab24dd74.zip
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
Diffstat (limited to 'src/engine/machina')
-rw-r--r--src/engine/machina/Action.hpp5
-rw-r--r--src/engine/machina/JackDriver.hpp8
-rw-r--r--src/engine/machina/Machine.hpp16
-rw-r--r--src/engine/machina/Makefile.am3
-rw-r--r--src/engine/machina/MidiAction.hpp22
-rw-r--r--src/engine/machina/Node.hpp22
6 files changed, 46 insertions, 30 deletions
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 <string>
#include <iostream>
+#include <raul/Deletable.h>
#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> node);
-
void write_event(Timestamp time,
size_t size,
const unsigned char* event);
@@ -66,13 +64,9 @@ private:
SharedPtr<Machine> _machine;
- SharedPtr<Node> _learn_node;
- SharedPtr<MidiAction> _learn_enter_action;
- SharedPtr<MidiAction> _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 <vector>
-#include <map>
#include <raul/SharedPtr.h>
#include <raul/List.h>
#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> node);
+ void learn(SharedPtr<LearnRequest> 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<LearnRequest> first_learn() { return *_pending_learns.begin(); }
+ SharedPtr<LearnRequest> pending_learn() { return _pending_learn; }
+ void clear_pending_learn() { _pending_learn.reset(); }
private:
typedef Raul::List<SharedPtr<Node> > Nodes;
@@ -59,6 +66,9 @@ private:
bool _is_finished;
FrameCount _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 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 <raul/Maid.h>
#include <raul/WeakPtr.h>
#include <raul/AtomicPtr.h>
#include "types.hpp"
@@ -30,18 +31,29 @@ class MidiDriver;
class MidiAction : public Action {
public:
- MidiAction(WeakPtr<MidiDriver> driver,
- size_t size,
- const unsigned char* event);
-
~MidiAction();
+
+ static SharedPtr<MidiAction>
+ create(SharedPtr<Raul::Maid> maid,
+ size_t size, const unsigned char* event)
+ {
+ SharedPtr<MidiAction> ret(new MidiAction(size, event));
+ maid->manage(ret);
+ return ret;
+ }
+
+ static void set_driver(SharedPtr<MidiDriver> driver);
bool set_event(size_t size, const byte* event);
void execute(Timestamp time);
private:
- WeakPtr<MidiDriver> _driver;
+ MidiAction(size_t size,
+ const unsigned char* event);
+
+ static WeakPtr<MidiDriver> _driver;
+
size_t _size;
const size_t _max_size;
Raul::AtomicPtr<byte> _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> action);
+ void remove_enter_action(SharedPtr<Action> action);
- void add_exit_action(Action* action);
- void remove_exit_action(Action* action);
+ void add_exit_action(SharedPtr<Action> action);
+ void remove_exit_action(SharedPtr<Action> 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<Action> _enter_action;
+ SharedPtr<Action> _exit_action;
+ EdgeList _outgoing_edges;
};