ConstComplete resident source bytes and an explicit mono output rate.
The ingest decoder admits RIFF/WAVE 16-bit PCM or 32-bit float, mono or stereo. Invalid fields throw an asset/field diagnostic; allocation errors may propagate because no product memory budget bounds the requested rate.
Complete RIFF/WAVE file, borrowed unchanged for the synchronous decode.
Diagnostic label used verbatim in refusal messages; no file is opened and no path validation is performed.
Positive safe-integer output samples per second, validated by the decoder; no default or upper product budget.
The source facts as declared and new mono samples the caller owns.
Decode one complete supported RIFF/WAVE file into finite mono samples at a requested rate.
The parser walks the RIFF chunks by id, requires the declared RIFF extent,
nBlockAlign, andnAvgBytesPerSecto agree with the format fields, and refuses a duplicatefmtordatachunk, an odd chunk without its pad byte, and terminal bytes too short for a chunk header. An extensible header follows the Microsoft WAVEFORMATEXTENSIBLE contract (https://learn.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-waveformatextensible): "The cbSize member must be at least 22",wValidBitsPerSample"can be any value not exceeding the container size", "the channels specified in dwChannelMask must be present in the prescribed order (from least significant bit up)" with SPEAKER_FRONT_LEFT0x1, SPEAKER_FRONT_RIGHT0x2, and SPEAKER_FRONT_CENTER0x4, and "the number of bits set in dwChannelMask should be the same as the number of channels". The SubFormat is admitted only when every byte after its leading 16-bit tag equals thexxxxxxxx-0000-0010-8000-00aa00389b71template that Ksmedia.h'sIS_VALID_WAVEFORMATEX_GUIDcompares (https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/converting-between-format-tags-and-subformat-guids), so a vendor GUID whose low word happens to read as PCM is not decoded as PCM.The supported subset is deliberately narrow: 16-bit PCM in a 16-bit container, 32-bit IEEE float in a 32-bit container, mono front-center, and stereo front-left/front-right. A legal declaration outside it, such as 20 valid bits in a 24-bit container or a front-left/front-center pair, is refused as unsupported by field rather than misread as the nearest supported layout. Every decoded sample is checked finite before the mono fold and before any resampling, so a NaN or infinity in one channel refuses the whole asset at its frame and channel instead of averaging into a plausible number.
PCM codes scale by 1/32768, so -32768 reads as exactly -1 and 32767 just under 1. Stereo folds to the mean of its two channels. A source at another rate is resampled by linear interpolation between neighboring source samples, holding the last sample past the end, to
round(frames * rate / sourceRate)samples, which may round to zero for a short source and a low target rate. No low-pass filter runs first, so downsampling a source with content above the target Nyquist frequency aliases it.Field admission refusals throw
Audio asset "<path>" [<reason>] <message>, where the reason names the field, such asriff-size,block-align, orunsupported-wave-layout. Buffer size follows source frames and the requested rate ratio; this function imposes no product memory budget, so platform allocation errors may propagate outside that refusal format.