Skip to content

AudioChannel ​

Struct

Source: AudioTypes.h

Description ​

Represents the internal state of a single audio channel.

Designed to be static and memory-efficient.

Properties ​

NameTypeDescription
dutyStepsconst SfxBreakpoint*Duty stepped table (PULSE); nullptr/0 = use duty + dutySweep.
dutyStepIndexuint8_tNext duty step index to apply; == count when finished.
dutyNextBoundarySamplesuint32_tSample age at which the next duty step applies (UINT32_MAX = none).
automationAgeSamplesuint32_tSamples since voice start (duty/pitch automation clock).
pitchEnvelopeconst SfxBreakpoint*Pitch envelope table; runtime multi-segment when count >= 2.
pitchSegIndexuint8_tStart-point index of the active pitch segment (0 .. count-2).
pitchSegStartAgeuint32_tAbsolute sample age at the start of the active pitch segment.
pitchSegLenSamplesuint32_tLength of the active pitch segment in samples (0 = hold final value).
noiseShortModebool@deprecated Use noiseLfsrShort. Will be removed in a future major version.
triangleQuantize4BitboolWhen type == TRIANGLE: quantize output to 4-bit NES levels (32 steps).
triangleOctaveUpboolWhen type == TRIANGLE: double the effective frequency at initVoiceFromEvent time, matching the NES convention where TRIANGLE is exactly one octave below PULSE for the same period value.
pulseDutyIndexuint8_tWhen type == PULSE: 0..3 selects the NES discrete duty pattern (12.5% / 25% / 50% / 75%); 255 = use continuous dutyCycle (default).
nesNoiseLutIndexuint8_tNOISE LUT index: 0..15 select a NES noise period from nes_apu::kNesNoisePeriodLutNtsc; 255 = derive the period from frequency (default, legacy behaviour).
noisePeriodSamplesuint32_tSamples until next LFSR step on NOISE; frequency sets noise clock rate (not pitch).
noiseCountdownuint32_tCounts down each output sample; at 0 the LFSR advances and reloads to noisePeriodSamples.
loopboolContinuous voice: no auto-disable; cleared only by STOP_CHANNEL / steal.
noiseUnipolarboolWhen type == NOISE: gate the LFSR output between 0 and the envelope level instead of between -level and +level.
noiseUnipolarOverriddenboolSet once the caller pinned noiseUnipolar explicitly.
nesNoiseLutOverriddenboolSet once the caller pinned nesNoiseLutIndex explicitly.
sweepSamplesTotaluint32_tTotal samples for the sweep.
sweepSamplesRemaininguint32_tSamples remaining in the sweep.
sweepStartHzfloatStarting frequency in Hz (NOISE: LFSR clock).
sweepEndHzfloatEnding frequency in Hz (NOISE: LFSR clock).
sweepStartIncQ32uint32_tMelodic: Q32 phase inc start; NOISE: start period.
sweepEndIncQ32uint32_tMelodic: Q32 phase inc end; NOISE: end period.
sweepCurveSweepCurveActive sweep curve (may fallback to Linear).
sweepLogRatiofloatFPU Exponential: logf(endHz/startHz).
sweepLogStartQ16int32_tQ15 path Exponential: log2(start) in Q16.
sweepLogDeltaQ16int32_tQ15 path Exponential: log2(end/start) in Q16.
nesLengthCounterNesLengthCounterNES APU length counter state for this voice.
nesLinearCounterNesLinearCounterNES APU linear counter state for this voice (TRIANGLE).
nesSweepUnitNesSweepUnitNES APU sweep unit state for this voice (PULSE).
nesEnvelopeNesEnvelopeNES APU envelope unit state for this voice (PULSE / NOISE).
envelopeCurveEnvelopeCurveResolved ADSR curve for this voice (S2).
pulseDutyOverriddenboolSet once the caller pinned the PULSE duty mode of the slot.
decayCurveRateQ15uint16_tClock of the exponential curve (S2): one rate per stage plus a shared Q15 phase accumulator.

Methods ​

void reset() ​

Description:

Resets the channel to a clean disabled state.

Released under the MIT License.