Psg

Struct Psg 

Source
pub struct Psg {
    pub switches: PsgSwitches,
    pub channels: [Channel; 6],
    pub select: u8,
    pub balance: u8,
    pub lfo_frequency: u8,
    pub lfo_control: u8,
    pub step: i64,
    pub rate_hz: f64,
    pub gain: f64,
    /* private fields */
}

Fields§

§switches: PsgSwitches

Switches, not state: a loaded state keeps the system’s own.

§channels: [Channel; 6]§select: u8§balance: u8

R1

§lfo_frequency: u8

R8

§lfo_control: u8

R9

§step: i64

steps run so far

§rate_hz: f64§gain: f64

Implementations§

Source§

impl Psg

Source

pub fn new(rate_hz: f64, switches: PsgSwitches) -> Psg

Source

pub fn attenuation(&self, ch: usize, side: usize) -> usize

Units of 1.5 dB below the maximum for a channel on one side (0 left, 1 right): R1 and R5 step 3 dB, R4 1.5 dB [mfr 2.1.2, 2.1.5, 2.1.6, 2.3]. 30 or more is silent.

Source

pub fn write(&mut self, offset: u32, value: u8, mclk: i64)

Source

pub fn state(&self) -> [(i32, usize, usize); 6]

Per channel (sample, units left, units right) for the step about to run; sample is -1 for a channel that is off (it contributes nothing).

Source

pub fn advance_to(&mut self, target: i64)

Run the steps up to (not including) step target.

Source

pub fn take_samples(&mut self, mclk: i64) -> Vec<(i32, i32)>

Stereo samples at rate_hz up to mclk since the last call (a box average of the step stream; the reference check is the unresampled step stream).

Trait Implementations§

Source§

impl AudioSource for Psg

Source§

fn rate_hz(&self) -> f64

Source§

fn gain(&self) -> f64

Source§

fn applies_gain(&self) -> bool

True when the source’s samples already carry its gain (the PSG): the mixer must not apply it a second time.
Source§

fn take_samples(&mut self, mclk: i64) -> Vec<(i32, i32)>

Stereo samples produced up to mclk since the last call.
Source§

impl Clone for Psg

Source§

fn clone(&self) -> Psg

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 Psg

Source§

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

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

impl Default for Psg

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Psg

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl DeviceState for Psg

Source§

fn save_state(&self) -> Vec<u8> ⓘ

Everything of the device that changes as the console runs.
Source§

fn load_state(&mut self, data: &[u8]) -> Result<(), String>

Put the device in a saved state. A device without state accepts only an empty one.
Source§

fn state_identity(&self) -> String

What the device is and which media it holds (a card’s ROM by its SHA-1, a disc by its table of contents): a state is refused by a system whose device answers otherwise.
Source§

impl PartialEq for Psg

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PsgPins for Psg

Source§

fn write(&mut self, offset: u32, value: u8, mclk: i64)

Source§

impl Serialize for Psg

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Psg

Auto Trait Implementations§

§

impl Freeze for Psg

§

impl RefUnwindSafe for Psg

§

impl Send for Psg

§

impl Sync for Psg

§

impl Unpin for Psg

§

impl UnwindSafe for Psg

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,