Repository navigation
Conversation
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.
Fixes #533
Summary
Fixes three bugs in
PulseAudioSoundManagerthat caused Linux sound visualization to lose low and high frequencies, suffer spectral leakage, and drop/corrupt buffered leftover samples, and addresses Round-1 review feedback:Hann window sizing (
PulseAudioSoundManager::init_buffers):m_weightstom_buffer_samples(fftSize() * 2 = 2048) instead offftSize() + 1(1025), and initialize with normalizedWINDOW_HANNING.m_buffer_samples = fftSize() * 2and channel defaults are consistently initialized.Time-domain windowing, multi-channel downmix & FFT amplitude scaling (
PulseAudioSoundManager::process_fft):m_weights[i]in the time domain prior tofftwf_execute(m_plan)instead of multiplying FFT magnitudes bym_weights[i]in the frequency domain (which previously zeroed out low and high frequency bins).m_ss.channels > 1while keeping a direct fast path for mono (channels == 1).std::hypotfand scale AC bins (i > 0) by2.0f(1.0ffor DCi == 0), matching the normalized Hann window gain so a unit-amplitude sine wave yields magnitude~1.0(consistent with Windows BASSWASAPI / macOS vDSP).Stream buffer leftover sample tracking (
PulseAudioSoundManager::stream_read_cb/consumeAudioData):consumeAudioData()to loop over all complete frames inpadata, invokingprocess_fft()whenever a fullm_buffer_samplesframe completes and accurately preserving any remaining sample count inm_pa_samples_read(instead of resettingm_pa_samples_read = 0or discarding data across oversized chunks).pa_stream_dropwhenpa_stream_peekreturnspadata == nullptr && nbytes == 0.Testing
PulseAudioSoundManagerTest(Software/tests/PulseAudioSoundManagerTest.hpp/.cpp), guarded underunix:!macx:contains(DEFINES, PULSEAUDIO_SUPPORT)inSoftware/tests/tests.pro(supportingPULSEAUDIO_INC_DIR/FFTW3_INC_DIR/PULSEAUDIO_LIB_DIR/FFTW3_LIB_DIR, usingpackagesExist(libpulse fftw3f)forPKGCONFIG += libpulse fftw3fwithLIBS += -lpulse -lfftw3ffallback) and#if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) && defined(PULSEAUDIO_SUPPORT)inSoftware/tests/TestsMain.cpp.qmake6 -r && make -j2andQT_QPA_PLATFORM=offscreen ./bin/LightpackTestson Linux:PULSEAUDIO_SUPPORTenabled: all 9 test suites passed (0 failed,0 skipped), includingPulseAudioSoundManagerTest(12 passed, 0 failed, covering Hann weights, low/mid/high frequencies, fractional-bin sidelobe suppression, DC/amplitude scaling, leftover sample tracking, stereo and 4-channel downmix, and end-to-endSoundVisualizerLED output withqScopeGuardsettings cleanup).PULSEAUDIO_SUPPORTdisabled: clean build and all 8 remaining test suites passed (0 failed,0 skipped).libpulse.pc/fftw3f.pcabsent fromPKG_CONFIG_LIBDIRand custom*_INC_DIR/*_LIB_DIRpaths:qmake6cleanly fell back to-L... -lpulse -lfftw3f.