Runtime-sized ring buffer stored in one 1D array texture. More...
Public Member Functions | |
| void | bind () const |
| Bind the complete spectrum history array to its single texture unit. | |
| void | cleanup () |
| Delete the array texture and reset state. | |
| int | count () const |
| Number of history layers currently allocated. | |
| int | init (int requested_count) |
Allocate one array texture with requested_count history layers. | |
| int | newestLayer () const |
| Physical layer containing the newest spectrum frame. | |
| SpectrumHistory (const acmx2::audio::AudioAnalyzer &analyzer) | |
| void | update (float scale=0.0f) |
| Push the current FFT magnitudes into the head of the ring buffer. | |
| ~SpectrumHistory () | |
Static Public Attributes | |
| static constexpr int | TEXTURE_UNIT = 10 |
| Texture unit assigned to the complete spectrum history array. | |
Private Attributes | |
| const acmx2::audio::AudioAnalyzer & | analyzer |
| int | bins = 0 |
| Texels per layer (== FFT_SIZE / 2). | |
| int | layer_count = 0 |
| Runtime-selected array depth. | |
| std::vector< float > | scaled_buf |
| Scratch for sensitivity-scaled magnitudes. | |
| GLuint | texture_id = 0 |
| One GL_TEXTURE_1D_ARRAY object. | |
| int | write_idx = 0 |
| Next physical layer to overwrite. | |
Runtime-sized ring buffer stored in one 1D array texture.
Enabled via the --enable-audio-buffers <N> CLI option. Allocates one GL_TEXTURE_1D_ARRAY with N GL_R32F layers and exposes it to GLSL as uniform sampler1DArray spectrum_history;. The requested layer count is clamped only to the active GPU's GL_MAX_ARRAY_TEXTURE_LAYERS limit.
Each call to update() writes the current FFT magnitudes into the layer at the ring head and advances the head. No texture data is copied between layers. Shaders use spectrum_history_head and spectrum_history_size to convert a logical age into a physical layer.
The complete array uses only texture unit 10. Unit 9 remains the live spectrum/spectrum0 texture.
Definition at line 2947 of file ACMX2/acmx.cpp.
|
inlineexplicit |
Definition at line 2949 of file ACMX2/acmx.cpp.
References analyzer.
|
inline |
Definition at line 3041 of file ACMX2/acmx.cpp.
References cleanup().
|
inline |
Bind the complete spectrum history array to its single texture unit.
Definition at line 3017 of file ACMX2/acmx.cpp.
References texture_id, and TEXTURE_UNIT.
|
inline |
Delete the array texture and reset state.
Definition at line 3032 of file ACMX2/acmx.cpp.
References layer_count, texture_id, and write_idx.
Referenced by init(), ACView::~ACView(), and ~SpectrumHistory().
|
inline |
Number of history layers currently allocated.
Definition at line 3029 of file ACMX2/acmx.cpp.
References layer_count.
|
inline |
Allocate one array texture with requested_count history layers.
| requested_count | Number of requested history frames. |
Definition at line 2960 of file ACMX2/acmx.cpp.
References bins, cleanup(), FFT_SIZE, layer_count, texture_id, and write_idx.
|
inline |
Physical layer containing the newest spectrum frame.
Definition at line 3026 of file ACMX2/acmx.cpp.
References layer_count, and write_idx.
|
inline |
Push the current FFT magnitudes into the head of the ring buffer.
Reuses magnitudes already computed by SpectrumTexture::update() for the same frame (caller must invoke that first). When scale is non-zero, magnitudes are multiplied by it (matching the live spectrum's sensitivity scaling).
Definition at line 2999 of file ACMX2/acmx.cpp.
References analyzer, bins, layer_count, scaled_buf, acmx2::audio::AudioAnalyzer::spectrum(), texture_id, and write_idx.
|
private |
Definition at line 3044 of file ACMX2/acmx.cpp.
Referenced by SpectrumHistory(), and update().
|
private |
Texels per layer (== FFT_SIZE / 2).
Definition at line 3046 of file ACMX2/acmx.cpp.
|
private |
Runtime-selected array depth.
Definition at line 3047 of file ACMX2/acmx.cpp.
Referenced by cleanup(), count(), init(), newestLayer(), and update().
|
private |
Scratch for sensitivity-scaled magnitudes.
Definition at line 3049 of file ACMX2/acmx.cpp.
Referenced by update().
|
private |
|
staticconstexpr |
Texture unit assigned to the complete spectrum history array.
Definition at line 2952 of file ACMX2/acmx.cpp.
Referenced by bind(), ShaderLibrary::update(), ShaderLibrary::updateShaderUniforms(), and ShaderLibrary::updateShaderUniforms2D().
|
private |
Next physical layer to overwrite.
Definition at line 3048 of file ACMX2/acmx.cpp.
Referenced by cleanup(), init(), newestLayer(), and update().