Fix QPSK encoder for Python 3 compatibility#1
Open
ogabrielluiz wants to merge 1 commit into
Open
Conversation
Python 2→3 migration: symbol_stream / 2 became float division, corrupting the QPSK constellation (values -1,0,1,2 instead of ±1). Produced ~20% sample clipping vs ~12% correct, making firmware WAVs unreliable to flash. Fix: use // operator. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
qpsk/encoder.py:symbol_stream / 2uses float division in Python 3, corrupting the QPSK modulation constellation. Values that should be ±1 become -1, 0, 1, 2 — producing ~20% sample clipping (vs ~12% with correct encoding) and making firmware WAVs unreliable or impossible to flash via the audio bootloader.//(integer division) operator.byteshandling, removal ofLsuffixes,xrange→range, etc.Context
Discovered while building custom Clouds firmware and failing to flash via audio bootloader. The official firmware WAVs (generated with Python 2) worked fine, but locally-generated WAVs (Python 3) consistently failed with red blinking error LEDs on the module. Root cause traced to the corrupted QPSK constellation from float division.
The 4ms fork independently worked around this with
.astype(int)but never submitted upstream.Test plan