|
@@ -3,7 +3,7 @@ use {pitch, time, Velocity};
|
|
|
pub type Playhead = time::Samples;
|
|
|
|
|
|
/// The current state of the Voice's note playback.
|
|
|
-#[derive(Copy, Clone, Debug)]
|
|
|
+#[derive(Copy, Clone, Debug, PartialEq)]
|
|
|
pub enum NoteState {
|
|
|
/// The note is current playing.
|
|
|
Playing,
|
|
@@ -24,25 +24,25 @@ impl Voice {
|
|
|
pub fn new() -> Self {
|
|
|
Voice {
|
|
|
note: None,
|
|
|
- playhead: 0,
|
|
|
+ playhead: time::Samples(0),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// Trigger playback with the given note.
|
|
|
#[inline]
|
|
|
- pub fn note_on(&mut self, hz: NoteHz, vel: NoteVelocity) {
|
|
|
- self.maybe_note = Some((NoteState::Playing, hz, vel));
|
|
|
+ pub fn note_on(&mut self, hz: pitch::Hz, vel: Velocity) {
|
|
|
+ self.note = Some((NoteState::Playing, hz, vel));
|
|
|
}
|
|
|
|
|
|
/// Release playback of the current note if there is one.
|
|
|
#[inline]
|
|
|
pub fn note_off(&mut self) {
|
|
|
if let Some(&mut(ref mut state, _, _)) = self.note.as_mut() {
|
|
|
- *state = NoteState::Released(0);
|
|
|
+ *state = NoteState::Released(time::Samples(0));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- pub fn fill_buffer(&mut self, buffer: &mut [S]) {
|
|
|
+ pub fn fill_buffer<S>(&mut self, buffer: &mut [S]) {
|
|
|
}
|
|
|
|
|
|
}
|