From 7fa3812f1297c444754f22c3141facecbda92ec7 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Tue, 21 Mar 2023 11:48:21 -0400 Subject: Trim ns to ms --- chordNote.cpp | 6 ++++++ chordNote.h | 5 +++-- main.cpp | 9 +++++++++ song.cpp | 6 ++++++ song.h | 1 + 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/chordNote.cpp b/chordNote.cpp index 8b0051c..1fa7549 100644 --- a/chordNote.cpp +++ b/chordNote.cpp @@ -94,6 +94,12 @@ void ChordNote::print(){ std::cout << "Start: " << start << " End: " << end << std::endl; } +// Trim all timings to milliseconds +void ChordNote::trim(){ + start = start/1000000; + end = end/1000000; +} + // }}} // vim: syntax=cpp.doxygen diff --git a/chordNote.h b/chordNote.h index 47ca43f..b66af06 100644 --- a/chordNote.h +++ b/chordNote.h @@ -16,8 +16,8 @@ class ChordNote { private: - const int start; // Time in Nanoseconds - const int end; // 0 if not set + 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. @@ -45,6 +45,7 @@ class ChordNote { // 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" diff --git a/main.cpp b/main.cpp index c5e29cd..d72b1d0 100644 --- a/main.cpp +++ b/main.cpp @@ -75,6 +75,15 @@ int main() { repertoire.push_back(Song(songRoot + songFolders[i] + chartFile)); } + // Parse all the songs + for (int i = 0; i < repertoire.size(); i++) + { + repertoire[i].parseSync(); + repertoire[i].parseChords(0); + repertoire[i].consolidateChords(0); + repertoire[i].trim(0); + cout << repertoire[i].getTitle() << " parsed!" << endl; + } string displayString; diff --git a/song.cpp b/song.cpp index cdffddc..9ac5f91 100644 --- a/song.cpp +++ b/song.cpp @@ -321,5 +321,11 @@ std::string Song::getAudioFile(){ return audioFile; } +void Song::trim(int difficulty){ + // TODO: make this fuction use the difficulty parameter + std::vector*chords = &expert; + chords->trim(); +} + // vim: syntax=cpp.doxygen diff --git a/song.h b/song.h index db9bec4..5af5fbd 100644 --- a/song.h +++ b/song.h @@ -26,6 +26,7 @@ class Song{ void printChords(int difficulty); void consolidateChords(int difficulty); // Merge chords with same start/end times + void trim(int difficulty); // Trim chord timings from nanoseconds to milliseconds std::string getChartFile(); std::string getTitle(); -- cgit v1.2.3