summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2023-03-21 11:48:21 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2023-03-21 11:48:21 -0400
commit7fa3812f1297c444754f22c3141facecbda92ec7 (patch)
treee1242ab9948dd3b9198514b508db528d3de32ab1
parent73d1b5bdda882a533767e06e75831cc5c9e552a5 (diff)
Trim ns to ms
-rw-r--r--chordNote.cpp6
-rw-r--r--chordNote.h5
-rw-r--r--main.cpp9
-rw-r--r--song.cpp6
-rw-r--r--song.h1
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<ChordNote>*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();