Volume can be controlled by "V". And numter following after the "V".
ex: ``"V4"``
## Example of a score
### The beginning of the Do Re Mi Song.
Tempo 120, Voulume 10, Octave 4, Default length is 4.
``"T120 V10 O4 L4 C. D8 E. C8 E C E2 D. E8 {FF} {ED} F2"``
## Provided C Functions
mml_parser is providing just 2 functions.
### init_mml()
Initialize an instance of mml parser.
#### Synopsis
```c
#include <audioutils/mml_parser.h>
int init_mml(FAR struct music_macro_lang_s *mml,
int fs, int tempo, int octave, int length);
```
#### Description
The function initializes `struct music_macro_lang_s` instance provided as 1st argument.
The argument `fs` is a sampling frequency of target audio output system, and this value is used for
calculating sample number in case of a tempo and length of note.
`tempo`, `octave` and `length` specify initial values for tempo, octave, and length, respectively.
#### Return value
On success, init_mml() returns 0. On error, it returns an negative value.
#### Errors
Currently no error is happened.
### parse_mml()
Parse MML from given string.
#### Synopsis
```c
#include <audioutils/mml_parser.h>
int parse_mml(FAR struct music_macro_lang_s *mml,
FAR char **score, FAR struct mml_result_s *result);
```
#### Description
parse_mml() parses the first MML of the string given by the argument ``score`` and gives
the result in the return value and the argument ``result``.
The ``result`` is an instance of mml_result_s, which contains note_idx, length, and
chord_notes as members. The meaning of the value of each member depends on the return value.
#### Return value
On error, a nevative value is returned.
On success, following values can be returned. And those values are defined in ``mml_parser.h``.
| Return values | Description |
| -------------------- | ----------- |
| MML_TYPE_EOF | This means that it have reached the end of the string. The content of the ``result`` has no meaning. |
| MML_TYPE_NOTE | This indicates that some note has been parsed. The scale of the note is stored in ``note_idx[0]``. The length of the note is given by the ``length`` member as the number of samples. In the case of tuplet, this return value is returned at the time each note is parsed. In other words, a tuplet is parsed as a single note. |
| MML_TYPE_REST | This indicates the ``rest`` has been parsed. The length of it is given by the ``length`` member as the number of samples. |
| MML_TYPE_TEMPO | This indicates ``"T"`` is parsed. ``length`` member in ``result`` has the value of the tempo. But tempo value is kept in mml instance for calculating sample number for each notes. So basically, no need to handle this return value in your code. |
| MML_TYPE_LENGTH | This indicates ``"L"`` is parsed. ``length`` member in ``result`` has the value of the parsed length. But current length value is kept in mml instance. So basically, no need to handle this return value in your code. |
| MML_TYPE_OCTAVE | This indicates ``"O"``, ``">"``, or ``"<"`` is parsed. ``length`` member in ``result`` has the value of the octave. But the octave is encoded in ``note_idx`` in ``MML_TYPE_NOTE`` case. So basically, no need to handle this return value in your code. |
| MML_TYPE_TUPLETSTART | This indicates tuplet is just started. And total length of the tuplet is stored in ``length`` of ``result`` members. |
| MML_TYPE_TUPLETDONE | This indicates the tuplet is just finished. |
| MML_TYPE_VOLUME | This indicates ``"V"`` is parsed. ``length`` member in ``result`` has the value of the parsed volume. |
| MML_TYPE_TONE | T.B.D. |
| MML_TYPE_CHORD | This indicates a chord is parsed. Chord has some notes, and how many notes is stored in ``chord_notes`` member of ``result``. And each notes are stored in ``note_idx[]``. Length of the chord is stored in ``length`` member of ``result``. |
The value of ``note_idx[]`` is encoding octave, like
| Octave | Note | node_idx value |
| ------ | ---- |:--------------:|
| O0 | C | 0 |
| O0 | C# | 1 |
| O0 | D | 2 |
| O0 | D# | 3 |
| O0 | E | 4 |
| O0 | F | 5 |
| O0 | F# | 6 |
| O0 | G | 7 |
| O0 | G# | 8 |
| O0 | A | 9 |
| O0 | A# | 10 |
| O0 | B | 11 |
| O1 | C | 12 |
And so on.
So for example, G# at Octave 4 is encoded as 56.
#### Errors
Following error code can be received as return value.