Skip to content

Read FLAC as well as WAV, behind one reader that dispatches on content - #4

Merged
ephemer merged 1 commit into
memory-map-slicefrom
flac-support
Aug 10, 2026
Merged

Read FLAC as well as WAV, behind one reader that dispatches on content#4
ephemer merged 1 commit into
memory-map-slicefrom
flac-support

Conversation

@ephemer

@ephemer ephemer commented Aug 10, 2026

Copy link
Copy Markdown
Member

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

Based on memory-map-slice (0bd273c), which is the branch AudioToMIDI-Training pins, so merging here moves that pin with no manifest change.

Why this is needed downstream

AudioToMIDI-Training already calls AudioFileReader from Dataset.swift, EntryPoint+Transcription.swift and MelSegments.swift. Those call sites cannot compile against the pinned revision, and the failure is confusing rather than obvious: swift package edit records the edit in .build/workspace-state.json, but xcodebuild reads its own .build/xcode/SourcePackages/workspace-state.json, which still says sourceControlCheckout. So xcodebuild silently compiles the pinned checkout and reports cannot find 'AudioFileReader' in scope while the type sits right there in the working tree.

Verification

  • swift build clean.
  • swift test: 10/10 pass, including 9 AudioFileReaderTests covering content-based dispatch, slice repeatability, and the FLAC fixtures in Tests/Flacs.

Contents

Sources/WavReader/AudioFileReader.swift the dispatching reader
Sources/WavReader/FlacReader.swift FLAC decode path
Sources/CDrFlac/ vendored dr_flac (528 K, 3 files)
Sources/AudioFileCompare/ audio-file-compare diff tool
Tests/Flacs/ 4 FLAC fixtures (224 K)
Package.swift +17 lines for the new targets

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.
@ephemer
ephemer merged commit 8d33d96 into memory-map-slice Aug 10, 2026
@ephemer

ephemer commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

FYI @reckjn

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.

1 participant