From fd6009bb021e7eebeb09e51b003c84a74a84a020 Mon Sep 17 00:00:00 2001 From: Robert Bendun Date: Tue, 24 May 2022 15:45:31 +0200 Subject: [PATCH] Euterpea like octave and duration setting --- src/value.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/value.cc b/src/value.cc index b2dc08d..c84d8cf 100644 --- a/src/value.cc +++ b/src/value.cc @@ -135,6 +135,20 @@ Result Value::operator()(Interpreter &i, std::vector args) switch (type) { case Type::Intrinsic: return intr(i, std::move(args)); case Type::Block: return blk(i, std::move(args)); + case Type::Music: + { + assert(args.size() == 1 || args.size() == 2, "music value can be called only in form note []"); // TODO(assert) + assert(args[0].type == Type::Number, "expected octave to be a number"); // TODO(assert) + + note.octave = args[0].n.as_int(); + + if (args.size() == 2) { + assert(args[1].type == Type::Number, "expected length to be a number"); // TODO(assert) + note.length = args[1].n; + } + + return *this; + } default: // TODO Fill location return errors::not_callable(std::nullopt, type);