Skip to main content
← PSoXide SDK guides and examples · SDK 80d1c329e977 · All Cargo features enabled; check feature gates before use.

Owner

Struct Owner 

Source
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

Source

pub const fn new() -> Self

An owner with every channel free.

Source

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 can
Source

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);
Source

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);
Source

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);

Trait Implementations§

Source§

impl Default for Owner

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Owner

§

impl RefUnwindSafe for Owner

§

impl Send for Owner

§

impl Sync for Owner

§

impl Unpin for Owner

§

impl UnsafeUnpin for Owner

§

impl UnwindSafe for Owner

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.