Skip to content

Instantly share code, notes, and snippets.

@piedoom
Created June 13, 2017 04:39
Show Gist options
  • Save piedoom/2b47ba860a0c6127996c6d16b36c8b2f to your computer and use it in GitHub Desktop.
Save piedoom/2b47ba860a0c6127996c6d16b36c8b2f to your computer and use it in GitHub Desktop.
pub fn set_voice_note_on(&mut self, note_data: NoteData){
// loop over all available voices
for voice in &mut self.voices {
// check the `VoiceState` and find one that's off
if voice.state == VoiceState::Off {
// send a note to an unused voice.
voice.note_data = note_data;
// add our voice to our vector of used voice references
self.voices_in_use.push(voice); // <===== compiles if removed
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment