Skip to content

Commit

Permalink
Fix background music playback
Browse files Browse the repository at this point in the history
I don't know yet if it's a bug in kira or working as designed.
  • Loading branch information
hasenbanck committed Dec 29, 2024
1 parent 68e3746 commit 18c2924
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion korangar_audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,14 @@ impl<F: FileLoader> EngineContext<F> {
}
};

let data = data.output_destination(&self.background_music_track).loop_region(..);
// Workaround: It seems kira drops the music as soon as it finishes, even though
// we defined the loop region to be the full region of the music. We shave off
// 50 ms of the music, so that the music never finishes, and we properly loop
// the music again.
let duration = data.duration().as_secs_f64() - 0.05;
let data = data.loop_region(..duration);
let data = data.output_destination(&self.background_music_track);

let handle = match self.manager.play(data) {
Ok(handle) => handle,
Err(_error) => {
Expand Down

0 comments on commit 18c2924

Please sign in to comment.