Skip to content

Commit

Permalink
Merge pull request #28 from subalterngames/no_play
Browse files Browse the repository at this point in the history
Fixed: Can't play music when a new save file loads
  • Loading branch information
subalterngames authored Jan 16, 2024
2 parents a0f3ba0 + 364fe08 commit 9fef5d0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion audio/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ impl Conn {
synth.set_sample_rate(self.framerate);
drop(synth);

// Enqueue note events.
let mut midi_event_queue = self.midi_event_queue.lock();
// Clear the queue before adding new events.
midi_event_queue.clear();
// Enqueue note events.
for track in state.music.get_playable_tracks().iter() {
for note in track.get_playback_notes(state.time.playback) {
// Note-on event.
Expand Down
5 changes: 5 additions & 0 deletions audio/src/midi_event_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ impl MidiEventQueue {
}
midi_events
}

/// Clear the queue.
pub(crate) fn clear(&mut self) {
self.events.clear()
}
}
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fixed: There was an input bug where the play/start key (spacebar) was sometimes unresponsive for the first few presses. This is because audio was still decaying from a previous play, meaning that technically the previous play was still ongoing.
- Fixed: When a new file is created or when a new save file loaded, the app didn't reset correctly.
- Fixed: If you try to play music and there are no tracks or no playable notes, the app starts playing music and then immediately stops.
- Fixed: If you're playing music and then load a save file, the save file can't play music because the synthesizer still has MIDI events from the previous music.

## 0.2.1

Expand Down

0 comments on commit 9fef5d0

Please sign in to comment.