aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/machina
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/machina')
-rw-r--r--src/engine/machina/JackDriver.hpp25
-rw-r--r--src/engine/machina/Makefile.am5
-rw-r--r--src/engine/machina/MidiAction.hpp (renamed from src/engine/machina/JackActions.hpp)32
-rw-r--r--src/engine/machina/types.hpp1
4 files changed, 30 insertions, 33 deletions
diff --git a/src/engine/machina/JackDriver.hpp b/src/engine/machina/JackDriver.hpp
index 84c9223..bae3ab2 100644
--- a/src/engine/machina/JackDriver.hpp
+++ b/src/engine/machina/JackDriver.hpp
@@ -22,11 +22,17 @@
#include <raul/SharedPtr.h>
#include <jack/midiport.h>
#include "Machine.hpp"
+#include "MidiDriver.hpp"
namespace Machina {
-class JackDriver : public Raul::JackDriver {
+/** Realtime JACK Driver.
+ *
+ * "Ticks" are individual frames when running under this driver, and all code
+ * in the processing context must be realtime safe (non-blocking).
+ */
+class JackDriver : public Raul::JackDriver, public Machina::MidiDriver {
public:
JackDriver();
@@ -36,18 +42,17 @@ public:
void set_machine(SharedPtr<Machine> machine) { _machine = machine; }
// Audio context
- Timestamp stamp_to_offset(Timestamp stamp);
- jack_port_t* output_port() { return _output_port; }
- //Timestamp current_cycle_start() { return _current_cycle_start; }
- //Timestamp current_cycle_offset() { return _current_cycle_offset; }
- FrameCount current_cycle_nframes() { return _current_cycle_nframes; }
+ Timestamp cycle_start() { return _current_cycle_start; }
+ FrameCount cycle_length() { return _current_cycle_nframes; }
-
-protected:
- virtual void on_process(jack_nframes_t nframes);
-
private:
+ // Audio context
+ Timestamp subcycle_offset() { return _current_cycle_offset; }
+ jack_port_t* output_port() { return _output_port; }
+ virtual void on_process(jack_nframes_t nframes);
+ Timestamp stamp_to_offset(Timestamp stamp);
SharedPtr<Machine> _machine;
+
jack_port_t* _output_port;
Timestamp _current_cycle_start;
Timestamp _current_cycle_offset; ///< for split cycles
diff --git a/src/engine/machina/Makefile.am b/src/engine/machina/Makefile.am
index eca6f9b..ffcae1e 100644
--- a/src/engine/machina/Makefile.am
+++ b/src/engine/machina/Makefile.am
@@ -7,6 +7,7 @@ libmachinainclude_HEADERS = \
Machine.hpp \
Loader.hpp \
JackDriver.hpp \
- JackActions.hpp \
NodeFactory.hpp \
- JackNodeFactory.hpp
+ JackNodeFactory.hpp \
+ MidiAction.hpp \
+ MidiDriver.hpp
diff --git a/src/engine/machina/JackActions.hpp b/src/engine/machina/MidiAction.hpp
index 0eb50b8..2e1d1fc 100644
--- a/src/engine/machina/JackActions.hpp
+++ b/src/engine/machina/MidiAction.hpp
@@ -15,8 +15,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef MACHINA_JACKACTIONS_HPP
-#define MACHINA_JACKACTIONS_HPP
+#ifndef MACHINA_MIDIACTION_HPP
+#define MACHINA_MIDIACTION_HPP
#include <raul/WeakPtr.h>
#include "types.hpp"
@@ -24,34 +24,24 @@
namespace Machina {
-class Node;
-class JackDriver;
+class MidiDriver;
-class JackNoteOnAction : public Action {
+class MidiAction : public Action {
public:
- JackNoteOnAction(WeakPtr<JackDriver> driver, unsigned char note_num);
+ JackNoteOnAction(WeakPtr<MidiDriver> driver,
+ size_t size,
+ unsigned char* event);
void execute(Timestamp time);
private:
- WeakPtr<JackDriver> _driver;
- unsigned char _note_num;
-};
-
-
-class JackNoteOffAction : public Action {
-public:
- JackNoteOffAction(WeakPtr<JackDriver> driver, unsigned char note_num);
-
- void execute(Timestamp time);
-
-private:
- WeakPtr<JackDriver> _driver;
- unsigned char _note_num;
+ WeakPtr<MidiDriver> _driver;
+ size_t _size;
+ unsigned char* _event;
};
} // namespace Machina
-#endif // MACHINA_JACKACTIONS_HPP
+#endif // MACHINA_MIDIACTION_HPP
diff --git a/src/engine/machina/types.hpp b/src/engine/machina/types.hpp
index 8793fb1..db36901 100644
--- a/src/engine/machina/types.hpp
+++ b/src/engine/machina/types.hpp
@@ -26,6 +26,7 @@ namespace Machina {
typedef jack_nframes_t FrameCount;
typedef jack_nframes_t Timestamp;
+
} // namespace Machina
#endif // MACHINA_TYPES_HPP