Skip to content

Instantly share code, notes, and snippets.

@piedoom
Created June 12, 2017 22:20
Show Gist options
  • Save piedoom/17b088b2783f5ece4fcc9f16fda034d5 to your computer and use it in GitHub Desktop.
Save piedoom/17b088b2783f5ece4fcc9f16fda034d5 to your computer and use it in GitHub Desktop.
pub fn set_voice_note_off(&mut self, note_data: NoteData){
for voice in &mut self.voices {
match voice.state {
// we only care if the note is currently on
VoiceState::On => {
// check if this voice is currently playing the note desired to be turned off
if voice.note_data.note == note_data.note {
// success - we found the voice to turn off
// replace the stored `voice.note_data` with our new `note_data`
voice.note_data = note_data;
}
}
// we don't care about anything else here
_ => return
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment