-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMLPlayer.h
54 lines (36 loc) · 972 Bytes
/
MMLPlayer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include <stdint.h>
#include <stdlib.h>
class MMLPlayer {
public:
void update();
void play(const char* string);
void stop();
private:
// initialise ready to play string
void prepare_to_play_string(const char* string);
bool _playing;
uint32_t _note_duration_us;
uint32_t _note_start_us;
const char* _string;
uint8_t _tempo;
uint8_t _default_note_length;
uint8_t _volume;
size_t _next;
uint8_t _octave;
float _silence_duration;
bool _repeat;
enum node_mode_t {
MODE_NORMAL,
MODE_LEGATO,
MODE_STACCATO
} _note_mode;
void start_silence(float duration);
void start_note(float duration, float frequency, float volume);
char next_char();
uint8_t next_number();
size_t next_dots();
float rest_duration(uint32_t rest_length, uint8_t dots);
// Called when the MML player should start the next action
void next_action();
};