Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full audio fastpath (part2) #141

Merged
merged 10 commits into from
Jul 5, 2024
Merged

Full audio fastpath (part2) #141

merged 10 commits into from
Jul 5, 2024

Conversation

softhack007
Copy link
Collaborator

@softhack007 softhack007 commented Jul 1, 2024

This PR allows the audio core to deliver sound data and FFT results 2x faster (43 sps --> 87 sps).

The concept behind this PR is called "sliding window FFT" (aka 50% overlapping FFT). In normal FFT a full batch of samples is first read then analyzed. With sliding window, 50% old samples and 50% new samples are put into each FFT run. This leads to faster responses (new samples arrive twice as fast) and improved accuracy of FFT (samples suppressed by windowing get a second chance in the next run). It also requires twice the number of FFT runs, so you'll need a fast MCU.

  • Frequency reactive effects (GEQ, FreqMap, DJLight) will have improved "on-spot" reactions, and will typically react to audio changes within 10-20 milliseconds.
  • Volume reactive effect will react a bit better (but still lagging behind, due to legacy filtering design that was created when only low-quality analog mics were available).

Limitations

  • only works on esp32-S3 and classic esp32, due to higher CPU load for FFT
  • Will not work well with analog microphone
  • UDP sound sync clients might get "flooded" (twice the number of audio updates need to be handled)

how to configure

image

Info Page (with SR_STATS enabled)

Normal mode
image

== > Fastpath Mode ==>
image

* introducing sliding window FFT, which effectively doubles the rate of samples - and FFT results - produced per second. As a side-effect, it also makes FFT a bit less noisy.

As sliding window FFT requires double the number of FFT runs, the feature is only enabled on esp32 and esp32-S3.
@softhack007 softhack007 marked this pull request as draft July 3, 2024 15:57
* limiter on/off : made the logic a bit clearer.
* use a simpler way of writing filters: a = n*a + (1-n)*b --> a = a+ n*(b-a)

no functional impact.
samples arrive 2x as fast in fast mode - adjust filters accordingly
@softhack007
Copy link
Collaborator Author

softhack007 commented Jul 4, 2024

new: user-selectable "FFT windowing" functions.

Why: depending on the audio signal, one or the other window may give better-looking results.

Name Comment FFT Effect (smearing of single frequency)
no window n/a in WLED-MM
Hamming nothing special - peaks a bit sharper than "Hann", but strong noise floor
Hann Recommended for generic signals
Blackman
Nuttall good side-lobe suppression
Blackman-Harris produces clear peaks
Flat-Top good amplitude preservation, bad frequency resolution

https://en.wikipedia.org/wiki/Window_function#Cosine-sum_windows

@softhack007 softhack007 marked this pull request as ready for review July 4, 2024 20:22
*some filter parameter tinkering
* restore FFT_MajPeakSmth in UDP SoundSync receiver
* mic quality: When set to "low noise" or "perfect", only minimal smoothing is performed on the "Mic Volume" input.
Every filter adds a delay, so this option can lead to better on-spot responses from effects.

* cleanup: removed a few unused variables and unused code.
@softhack007 softhack007 merged commit 4b6d890 into mdev Jul 5, 2024
70 checks passed
@softhack007 softhack007 deleted the Full_audio_FastPath branch October 11, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant