diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2023-02-14 16:34:40 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2023-02-14 16:34:40 -0500 |
commit | 6983e53daae8cab25ff113c7b5ccd3b31f39fcbb (patch) | |
tree | 5832db5c367b99ced3eb25591e325961630c7404 /song.cpp | |
parent | 8edabf33e46e1d2e5f69bbf856cf7f3595a4efa6 (diff) |
Basic Song and chord structure
Diffstat (limited to 'song.cpp')
-rw-r--r-- | song.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/song.cpp b/song.cpp new file mode 100644 index 0000000..0f34782 --- /dev/null +++ b/song.cpp @@ -0,0 +1,54 @@ +#include "song.h" + +Song::Song(std::string chartFile) { + // TODO: import and parse chartFile +} + +Song::~Song() {}; + +void Song::consolidate() { + int totalSize = chords.size(); + // Check each chord against every other chord + for (int i=0; i<totalSize; i++) { + // Get the start and end times of the current chord + int start = chords[i].getStart(); + int end = chords[i].getEnd(); + // Check the current chord against every following chord + for (int j=i+1; j<totalSize; j++) { + // If the start and end times match: + if (chords[j].getStart() == start && chords[j].getEnd() == end) { + // Append those notes to the first encountered chord (i) + for (int k=0; k<5; k++) { + // If this note is set in the second chord, change it in the first + if (chords[j].getNotes()[k]) { + chords[i].change(k); + } + } + // Remove the second chord from the vector + chords.erase(chords.begin()+j); + // Decrement the total size of the vector + totalSize--; + } + } + } +} + +std::string Song::getTitle() { + return title; +} + +std::string Song::getArtist() { + return artist; +} + +int Song::getDuration() { + return duration; +} + +std::string Song::getAudioFile() { + return audioFile; +} + +std::vector<Chord> Song::getChords() { + return chords; +} |