Note on & note off explicit midi calls

This commit is contained in:
Robert Bendun 2022-05-30 15:35:37 +02:00
parent 43d7aeac1d
commit 31dfcc37ca

View File

@ -366,6 +366,30 @@ Interpreter::Interpreter()
return Value{}; return Value{};
}); });
global.force_define("note_on", +[](Interpreter &i, std::vector<Value> args) -> Result<Value> {
using Channel_Note_Velocity = Shape<Value::Type::Number, Value::Type::Number, Value::Type::Number>;
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<Value> args) -> Result<Value> {
using Channel_Note_Velocity = Shape<Value::Type::Number, Value::Type::Number, Value::Type::Number>;
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<std::plus<>>; operators["+"] = plus_minus_operator<std::plus<>>;
operators["-"] = plus_minus_operator<std::minus<>>; operators["-"] = plus_minus_operator<std::minus<>>;
operators["*"] = binary_operator<std::multiplies<>>; operators["*"] = binary_operator<std::multiplies<>>;