summaryrefslogtreecommitdiff
path: root/tools/seq_compiler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/seq_compiler.cc')
-rw-r--r--tools/seq_compiler.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/seq_compiler.cc b/tools/seq_compiler.cc
index 5804031..462bdba 100644
--- a/tools/seq_compiler.cc
+++ b/tools/seq_compiler.cc
@@ -703,17 +703,7 @@ int main(int argc, char* argv[]) {
std::string command;
ss >> command;
- if (command == "END_DEMO") {
- std::string end_time;
- if (!(ss >> end_time)) {
- std::cerr << "Error line " << line_num
- << ": END_DEMO requires <time>\n";
- return 1;
- }
- // Convert beat notation to time
- demo_end_time = convert_to_time(end_time, bpm);
- std::cout << "Demo end time: " << demo_end_time << "s\n";
- } else if (command == "SEQUENCE") {
+ if (command == "SEQUENCE") {
std::string start, priority;
if (!(ss >> start >> priority)) {
std::cerr << "Error line " << line_num
@@ -855,9 +845,23 @@ int main(int argc, char* argv[]) {
}
}
- // Sort sequences by priority
+ // Calculate demo end time from maximum effect end time
+ float max_end_time = 0.0f;
+ for (const auto& seq : sequences) {
+ float seq_start = std::stof(seq.start_time);
+ for (const auto& eff : seq.effects) {
+ max_end_time = std::max(max_end_time, seq_start + std::stof(eff.end));
+ }
+ }
+ demo_end_time = std::to_string(max_end_time);
+ std::cout << "Demo end time (calculated): " << demo_end_time << "s\n";
+
+ // Sort sequences by start time (primary) then priority (secondary)
std::sort(sequences.begin(), sequences.end(),
[](const SequenceEntry& a, const SequenceEntry& b) {
+ float a_start = std::stof(a.start_time);
+ float b_start = std::stof(b.start_time);
+ if (a_start != b_start) return a_start < b_start;
return std::stoi(a.priority) < std::stoi(b.priority);
});