Skip to content

Commit

Permalink
fix: audio & chart out of sync in exercise mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrowhe authored and sjfhsjfh committed Feb 4, 2025
1 parent 717c116 commit 3777640
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion prpr/src/scene/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ impl GameScene {
clicked = None;
}
let mut pos = self.music.position();
if self.mode == GameMode::Exercise {
pos = tm.now() as f32;
}
if clicked.map_or(false, |it| it != -1) && (tm.speed - res.config.speed as f64).abs() > 0.01 {
debug!("recreating music");
self.music = res.audio.create_music(
Expand All @@ -528,7 +531,7 @@ impl GameScene {
reset!(self, res, tm);
}
Some(1) => {
if self.mode == GameMode::Exercise && tm.now() > self.exercise_range.end as f64 {
if self.mode == GameMode::Exercise && (tm.now() > self.exercise_range.end as f64 || tm.now() < self.exercise_range.start as f64) {
tm.seek_to(self.exercise_range.start as f64);
self.music.seek_to(self.exercise_range.start)?;
pos = self.exercise_range.start;
Expand Down

0 comments on commit 3777640

Please sign in to comment.