-
Notifications
You must be signed in to change notification settings - Fork 1
/
music.h
45 lines (33 loc) · 902 Bytes
/
music.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
45
#ifndef MUSIC_H
#define MUSIC_H
#include <stdbool.h>
#define PARSE_ERROR(...) { fprintf (stderr, __VA_ARGS__); exit(1); }
typedef enum music_item_type {
MUSIC_ITEM_NOTE,
MUSIC_ITEM_REST,
MUSIC_ITEM_TEMPO,
MUSIC_ITEM_SUB
} music_item_type_t;
typedef unsigned int music_item_tempo_t;
typedef struct music_item_note {
unsigned int id;
unsigned int frac;
unsigned int beats;
} music_item_note_t;
typedef struct music_item_sub {
unsigned int beats;
struct music_item *first;
} music_item_sub_t;
typedef struct music_item {
music_item_type_t type;
union {
music_item_note_t note;
music_item_tempo_t tempo;
music_item_sub_t sub;
} value;
struct music_item *next;
} music_item_t;
music_item_t * music_parse (char *input);
void music_item_destroy (music_item_t *item);
bool music_generate (const char *file, music_item_tempo_t tempo, music_item_t *sequence, int instr_id);
#endif