Repository navigation
wav_chunks: one public RIFF chunk walker, fast overrun scan - #16
Merged
Merged
Conversation
…running data (voxy#85)
… on the same walker (voxy#85)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
recode.wav_chunks(wav_bytes)(yieldsWavChunk(chunk_id, offset, size)), the one RIFF chunk walker asked for in thorwhalen/voxy#85; voxy then drops its own and imports this.decode_wav_bytes/_wav_data_chunknow locatedatathrough it, so recode has one walker too. Adatachunk whose declared size is a placeholder (0, or past the end) ends where the chunks after it begin, or at the end of the buffer. The scan for that point is now fast: known trailing ids (LIST, id3, bext, ...) are matched first by a compiled regex, then any printable-ASCII id; 10 minutes of 24 kHz audio takes about 0.26 s (it took several seconds scanning every word in Python). A trailer missing its final pad byte is accepted.Behaviour change: declared size
0followed by other chunks now decodes the audio (it decoded zero samples before). No test pinned the old result.Adversarial review (Fable): first version not landable: the fast known-id pass was dead code (my edit had not applied), the missing-pad-byte trailer regressed against voxy's walker, and
decode_wav_bytesstill used a second walker while the docstring said otherwise. Fixed all three, plusWavChunkas a NamedTuple, private id table, tests for printable-audio, missing pad byte, bytearray/memoryview input anddecode_wav_bytesagreeing withwav_chunks. Left as documented quirk: an unknown chunk ahead of a known one is read as audio.164 passed (156 before + 8 new), doctests pass.