Skip to main content

Noise

Struct Noise 

Source
pub struct Noise { /* private fields */ }
Expand description

Channel 4’s settings.

The pitch is a clock divider and shift rather than a note, since what comes out is noise and is chosen by ear.

Implementations§

Source§

impl Noise

Source

pub const fn new(volume: u8, divider: u8, shift: u8) -> Self

Noise at volume, out of 15, clocked at 262144 / (divider << shift) hertz, where a divider of 0 counts as a half.

A volume of 0 is not a quiet sound but a stopped channel: it turns the DAC off, and a channel whose DAC is off will not start.

A shift of 14 or 15 stops the clock, and neither is reachable here.

Source

pub const fn short_lfsr(self) -> Self

Run the shift register seven bits wide, which repeats often enough to carry a pitch.

Source

pub const fn envelope(self, pace: u8, increase: bool) -> Self

Step the volume every pace ticks of a 64 Hz count, up or down.

A pace of 0 holds the volume where Noise::new put it.

Source

pub const fn length(self, ticks: u8) -> Self

Stop the channel after ticks of a 256 Hz count, at most 64.

Source

pub fn play(&self)

Play on channel 4.

Trait Implementations§

Source§

impl Clone for Noise

Source§

fn clone(&self) -> Noise

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Noise

Source§

impl Eq for Noise

Source§

impl PartialEq for Noise

Source§

fn eq(&self, other: &Noise) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Noise

Auto Trait Implementations§

§

impl BankSafe for Noise

§

impl Freeze for Noise

§

impl RefUnwindSafe for Noise

§

impl Send for Noise

§

impl Sync for Noise

§

impl Unpin for Noise

§

impl UnsafeUnpin for Noise

§

impl UnwindSafe for Noise

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CellValue for T
where T: Copy + BankSafe,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.