pub struct Owner {
pub channels: [Channel; 24],
pub latest: [u8; 42],
/* private fields */
}Expand description
The channel table and program map.
Fields§
§channels: [Channel; 24]The 24 channels; channel 0 is never allocated.
latest: [u8; 42]The last channel each program was given, kept after replacement.
Implementations§
Source§impl Owner
impl Owner
Sourcepub fn play(&mut self, program: u8, priority: i16, duration: i16) -> Option<u8>
pub fn play(&mut self, program: u8, priority: i16, duration: i16) -> Option<u8>
Start a note for program: the first free channel, else the first
finite note with a strictly lower priority (a larger number). Loops are
never taken and equal priority cannot steal.
let mut o = Owner::new();
for _ in 1..24 {
o.play(7, 1, 20);
}
assert_eq!(o.play(7, 1, 20), None); // equal priority cannot steal
assert_eq!(o.play(7, 0, 20), Some(1)); // a more important note canSourcepub fn kill(&mut self, program: u8)
pub fn kill(&mut self, program: u8)
Native KillNote follows the program’s last channel, even when its prior note ended or was replaced. It releases after eight updates.
let mut o = Owner::new();
let ch = o.play(3, 1, 50).unwrap();
o.kill(3);
assert_eq!(o.channels[ch as usize].duration, NOTE_RELEASE);Sourcepub fn stop_all(&mut self)
pub fn stop_all(&mut self)
Free every channel. Like the original KillAllFx it keeps the program-to-channel identities.
let mut o = Owner::new();
o.play(1, 0, -1);
o.stop_all();
assert_eq!(o.channels[1].duration, 0);Sourcepub fn update(&mut self, paused: bool) -> Update
pub fn update(&mut self, paused: bool) -> Update
One UpdateNotes call. A change of paused returns a save or restore
and no tick; otherwise every note ages by one, fading in its last
NOTE_FADE_STEPS updates and keying off on its last.
let mut o = Owner::new();
o.play(1, 1, 1);
assert_eq!(o.update(false).key_off, 1 << 1);