Note value quantity data type
A note value quantity is an integer multiple of a note value. Some examples:
Note value quantity | Encoding |
---|---|
A single eighth note | /8 |
Six eighth notes | 6/8 |
Six dotted eighth notes | 6/8d |
Five whole notes | 5/1 |
Syntax definition
A note value quantity consists of the following, in order:
- Zero or more ASCII digits encoding the multiplier.
- A note value.
Algorithm for parsing
To parse a note value quantity, use the following procedure:
- Let input be the string being parsed.
- Let position be a pointer into input, initially pointing at the start of the string.
- Let multiplier be
1
. - Collect a sequence of characters that are ASCII digits only, and let unparsed number be the result.
- If unparsed number is not empty, assign unparsed number to multiplier using the rules for parsing integers.
- Let note value be the result of parsing the remainder of the string beginning at position according to the algorithm for parsing a note value.
- Return multiplier and note value.