Skip to main content

MixRecord

Struct MixRecord 

Source
pub struct MixRecord {
    pub mixed: f32,
    pub external: f32,
    pub pulse1: u8,
    pub pulse2: u8,
    pub triangle: u8,
    pub noise: u8,
    pub dmc: u8,
}
Expand description

The five channel outputs that went into one mixed CPU-cycle sample, plus the result.

Channel values are the raw pre-mix outputs each channel presented — 0-15 for the two pulses, the triangle and the noise, 0-127 for the DMC — which is what the non-linear mixer consumes. They are NOT scaled by the frontend’s mixer gains: those are a presentation control, and recording post-gain values would make the record describe the user’s slider rather than the chip.

Fields§

§mixed: f32

The mixed sample handed to the band-limited decimator, including any expansion audio.

§external: f32

The expansion-audio contribution, RAW (0.0 on a cartridge without one).

Raw in the same sense as the five channel fields: before the frontend’s expansion gain and before the mixer mask. So on a muted or attenuated expansion channel this reports what the cartridge produced, not what reached mixed — consistent with pulse1 reporting a muted pulse’s output rather than zero. Both mix paths record this same raw value; an earlier revision recorded the gained value on one of them, which review caught.

§pulse1: u8

Pulse 1 output, 0-15.

§pulse2: u8

Pulse 2 output, 0-15.

§triangle: u8

Triangle output, 0-15.

§noise: u8

Noise output, 0-15.

§dmc: u8

DMC output, 0-127.

Implementations§

Source§

impl MixRecord

Source

pub fn dominant(&self) -> Option<usize>

Which channel contributed most to this sample, as an index into the conventional order (0 = pulse 1 … 4 = DMC), or None when every channel is silent.

Compares each channel’s share of its own full scale rather than its raw value, because the raw values are not commensurable: a DMC 127 and a pulse 15 are both “full scale” on different scales.

That normalisation is linearvalue / max — and deliberately does NOT model the non-linear mixer, which an earlier draft of this comment claimed it did. The two give different answers, since the mixer weights the triangle/noise/DMC group differently from the pulses and is not proportional in either. This reports which channel is working hardest relative to what it can do, which is the question a user pointing at a cycle is asking; attributing loudness in the final mix would be a different function, and calling this one that would be a false label on a correct computation.

Trait Implementations§

Source§

impl Clone for MixRecord

Source§

fn clone(&self) -> MixRecord

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 MixRecord

Source§

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

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

impl Default for MixRecord

Source§

fn default() -> MixRecord

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

impl PartialEq for MixRecord

Source§

fn eq(&self, other: &MixRecord) -> 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 Copy for MixRecord

Source§

impl StructuralPartialEq for MixRecord

Auto Trait Implementations§

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.