From 31dfcc37ca45b06fb249c1eac7ef3d0501193dc2 Mon Sep 17 00:00:00 2001 From: Robert Bendun Date: Mon, 30 May 2022 15:35:37 +0200 Subject: [PATCH] Note on & note off explicit midi calls --- src/interpreter.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/interpreter.cc b/src/interpreter.cc index 6727dd6..74f6a70 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -366,6 +366,30 @@ Interpreter::Interpreter() return Value{}; }); + global.force_define("note_on", +[](Interpreter &i, std::vector args) -> Result { + using Channel_Note_Velocity = Shape; + + if (Channel_Note_Velocity::typecheck(args)) { + auto [chan, note, vel] = Channel_Note_Velocity::move_from(args); + i.midi_connection->send_note_on(chan.as_int(), note.as_int(), vel.as_int()); + return Value {}; + } + + unreachable(); + }); + + global.force_define("note_off", +[](Interpreter &i, std::vector args) -> Result { + using Channel_Note_Velocity = Shape; + + if (Channel_Note_Velocity::typecheck(args)) { + auto [chan, note, vel] = Channel_Note_Velocity::move_from(args); + i.midi_connection->send_note_off(chan.as_int(), note.as_int(), vel.as_int()); + return Value {}; + } + + unreachable(); + }); + operators["+"] = plus_minus_operator>; operators["-"] = plus_minus_operator>; operators["*"] = binary_operator>;