diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-16 17:12:11 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-16 17:12:11 +0100 |
| commit | 18a3ccb2a1335d3747657e0b764af31fd723856e (patch) | |
| tree | 3d310d9f0fb915a8092d83c22c224300f7cd86ed /src/app | |
| parent | c79ebff06ae74135c5f67ecc01d5bb55aeb5eda9 (diff) | |
feat: Add PeakMeterEffect v2 for test_demo audio visualization
Ports PeakMeterEffect to v2 Effect system with proper DAG routing.
Red horizontal bar overlay displays audio_intensity for visual debugging
of audio-visual synchronization.
Changes:
- New: src/effects/peak_meter_effect.{h,cc} - v2 implementation
- Timeline: FlashEffect -> flash_out -> PeakMeterEffect -> sink
- Build: Added to COMMON_GPU_EFFECTS and demo_effects.h
- Test: Added to test_demo_effects.cc (9/9 effects pass)
- Cleanup: Removed old disabled PeakMeterEffect code from test_demo.cc
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/test_demo.cc | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/src/app/test_demo.cc b/src/app/test_demo.cc index 83e6f8b..6031aef 100644 --- a/src/app/test_demo.cc +++ b/src/app/test_demo.cc @@ -19,89 +19,6 @@ #include "generated/test_timeline.h" extern float GetDemoDuration(); -// TODO: Port PeakMeterEffect and CNN effects to v2 -// #include "../../cnn_v1/src/cnn_v1_effect.h" -// #include "../../cnn_v2/src/cnn_v2_effect.h" -// #include "gpu/post_process_helper.h" -// #include "gpu/shader_composer.h" - -#if 0 // Disabled: needs v2 port -class PeakMeterEffect : public PostProcessEffectV2 { - public: - PeakMeterEffect(const GpuContext& ctx) : PostProcessEffect(ctx) { - // Use ShaderComposer to include CommonUniforms from common_uniforms.wgsl - const char* shader_main = R"( - struct VertexOutput { - @builtin(position) position: vec4<f32>, - @location(0) uv: vec2<f32>, - }; - - struct EffectParams { - unused: f32, - }; - - @group(0) @binding(0) var inputSampler: sampler; - @group(0) @binding(1) var inputTexture: texture_2d<f32>; - @group(0) @binding(2) var<uniform> uniforms: CommonUniforms; - @group(0) @binding(3) var<uniform> params: EffectParams; - - @vertex - fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; - // Full-screen triangle (required for post-process pass-through) - var pos = array<vec2<f32>, 3>( - vec2<f32>(-1.0, -1.0), - vec2<f32>(3.0, -1.0), - vec2<f32>(-1.0, 3.0) - ); - output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0); - output.uv = pos[vertexIndex] * 0.5 + 0.5; - return output; - } - - @fragment - fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> { - // Bar dimensions - let bar_y_min = 0.005; - let bar_y_max = 0.015; - let bar_x_min = 0.015; - let bar_x_max = 0.250; - let in_bar_y = input.uv.y >= bar_y_min && input.uv.y <= bar_y_max; - let in_bar_x = input.uv.x >= bar_x_min && input.uv.x <= bar_x_max; - - // Optimization: Return bar color early (avoids texture sampling for ~5% of pixels) - if (in_bar_y && in_bar_x) { - let uv_x = (input.uv.x - bar_x_min) / (bar_x_max - bar_x_min); - let factor = step(uv_x, uniforms.audio_intensity); - return mix(vec4<f32>(0.0, 0.0, 0.0, 1.0), vec4<f32>(1.0, 0.0, 0.0,1.0), factor); - } - - // Pass through input texture for rest of screen - return textureSample(inputTexture, inputSampler, input.uv); - } - )"; - - // Compose shader with common_uniforms to get CommonUniforms definition - std::string shader_code = - ShaderComposer::Get().Compose({"common_uniforms"}, shader_main); - - pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format, - shader_code.c_str()); - } - - void update_bind_group(WGPUTextureView input_view) override { - pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, - uniforms_.get(), {}); - } - - void render(WGPURenderPassEncoder pass, - const UniformsSequenceParams& uniforms) override { - uniforms_.update(ctx_.queue, uniforms); - PostProcessEffect::render(pass, uniforms); - } -}; -#endif // Disabled: needs v2 port - static int g_cnn_version = 2; // Default to v2 #if !defined(STRIP_ALL) @@ -228,12 +145,6 @@ int main(int argc, char** argv) { // Initialize v2 timeline from test_demo.seq InitializeSequences(*gpu_get_context(), width, height); -#if !defined(STRIP_ALL) - // TODO: Port CNN and peak meter effects to v2 - // const GpuContext* gpu_ctx = gpu_get_context(); - // (v1 gpu_add_custom_effect not available in v2) -#endif - audio_init(); static AudioEngine g_audio_engine; |
