diff options
Diffstat (limited to 'src/engine/machina')
-rw-r--r-- | src/engine/machina/Context.hpp | 44 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 10 |
2 files changed, 49 insertions, 5 deletions
diff --git a/src/engine/machina/Context.hpp b/src/engine/machina/Context.hpp new file mode 100644 index 0000000..270ede7 --- /dev/null +++ b/src/engine/machina/Context.hpp @@ -0,0 +1,44 @@ +/* This file is part of Machina. + * Copyright 2007-2012 David 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 3 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 more details. + * + * You should have received a copy of the GNU General Public License + * along with Machina. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MACHINA_CONTEXT_HPP +#define MACHINA_CONTEXT_HPP + +#include "raul/Atom.hpp" +#include "raul/TimeSlice.hpp" + +namespace Machina { + +class Context { +public: + Context(Raul::Forge& forge, uint32_t rate, uint32_t ppqn, double bpm) + : _forge(forge) + , _time(rate, ppqn, bpm) + {} + + Raul::Forge& forge() { return _forge; } + const Raul::TimeSlice& time() const { return _time; } + Raul::TimeSlice& time() { return _time; } + +private: + Raul::Forge& _forge; + Raul::TimeSlice _time; +}; + +} // namespace Machina + +#endif // MACHINA_CONTEXT_HPP diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index d65b670..0109742 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -35,6 +35,7 @@ namespace Machina { +class Context; class Controller; class LearnRequest; @@ -42,7 +43,7 @@ class LearnRequest; */ class Machine : public Stateful { public: - Machine(Raul::Forge& forge, TimeUnit unit); + Machine(TimeUnit unit); Machine(const Machine& copy); Machine& operator=(const Machine& other); @@ -66,7 +67,7 @@ public: // Audio context void reset(Raul::TimeStamp time); - uint32_t run(const Raul::TimeSlice& time, SharedPtr<UpdateBuffer> updates); + uint32_t run(Context& context, SharedPtr<UpdateBuffer> updates); // Any context inline Raul::TimeStamp time() const { return _time; } @@ -87,13 +88,12 @@ private: // Audio context SharedPtr<Node> earliest_node() const; - bool enter_node(SharedPtr<MIDISink> sink, SharedPtr<Node> node, SharedPtr<UpdateBuffer> updates); - void exit_node(SharedPtr<MIDISink> sink, SharedPtr<Node>, SharedPtr<UpdateBuffer> updates); + bool enter_node(Context& context, SharedPtr<MIDISink> sink, SharedPtr<Node> node, SharedPtr<UpdateBuffer> updates); + void exit_node(Context& context, SharedPtr<MIDISink> sink, SharedPtr<Node>, SharedPtr<UpdateBuffer> updates); static const size_t MAX_ACTIVE_NODES = 128; std::vector< SharedPtr<Node> > _active_nodes; - Raul::Forge& _forge; bool _is_activated; bool _is_finished; Raul::TimeStamp _time; |