Fix onset click#319
Open
Allan-xmos wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the StandardPdmRxService::ThreadEntry() startup behavior to reduce audible onset artifacts by ignoring obviously invalid initial PDM reads and emitting a known fill pattern until valid-looking data arrives.
Changes:
- Add a pre-start loop that reads the PDM port, fills outgoing blocks with
0x55pattern data, and waits for “good” reads before switching to real samples. - Begin streaming blocks immediately during startup (with the fill pattern) while waiting for valid port data.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| s_chan_out_word(this->c_pdm_blocks.end_a, reinterpret_cast<uint32_t>(ready_block)); | ||
| } | ||
| if (data == 0x00000000 || data == 0xFFFFFFFF) { |
Comment on lines
+484
to
+491
| if(!phase){ | ||
| this->phase = this->num_phases; | ||
| uint32_t* ready_block = this->blocks[0]; | ||
| this->blocks[0] = this->blocks[1]; | ||
| this->blocks[1] = ready_block; | ||
|
|
||
| s_chan_out_word(this->c_pdm_blocks.end_a, reinterpret_cast<uint32_t>(ready_block)); | ||
| } |
Comment on lines
+479
to
+482
| // During boot, the PDM port may read all 0s or all 1s. | ||
| // Output 0x55 (zero) to the buffer until we get a valid frame. | ||
| uint32_t data = port_in(this->p_pdm_mics); | ||
| this->blocks[0][--phase] = 0x55555555; |
| this->blocks[0] = this->blocks[1]; | ||
| this->blocks[1] = ready_block; | ||
|
|
||
| s_chan_out_word(this->c_pdm_blocks.end_a, reinterpret_cast<uint32_t>(ready_block)); |
| S[:,P:] = sig_in | ||
| return S | ||
|
|
||
| def boot_logic(self, pdm_signal: np.ndarray) -> np.ndarray: |
| Q = self.DecimationFactor | ||
| N_pcm = SAMPS_IN // self.DecimationFactor | ||
|
|
||
| pdm_signal = self.boot_logic(pdm_signal) |
Comment on lines
+89
to
+92
| CHANS, SAMPS_IN = pdm_signal.shape | ||
| BOOT_WORD = np.uint32(0x55555555) | ||
| spw = 32 // CHANS # PDM samples per channel packed per interleaved word | ||
| total_words = SAMPS_IN // spw |
Comment on lines
+479
to
+481
| // During boot, the PDM port may read all 0s or all 1s. | ||
| // Output 0x55 (zero) to the buffer until we get a valid frame. | ||
| uint32_t data = port_in(this->p_pdm_mics); |
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.
Wait for data on the port that isn't 0 or 1, send 55 while waiting