diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2023-04-08 13:36:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-08 13:36:34 -0400 |
commit | c3946e1a73aec0eb75ff4301dc42e1a2a71aab60 (patch) | |
tree | 9bfd6b6df4666491295b30088a6bf7bec6f61757 /chordNote.h | |
parent | 0fd63dfa5dfcac42a45f0b247e8461b4b969d6f7 (diff) | |
parent | 3180cb7584c037463ee5c2047aea3e3ed0f0b364 (diff) |
Diffstat (limited to 'chordNote.h')
-rw-r--r-- | chordNote.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/chordNote.h b/chordNote.h new file mode 100644 index 0000000..b66af06 --- /dev/null +++ b/chordNote.h @@ -0,0 +1,53 @@ +#ifndef CHORDNOTE_H +#define CHORDNOTE_H + +// Chords are used to represent a set of notes that are played together. +// For this guitar hero implementation, a single note is technically a chord. +// This analogy is used to make sure that simultaneous notes are always grouped +// under a single chord since they have information in common (start/end time). + +// Fret Definitions {{{ +#define FRET1 0 // green +#define FRET2 1 // red +#define FRET3 2 // yellow +#define FRET4 3 // blue +#define FRET5 4 // orange +// }}} + +class ChordNote { + private: + int start; // Time in Nanoseconds + int end; // 0 if not set + bool notes[5]; // Which notes are in the chord + int renderStart; // Time in Nanoseconds + // Chords are initialized with a single button. + // Other notes are added as notes with the same "start" are encountered + // in .chart files. + // End time is initialized to 0 but can be changed if the .chart file + // indicates otherwise. + public: + // Constructors, Destructors & Operators: + ChordNote(bool noteStates[5], int start, int end=0); // All known notes + ChordNote(int note, int start, int end=0); // For chartiles + ChordNote(const ChordNote& chord); // Copy constructor + ChordNote& operator=(const ChordNote& other); // Assignment operator + ~ChordNote(); // Destructor + // Getters: + bool* getNotes(); // All notes in the chord + int getStart(); // Start time of the chord + int getEnd(); // End time of the chord + int getRenderStart(); // Start time for rendering + // Setters: + void setRenderStart(int renderTime); // When it needs to start rendering + // Modifiers: + bool toggle(int note); // Add/remove a note in a chord + void merge(ChordNote chord); // Merge two chords (OR on every note) + // Misc: + bool has(int note); // check if a note is in the chord + void print(); // For debugging + void trim(); // Trim all timings to milliseconds +}; + +//#include "chordNote.cpp" +#endif // CHORDNOTE_H +// vim: syntax=cpp.doxygen |