summaryrefslogtreecommitdiff
path: root/lib/level.dart
diff options
context:
space:
mode:
authorOrangerot <purple@orangerot.dev>2024-12-29 16:49:42 +0100
committerOrangerot <purple@orangerot.dev>2024-12-29 16:49:42 +0100
commitf577670d7564b24dfe8cc247459670a2d7ef5bab (patch)
treefbf29aa99ecd3f9cde927cea07f1edbb250c6b9f /lib/level.dart
parent5a763a5de26981c7d015a9e6276017b0f6c12f67 (diff)
style: refactored time offset generation of beat inside of Simfile class
Diffstat (limited to 'lib/level.dart')
-rw-r--r--lib/level.dart23
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/level.dart b/lib/level.dart
index 548a752..a6d4967 100644
--- a/lib/level.dart
+++ b/lib/level.dart
@@ -125,24 +125,13 @@ class _LevelState extends State<Level> {
simfile = Simfile(simfilePath);
simfile!.load();
- double bpm = simfile!.bpms.entries.first.value;
-
- for (final (measureIndex, measure)
- in simfile!.chartSimplest!.measures!.indexed) {
- for (final (noteIndex, noteData) in measure.indexed) {
- int arrowIndex = noteData.indexOf('1');
- if (arrowIndex < 0 || arrowIndex > 3) {
- continue;
- }
- double beat =
- measureIndex * 4.0 + (noteIndex.toDouble() / measure.length) * 4.0;
- double minutesPerBeat = 1.0 / bpm;
- double offsetMinutes = simfile!.offset / 60.0;
- notes.add(Note(
- time: beat * minutesPerBeat + offsetMinutes,
- direction: ArrowDirection.values[arrowIndex]));
+ simfile!.chartSimplest!.beats.forEach((time, noteData) {
+ int arrowIndex = noteData.indexOf('1');
+ if (arrowIndex < 0 || arrowIndex > 3) {
+ return;
}
- }
+ notes.add(Note(time: time, direction: ArrowDirection.values[arrowIndex]));
+ });
print(audioPath);