diff options
Diffstat (limited to 'src/engine/machina')
-rw-r--r-- | src/engine/machina/LearnRequest.hpp | 81 | ||||
-rw-r--r-- | src/engine/machina/MidiDriver.hpp | 54 |
2 files changed, 135 insertions, 0 deletions
diff --git a/src/engine/machina/LearnRequest.hpp b/src/engine/machina/LearnRequest.hpp new file mode 100644 index 0000000..60f1b27 --- /dev/null +++ b/src/engine/machina/LearnRequest.hpp @@ -0,0 +1,81 @@ +/* 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 Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef MACHINA_LEARNREQUEST_HPP +#define MACHINA_LEARNREQUEST_HPP + +#include <raul/Maid.h> +#include <raul/SharedPtr.h> +#include "types.hpp" +#include "Node.hpp" +#include "MidiAction.hpp" + +namespace Machina { + +class Node; +class MidiAction; + + +/** A request to MIDI learn a certain node. + */ +class LearnRequest : public Raul::Deletable { +public: + + static SharedPtr<LearnRequest> + create(SharedPtr<Raul::Maid> maid, SharedPtr<Node> node) + { + SharedPtr<LearnRequest> ret(new LearnRequest(maid, node)); + maid->manage(ret); + return ret; + } + + // Add the learned actions to the node + void finish(Timestamp time) + { + _node->add_enter_action(_enter_action); + _node->add_exit_action(_exit_action); + _node->set_duration(time - _start_time); + std::cerr << "LEARN DURATION: " << _node->duration() << std::endl; + } + + void start(Timestamp time) { _started = true; _start_time = time; } + bool started() { return _started; } + + const SharedPtr<Node>& node() { return _node; } + const SharedPtr<MidiAction>& enter_action() { return _enter_action; } + const SharedPtr<MidiAction>& exit_action() { return _exit_action; } + +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)) + { + } + + bool _started; + Timestamp _start_time; + SharedPtr<Node> _node; + SharedPtr<MidiAction> _enter_action; + SharedPtr<MidiAction> _exit_action; +}; + + +} // namespace Machina + +#endif // MACHINA_LEARNREQUEST_HPP diff --git a/src/engine/machina/MidiDriver.hpp b/src/engine/machina/MidiDriver.hpp new file mode 100644 index 0000000..7f6dca1 --- /dev/null +++ b/src/engine/machina/MidiDriver.hpp @@ -0,0 +1,54 @@ +/* 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_MIDIDRIVER_HPP +#define MACHINA_MIDIDRIVER_HPP + +#include "machina/types.hpp" + +namespace Machina { + +class Node; + + +class MidiDriver { +public: + virtual ~MidiDriver() {} + + /** Emit a MIDI event at the given time */ + virtual void write_event(Timestamp time, + size_t size, + const unsigned char* event) = 0; + + /** Beginning of current cycle in absolute time. + */ + virtual Timestamp cycle_start() = 0; + + /** Length of current cycle in ticks. + * + * A "tick" is the smallest recognizable unit of (discrete) time. + * Ticks could be single audio frames, MIDI clock at a certain ppqn, etc. + */ + virtual FrameCount cycle_length() = 0; + +}; + + +} // namespace Machina + +#endif // MACHINA_MIDIDRIVER_HPP + |