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: f32The mixed sample handed to the band-limited decimator, including any expansion audio.
external: f32The 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: u8Pulse 1 output, 0-15.
pulse2: u8Pulse 2 output, 0-15.
triangle: u8Triangle output, 0-15.
noise: u8Noise output, 0-15.
dmc: u8DMC output, 0-127.
Implementations§
Source§impl MixRecord
impl MixRecord
Sourcepub fn dominant(&self) -> Option<usize>
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 linear — value / 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.