From 6c358a842baaf6d211a5c8c1717d815e7813ed96 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sun, 11 Jul 2021 18:45:38 +0800 Subject: First commit Now I have a kind of piano like instrument. A violin-like instrument is being constructed. --- parser.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 parser.h (limited to 'parser.h') diff --git a/parser.h b/parser.h new file mode 100644 index 0000000..3454bd4 --- /dev/null +++ b/parser.h @@ -0,0 +1,48 @@ +#ifndef PARSER_H +#define PARSER_H +#include "util.h" +#include "instrument.h" + +/* Parse a complex sheet file so that it is easy to generate complex + sounds. */ + +/* A unit for the parser. This typically represents one note, but can + serve different purposes. In our format, a unit is given in one + line. */ + +struct PUnit_s; + +typedef struct PUnit_s PUnit; + +struct PNote_s; + +typedef struct PNote_s PNote; + +/* A sheet is just an array of units. But we need to know the length + of the array as well. */ + +typedef struct { + PUnit *data; + LENT len; +} PSheet; + +U_ATTR void print_sheet(const PSheet sh); + +/* Might be helpful, or not */ + +H_ATTR unsigned char is_empty_note(PNote *n); + +/* The function to read the sheet. */ + +U_ATTR PSheet read_sheet(const char *str, LENT len); + +/* Destructor */ + +U_ATTR void destroy_sheet(PSheet sh); + +/* Now play sheet */ + +U_ATTR WaveFrag play_sheet(const PSheet sh, const Volume v); + +#endif + -- cgit v1.2.3-18-g5258