Skip to main content

Pulse

Struct Pulse 

Source
pub struct Pulse {
    pub envelope: Envelope,
    pub length: LengthCounter,
    /* private fields */
}
Expand description

Pulse channel state.

Fields§

§envelope: Envelope

Envelope generator.

§length: LengthCounter

Length counter.

Implementations§

Source§

impl Pulse

Source

pub const fn new(is_pulse1: bool) -> Self

Construct a new pulse channel. is_pulse1=true for the pulse-1 sweep negation flavor (one’s complement).

Source

pub fn write_ctrl(&mut self, value: u8)

$4000 / $4004 write: duty + length-halt + envelope.

Source

pub fn write_sweep(&mut self, value: u8)

$4001 / $4005 write: sweep config.

Source

pub fn write_timer_lo(&mut self, value: u8)

$4002 / $4006 write: timer low.

Source

pub fn write_timer_hi(&mut self, value: u8)

$4003 / $4007 write: length load + timer high.

Source

pub fn clock_timer(&mut self)

One APU clock (half CPU clock).

Source

pub fn clock_half_frame(&mut self)

Half-frame clock: sweep + length.

Source

pub fn clock_quarter_frame(&mut self)

Quarter-frame clock: envelope.

Source

pub fn muted(&self) -> bool

Sweep mute: timer < 8 OR target > $7FF.

Source

pub fn output(&self) -> u8

Per-cycle output volume (0..=15).

Trait Implementations§

Source§

impl Clone for Pulse

Source§

fn clone(&self) -> Pulse

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Pulse

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for Pulse

Auto Trait Implementations§

§

impl Freeze for Pulse

§

impl RefUnwindSafe for Pulse

§

impl Send for Pulse

§

impl Sync for Pulse

§

impl Unpin for Pulse

§

impl UnsafeUnpin for Pulse

§

impl UnwindSafe for Pulse

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.