Skip to content

Add readSlice function - #3

Open
reckjn wants to merge 4 commits into
masterfrom
memory-map-slice
Open

Add readSlice function#3
reckjn wants to merge 4 commits into
masterfrom
memory-map-slice

Conversation

@reckjn

@reckjn reckjn commented Mar 9, 2026

Copy link
Copy Markdown

No description provided.

reckjn and others added 4 commits March 9, 2026 08:54
#4)

AudioFileReader is a Sequence over either container, chosen by inspecting the
file rather than trusting its extension, so callers that only ever wanted samples
stop caring which format they were handed. FlacReader decodes through a vendored
dr_flac in CDrFlac; audio-file-compare exists to diff the two readers over the
same material.

The 9 AudioFileReaderTests cover the dispatch, slice repeatability and the FLAC
fixtures in Tests/Flacs.
WavReader's block iterator writes one slot per frame rather than one per
sample, so on a multi-channel file each channel overwrites the last at the
same index and only the final one survives. Half the block — for stereo — is
then left holding whatever the previous block put there, and the frame's other
channels are gone. The float and double paths make the matching mistake at the
other end, slicing from `frameIndex` where the buffer is indexed by sample, so
they read from a point n-times too early and run short of the frames they
promised.

Every fixture was mono, where a frame and a sample are the same thing, which is
why this survived. `readSlice` is unaffected: it strides by `bytesPerFrame` and
returns the first channel by design.

Found by the corpus migration's own check, comparing a stereo WAV against the
FLAC made from it through this reader: the reference decoder called them
identical and this reader disagreed at the second sample, which was the right
channel of frame 0.

The new fixture pair is stereo with different audio in each channel — the right
is the left delayed 23 samples and attenuated — because dual-mono cannot
distinguish a reader that interleaves from one that duplicates.
Interleave every channel a WAV block claims to carry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants