Repository navigation
Conversation
The float path (bit_depth=None) computed the padding from the frame size instead of the input length, so a mono input shorter than a frame was never padded and encode() failed with "Buffer size too small" from ctypes. The docstring says input shorter than a frame is zero padded, as the 16/24-bit paths already do.
This branch has not been deployed
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.
Encoder.encode()documents that PCM input shorter than a frame is padded with zeros. The 16/24-bit path does this. The float path computes the padding aspcm_len - frame_samplesinstead of from the input length, so:ValueError: Buffer size too small ...from ctypes;(num_channels - 1) * frame_samples, so input shorter than one channel's frame fails the same way.This change pads up to
pcm_lenbased on the actual buffer length, the same way the integer path does. Full-length input is unchanged. Multi-channel full-length input no longer gets an unused zero tail appended.Test:
test_encode_pads_short_inputinpython/tests/basic_test.pychecks that encoding a short input gives the same bytes as encoding the same input explicitly zero-padded on a fresh encoder, for 1 and 2 channels and float/16/24-bit input. Before this change the float cases fail withValueError; the 16/24-bit cases pass both before and after.This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.