From 547d2e751fe03b6c2e81beef8fad27a31b5905e8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 12 Feb 2007 03:08:42 +0000 Subject: Added missing files. git-svn-id: http://svn.drobilla.net/lad/machina@304 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/machina/LearnRequest.hpp | 81 +++++++++++++++++++++++++++++++++++++ src/engine/machina/MidiDriver.hpp | 54 +++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 src/engine/machina/LearnRequest.hpp create mode 100644 src/engine/machina/MidiDriver.hpp (limited to 'src/engine/machina') 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 + * + * 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 +#include +#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 + create(SharedPtr maid, SharedPtr node) + { + SharedPtr 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() { return _node; } + const SharedPtr& enter_action() { return _enter_action; } + const SharedPtr& exit_action() { return _exit_action; } + +private: + LearnRequest(SharedPtr maid, SharedPtr 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; + SharedPtr _enter_action; + SharedPtr _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 + * + * 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 + -- cgit v1.2.1