diff options
Diffstat (limited to 'src/engine/machina')
-rw-r--r-- | src/engine/machina/Context.hpp | 3 | ||||
-rw-r--r-- | src/engine/machina/Controller.hpp | 27 | ||||
-rw-r--r-- | src/engine/machina/Driver.hpp | 24 | ||||
-rw-r--r-- | src/engine/machina/Engine.hpp | 3 | ||||
-rw-r--r-- | src/engine/machina/Evolver.hpp | 12 | ||||
-rw-r--r-- | src/engine/machina/Loader.hpp | 3 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 20 | ||||
-rw-r--r-- | src/engine/machina/Mutation.hpp | 12 | ||||
-rw-r--r-- | src/engine/machina/URIs.hpp | 3 | ||||
-rw-r--r-- | src/engine/machina/types.hpp | 2 |
10 files changed, 75 insertions, 34 deletions
diff --git a/src/engine/machina/Context.hpp b/src/engine/machina/Context.hpp index c863cc4..8f86602 100644 --- a/src/engine/machina/Context.hpp +++ b/src/engine/machina/Context.hpp @@ -26,7 +26,8 @@ namespace Machina { class MIDISink; -class Context { +class Context +{ public: Context(Raul::Forge& forge, uint32_t rate, uint32_t ppqn, double bpm) : _forge(forge) diff --git a/src/engine/machina/Controller.hpp b/src/engine/machina/Controller.hpp index f5bf631..ddd1d4c 100644 --- a/src/engine/machina/Controller.hpp +++ b/src/engine/machina/Controller.hpp @@ -30,7 +30,9 @@ #include "Stateful.hpp" -namespace Raul { class Atom; class Maid; } +namespace Raul { +class Atom; class Maid; +} namespace Machina { @@ -38,18 +40,25 @@ class Engine; class Machine; class Stateful; -namespace Client { class ClientModel; class ClientObject; } +namespace Client { +class ClientModel; class ClientObject; +} -class Controller { +class Controller +{ public: Controller(SharedPtr<Engine> engine, Client::ClientModel& client_model); uint64_t create(const Client::ClientObject& obj); uint64_t connect(uint64_t tail_id, uint64_t head_id); - void set_property(uint64_t object_id, URIInt key, const Raul::Atom& value); - void learn(SharedPtr<Raul::Maid> maid, uint64_t node_id); - void disconnect(uint64_t tail_id, uint64_t head_id); - void erase(uint64_t id); + + void set_property(uint64_t object_id, + URIInt key, + const Raul::Atom& value); + + void learn(SharedPtr<Raul::Maid> maid, uint64_t node_id); + void disconnect(uint64_t tail_id, uint64_t head_id); + void erase(uint64_t id); void announce(SharedPtr<Machine> machine); @@ -59,9 +68,11 @@ private: SharedPtr<Stateful> find(uint64_t id); struct StatefulComparator { - inline bool operator()(SharedPtr<Stateful> lhs, SharedPtr<Stateful> rhs) const { + inline bool operator()(SharedPtr<Stateful> lhs, + SharedPtr<Stateful> rhs) const { return lhs->id() < rhs->id(); } + }; typedef std::set<SharedPtr<Stateful>, StatefulComparator> Objects; diff --git a/src/engine/machina/Driver.hpp b/src/engine/machina/Driver.hpp index 69bf951..778fd22 100644 --- a/src/engine/machina/Driver.hpp +++ b/src/engine/machina/Driver.hpp @@ -28,7 +28,9 @@ namespace Machina { class Machine; -class Driver : public MIDISink { +class Driver + : public MIDISink +{ public: Driver(Raul::Forge& forge, SharedPtr<Machine> machine) : _forge(forge) @@ -38,23 +40,29 @@ public: virtual ~Driver() {} SharedPtr<Machine> machine() { return _machine; } - virtual void set_machine(SharedPtr<Machine> machine) { _machine = machine; } + + virtual void set_machine(SharedPtr<Machine> machine) { + _machine = machine; + } SharedPtr<UpdateBuffer> update_sink() { return _updates; } - void set_update_sink(SharedPtr<UpdateBuffer> b) { _updates = b; } - virtual void set_bpm(double bpm) = 0; + void set_update_sink(SharedPtr<UpdateBuffer> b) { + _updates = b; + } + + virtual void set_bpm(double bpm) = 0; virtual void set_quantization(double q) = 0; virtual bool is_activated() const { return false; } - virtual void activate() {} - virtual void deactivate() {} + virtual void activate() {} + virtual void deactivate() {} virtual void stop() {} - virtual bool recording() { return false; } + virtual bool recording() { return false; } virtual void start_record(bool step) {} - virtual void finish_record() {} + virtual void finish_record() {} protected: Raul::Forge& _forge; diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp index 5f11d55..7040082 100644 --- a/src/engine/machina/Engine.hpp +++ b/src/engine/machina/Engine.hpp @@ -32,7 +32,8 @@ namespace Machina { class Machine; -class Engine { +class Engine +{ public: Engine(Raul::Forge& forge, SharedPtr<Driver> driver, diff --git a/src/engine/machina/Evolver.hpp b/src/engine/machina/Evolver.hpp index 8dd8e12..1aec3e8 100644 --- a/src/engine/machina/Evolver.hpp +++ b/src/engine/machina/Evolver.hpp @@ -25,16 +25,22 @@ #include "Schrodinbit.hpp" -namespace Eugene { template <typename G> class HybridMutation; } +namespace Eugene { +template<typename G> +class HybridMutation; +} namespace Machina { class Machine; class Problem; -class Evolver : public Raul::Thread { +class Evolver + : public Raul::Thread +{ public: - Evolver(Raul::TimeUnit unit, const string& target_midi, SharedPtr<Machine> seed); + Evolver(Raul::TimeUnit unit, const string& target_midi, + SharedPtr<Machine> seed); void seed(SharedPtr<Machine> parent); bool improvement() { return _improvement; } diff --git a/src/engine/machina/Loader.hpp b/src/engine/machina/Loader.hpp index 470b109..f97618a 100644 --- a/src/engine/machina/Loader.hpp +++ b/src/engine/machina/Loader.hpp @@ -31,7 +31,8 @@ namespace Machina { class Machine; -class Loader { +class Loader +{ public: Loader(Raul::Forge& forge, Sord::World& rdf_world); diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 164c2e4..acfc599 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -41,7 +41,9 @@ class LearnRequest; /** A (Finite State) Machine. */ -class Machine : public Stateful { +class Machine + : public Stateful +{ public: Machine(TimeUnit unit); Machine(const Machine& copy); @@ -72,8 +74,8 @@ public: // Any context inline Raul::TimeStamp time() const { return _time; } - SharedPtr<LearnRequest> pending_learn() { return _pending_learn; } - void clear_pending_learn() { _pending_learn.reset(); } + SharedPtr<LearnRequest> pending_learn() { return _pending_learn; } + void clear_pending_learn() { _pending_learn.reset(); } typedef std::list< SharedPtr<Node> > Nodes; Nodes& nodes() { return _nodes; } @@ -85,10 +87,16 @@ public: private: // Audio context SharedPtr<Node> earliest_node() const; - bool enter_node(Context& context, SharedPtr<Node> node, SharedPtr<UpdateBuffer> updates); - void exit_node(Context& context, SharedPtr<Node> node, SharedPtr<UpdateBuffer> updates); - static const size_t MAX_ACTIVE_NODES = 128; + bool enter_node(Context& context, + SharedPtr<Node> node, + SharedPtr<UpdateBuffer> updates); + + void exit_node(Context& context, + SharedPtr<Node> node, + SharedPtr<UpdateBuffer> updates); + + static const size_t MAX_ACTIVE_NODES = 128; std::vector< SharedPtr<Node> > _active_nodes; SharedPtr<LearnRequest> _pending_learn; diff --git a/src/engine/machina/Mutation.hpp b/src/engine/machina/Mutation.hpp index 437165f..dd2dbbf 100644 --- a/src/engine/machina/Mutation.hpp +++ b/src/engine/machina/Mutation.hpp @@ -21,10 +21,10 @@ #include "machina_config.h" #ifdef HAVE_EUGENE - #include "eugene/Mutation.hpp" - #define SUPER : public Eugene::Mutation<Machine> +# include "eugene/Mutation.hpp" +# define SUPER : public Eugene::Mutation <Machine> #else - #define SUPER : public Mutation +# define SUPER : public Mutation #endif namespace Machina { @@ -33,7 +33,11 @@ class Machine; namespace Mutation { -struct Mutation { virtual ~Mutation() {}; virtual void mutate(Machine& machine) = 0; }; +struct Mutation { + virtual ~Mutation() {} + + virtual void mutate(Machine& machine) = 0; +}; struct Compress SUPER { void mutate(Machine& machine); }; struct AddNode SUPER { void mutate(Machine& machine); }; diff --git a/src/engine/machina/URIs.hpp b/src/engine/machina/URIs.hpp index 4838761..caed196 100644 --- a/src/engine/machina/URIs.hpp +++ b/src/engine/machina/URIs.hpp @@ -26,7 +26,8 @@ namespace Machina { -class URIs { +class URIs +{ public: static void init() { _instance = new URIs(); } diff --git a/src/engine/machina/types.hpp b/src/engine/machina/types.hpp index 8bae27a..7603d3c 100644 --- a/src/engine/machina/types.hpp +++ b/src/engine/machina/types.hpp @@ -24,7 +24,7 @@ namespace Machina { typedef unsigned char byte; -typedef Raul::RingBuffer UpdateBuffer; +typedef Raul::RingBuffer UpdateBuffer; typedef uint32_t URIInt; |