diff options
Diffstat (limited to 'src/engine/machina')
-rw-r--r-- | src/engine/machina/ActionFactory.hpp | 1 | ||||
-rw-r--r-- | src/engine/machina/Edge.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/LearnRequest.hpp | 6 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 4 | ||||
-rw-r--r-- | src/engine/machina/MidiAction.hpp | 11 | ||||
-rw-r--r-- | src/engine/machina/Node.hpp | 4 | ||||
-rw-r--r-- | src/engine/machina/Problem.hpp | 56 |
7 files changed, 67 insertions, 17 deletions
diff --git a/src/engine/machina/ActionFactory.hpp b/src/engine/machina/ActionFactory.hpp index b0aa1f9..f47a626 100644 --- a/src/engine/machina/ActionFactory.hpp +++ b/src/engine/machina/ActionFactory.hpp @@ -26,6 +26,7 @@ class Action; namespace ActionFactory { + SharedPtr<Action> copy(SharedPtr<Action> copy); SharedPtr<Action> note_on(unsigned char note); SharedPtr<Action> note_off(unsigned char note); } diff --git a/src/engine/machina/Edge.hpp b/src/engine/machina/Edge.hpp index 3f564ef..1b52dc7 100644 --- a/src/engine/machina/Edge.hpp +++ b/src/engine/machina/Edge.hpp @@ -31,7 +31,7 @@ namespace Machina { class Node; -class Edge : public Raul::Stateful, public boost::noncopyable { +class Edge : public Raul::Stateful { public: Edge(WeakPtr<Node> tail, SharedPtr<Node> head) diff --git a/src/engine/machina/LearnRequest.hpp b/src/engine/machina/LearnRequest.hpp index 4ec22ff..f6bc60f 100644 --- a/src/engine/machina/LearnRequest.hpp +++ b/src/engine/machina/LearnRequest.hpp @@ -58,9 +58,11 @@ private: LearnRequest(SharedPtr<Raul::Maid> maid, SharedPtr<Node> node) : _started(false) , _node(node) - , _enter_action(MidiAction::create(maid, 4, NULL)) - , _exit_action(MidiAction::create(maid, 4, NULL)) + , _enter_action(new MidiAction(4, NULL)) + , _exit_action(new MidiAction(4, NULL)) { + maid->manage(_enter_action); + maid->manage(_exit_action); } bool _started; diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 889dc1a..4544090 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -20,6 +20,7 @@ #include <boost/utility.hpp> #include <raul/SharedPtr.hpp> +#include <raul/WeakPtr.hpp> #include <raul/List.hpp> #include <raul/TimeSlice.hpp> #include <redlandmm/Model.hpp> @@ -32,9 +33,10 @@ namespace Machina { /** A (Finite State) Machine. */ -class Machine : public Raul::Stateful, public boost::noncopyable { +class Machine : public Raul::Stateful { public: Machine(); + Machine(const Machine& copy); ~Machine(); // Main context diff --git a/src/engine/machina/MidiAction.hpp b/src/engine/machina/MidiAction.hpp index 5639532..1a3f176 100644 --- a/src/engine/machina/MidiAction.hpp +++ b/src/engine/machina/MidiAction.hpp @@ -18,8 +18,6 @@ #ifndef MACHINA_MIDIACTION_HPP #define MACHINA_MIDIACTION_HPP -#include <raul/Maid.hpp> -#include <raul/WeakPtr.hpp> #include <raul/AtomicPtr.hpp> #include <raul/TimeSlice.hpp> #include "types.hpp" @@ -37,15 +35,6 @@ public: MidiAction(size_t size, const unsigned char* event); - 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; - } - size_t event_size() { return _size; } byte* event() { return _event.get(); } diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp index 5926a50..1f0face 100644 --- a/src/engine/machina/Node.hpp +++ b/src/engine/machina/Node.hpp @@ -18,7 +18,6 @@ #ifndef MACHINA_NODE_HPP #define MACHINA_NODE_HPP -#include <boost/utility.hpp> #include <raul/SharedPtr.hpp> #include <raul/List.hpp> #include <raul/Stateful.hpp> @@ -41,11 +40,12 @@ using Raul::BeatTime; * Initial nodes do not have enter actions (since they are entered at * an undefined point in time <= 0). */ -class Node : public Raul::Stateful, public boost::noncopyable { +class Node : public Raul::Stateful { public: typedef std::string ID; Node(BeatCount duration=0, bool initial=false); + Node(const Node& copy); void set_enter_action(SharedPtr<Action> action); void set_exit_action(SharedPtr<Action> action); diff --git a/src/engine/machina/Problem.hpp b/src/engine/machina/Problem.hpp new file mode 100644 index 0000000..d221e5c --- /dev/null +++ b/src/engine/machina/Problem.hpp @@ -0,0 +1,56 @@ +/* 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_PROBLEM_HPP +#define MACHINA_PROBLEM_HPP + +#include <raul/MIDISink.hpp> + +namespace Machina { + +class Machine; + + +class Problem { +public: + Problem(const std::string& target_midi); + + float fitness(Machine& machine); + +private: + struct Evaluator : public Raul::MIDISink { + Evaluator(Problem& problem) : _problem(problem), _n_notes(0) { + for (uint8_t i=0; i < 128; ++i) + _note_frequency[i] = 0; + } + void write_event(Raul::BeatTime time, + size_t ev_size, + const uint8_t* ev) throw (std::logic_error); + void compute(); + Problem& _problem; + + float _note_frequency[128]; + size_t _n_notes; + }; + + Evaluator _target; +}; + + +} // namespace Machina + +#endif // MACHINA_PROBLEM_HPP |