fix(spectroscope): zero-pad fft samples to expected size - #24
Open
dotacow wants to merge 1 commit into
Open
Conversation
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.
First of all, thanks for making this project, it earned a place in my terminal, it is very neat & nice to look at, I also want to learn more about DSP and this is a great output of doing that.
fixes a panic that occurs when not using the PulseAudio backend
I initially ran the program
./target/debug/scope-tui audio # I also tried matching buffer size with -b512,2048, etc., didn't seem to help, expected size just kept changing to passed size/2then when I tabbed my way to the spectroscope view:
o/registry/src/index.crates.io-1949cf8c6b5b557f/rustfft-6.3.0/src/common.rs:19:5: Provided FFT buffer was too small. Expected len = 2048, got len = 512 note: run with `RUST_BACKTRACE=1` environment variable to display a backtraceI recreated the panic with gdb running, found the culprit at
src/display/spectroscope.rs:163, so I just prefixed it with a check that zero-pads the tmp buffer to match the expected sample size.I explain my process because I don't know much about the Linux audio stack, so I don't know why the accumulated buffer doesn't match the expected size, but I suspect it may be because PulseAudio protects us from this failure by automatically padding the audio peripheral queue to reach 2048 samples.