libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
notesequenceparser.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <promeki/core/string.h>
11#include <promeki/core/map.h>
15
17
43 public:
49 MusicalNote::List parse(const String &input);
50
55 const StringList &errors() const { return _errors; }
56
57 private:
58 struct Params {
59 double tempo = 100.0;
60 double noteLength = 0.25;
61 float amplitude = 0.5f;
62 int octave = 4;
63 MusicalScale scale;
64 float legato = 0.5f;
65 float vibrato = 0.0f;
66 float vibratoRate = 5.0f;
67 float tremolo = 0.0f;
68 float tremoloRate = 5.0f;
69 };
70
71 String _input;
72 size_t _pos = 0;
73 double _currentTime = 0.0;
74 Params _params;
75 List<Params> _paramStack;
76 Map<String, Params> _namedParams;
77 MusicalNote::List _notes;
78 StringList _errors;
79
80 void parseToken();
81 void parseTempo();
82 void parseNoteLengthParam();
83 void parseAmplitude();
84 void parseOctave();
85 void parseScaleParam();
86 void parseLegato();
87 void parseVibrato();
88 void parseTremolo();
89 void parseLetterNote();
90 void parseNumericNote();
91 void parseRest();
92 void parseBarRest();
93 void parseSaveParams();
94 void parseRecallParams();
95 void pushParams();
96 void popParams();
97 void skipComment();
98 void skipWhitespace();
99
100 char current() const;
101 char peek(int offset) const;
102 bool atEnd() const;
103 String readParenArg();
104 double parseDurationModifier();
105 void emitNote(float midiNote, int dots, double lengthMod);
106 void emitRest(int dots, double lengthMod);
107 void addError(const String &msg);
108
109 static double parseNoteLengthValue(const String &s);
110 static double applyDots(double length, int dots);
111};
112
Dynamic array container wrapping std::vector.
Definition list.h:40
Represents a musical scale with a root pitch class and mode.
Definition musicalscale.h:26
Parses a domain-specific text notation into a sequence of MusicalNote objects.
Definition notesequenceparser.h:42
MusicalNote::List parse(const String &input)
Parses the input string and returns a list of notes.
const StringList & errors() const
Returns any errors encountered during the last parse.
Definition notesequenceparser.h:55
Manages a list of strings.
Definition stringlist.h:21
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19