Skip to content

Add Audio Variables — Bass/Mid/Treble Band Energy Extraction - #7

Open
lannerwsf wants to merge 2 commits into
devlup-labs:mainfrom
lannerwsf:main
Open

Add Audio Variables — Bass/Mid/Treble Band Energy Extraction#7
lannerwsf wants to merge 2 commits into
devlup-labs:mainfrom
lannerwsf:main

Conversation

@lannerwsf

Copy link
Copy Markdown

Add Audio Variables — Bass/Mid/Treble Band Energy Extraction

Closes #2

Changes

This PR adds frequency band energy extraction with EMA smoothing to the audio processing pipeline, following the projectM reference implementation pattern.

audio/FFTProcessor.h / audio/FFTProcessor.cpp

  • Added computeBandEnergies() private method that divides FFT magnitude bins into three frequency ranges:
    • Bass: 20–250 Hz (bins 1–~12)
    • Mid: 250–4000 Hz (bins ~12–~186)
    • Treble: 4000 Hz – Nyquist (~186+)
  • Each band's energy is the mean magnitude across its bins (DC bin 0 excluded from bass)
  • Added EMA smoothing for attenuated variants (bassAtt, midAtt, trebleAtt) with smoothing factor SMOOTHING = 0.15
  • Added public getters: getBass(), getMid(), getTreble(), getBassAtt(), getMidAtt(), getTrebleAtt()

src/Audio.h / src/Audio.cpp

  • Added corresponding public getters that delegate to the underlying FFTProcessor
  • Thread-safe — call after getFFTData() in the same render cycle context

Verification

  • Band energies are recomputed every FFT frame alongside magnitudes
  • Attenuated values converge smoothly from raw values via EMA
  • Zero-overhead when getters are not called (band computation is always done for API consistency)

Implements the 'Add Audio Variables' feature request (devlup-labs#2):

- Compute band loudness from FFT magnitudes:
  - Bass: 20–250 Hz
  - Mid: 250–4000 Hz
  - Treble: 4000 Hz – Nyquist
- Add EMA-smoothed (attenuated) variants: bassAtt, midAtt, trebleAtt
- Expose all six values through FFTProcessor and AudioProcessor APIs
- Smoothing factor of 0.15 for natural decay response

Reference: projectM implementation pattern for band energy extraction.
@lannerwsf lannerwsf mentioned this pull request May 20, 2026
…lup-labs#1)

Convert the 2D bar graph into a 3D bar graph visualization with:
- Perspective projection and orbiting camera for depth perception
- X-axis: frequency bands, Y-axis: amplitude, Z-axis: time evolution
- 3D bar boxes (6 faces, 12 triangles per bar) with depth testing
- FFT history buffer stores up to 64 frames along the Z-axis
- Automatic camera orbit for full 3D viewing experience
- Age-based dimming on older bars for depth cue
- New visualization option devlup-labs#5 in main menu
- Dedicated 3D vertex shader with MVP matrix uniforms

Files:
- src/visualizations/BarVisualization3D.h/.cpp
- src/visualizations/vertexShader3D.glsl
- src/main.cpp (added option 5)
- src/Makefile (added new source)
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.

Add Audio Variables

1 participant