summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-08 17:39:33 +0100
committerskal <pascal.massimino@gmail.com>2026-02-08 17:39:33 +0100
commit8296fe5180b979b9d1f32f6375b41f0e0a8a399d (patch)
tree28918defcd64001105f8f631a3c0494abd580026 /src/tests
parentb85635ea92ace57e4d94288031a3a61a96fcbd2a (diff)
feat(gpu): Add parameter-driven ChromaAberrationEffect
Implements Task #73 - Extends shader parametrization system to ChromaAberrationEffect following the FlashEffect pattern. Changes: - Added ChromaAberrationParams struct (offset_scale, angle) - Added ChromaUniforms with proper WGSL alignment (32 bytes) - Updated shader to compute offset direction from angle parameter - Extended seq_compiler to parse offset/angle parameters - Updated demo.seq with 2 parameterized instances: * Line 50: offset=0.03 angle=0.785 (45° diagonal, stronger) * Line 76: offset=0.01 angle=1.57 (90° vertical, subtle) Technical details: - Backward-compatible default constructor maintained - Migrated from raw buffer to UniformBuffer<ChromaUniforms> - Shader computes direction: vec2(cos(angle), sin(angle)) - Generated code creates ChromaAberrationParams initialization Testing: - All 32/32 tests pass - Demo runs without errors - Binary size: 5.6M stripped (~200-300 bytes impact) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_effect_base.cc6
-rw-r--r--src/tests/test_jittered_audio.cc11
-rw-r--r--src/tests/test_variable_tempo.cc21
3 files changed, 18 insertions, 20 deletions
diff --git a/src/tests/test_effect_base.cc b/src/tests/test_effect_base.cc
index 2534b36..e280e05 100644
--- a/src/tests/test_effect_base.cc
+++ b/src/tests/test_effect_base.cc
@@ -60,10 +60,12 @@ static void test_offscreen_render_target() {
// Note: Buffer mapping may fail on some systems (WebGPU driver issue)
// Don't fail the test if readback returns empty buffer
if (pixels.empty()) {
- fprintf(stdout, " ⚠ Pixel readback skipped (buffer mapping unavailable)\n");
+ fprintf(stdout,
+ " ⚠ Pixel readback skipped (buffer mapping unavailable)\n");
} else {
assert(pixels.size() == 256 * 256 * 4 && "Pixel buffer size should match");
- fprintf(stdout, " ✓ Pixel readback succeeded (%zu bytes)\n", pixels.size());
+ fprintf(stdout, " ✓ Pixel readback succeeded (%zu bytes)\n",
+ pixels.size());
}
}
diff --git a/src/tests/test_jittered_audio.cc b/src/tests/test_jittered_audio.cc
index c1376db..d8260ec 100644
--- a/src/tests/test_jittered_audio.cc
+++ b/src/tests/test_jittered_audio.cc
@@ -64,8 +64,8 @@ void test_jittered_audio_basic() {
// Should have consumed some audio (exact amount depends on timing/jitter)
// With minimal sleeps and 0.1s sim time, expect 50-1000 frames
- assert(frames_consumed > 50); // At least some audio consumed
- assert(frames_consumed < 2000); // Not excessive
+ assert(frames_consumed > 50); // At least some audio consumed
+ assert(frames_consumed < 2000); // Not excessive
// Underruns are acceptable in this test, but shouldn't be excessive
assert(underruns < 5); // Less than 5 underruns in 0.1 seconds
@@ -133,10 +133,11 @@ void test_jittered_audio_with_acceleration() {
// Should have consumed some audio (exact amount depends on timing/jitter)
// With minimal sleeps and 0.6s sim time, expect more than basic test
- assert(frames_consumed > 200); // At least some audio consumed
- assert(frames_consumed < 5000); // Not excessive
+ assert(frames_consumed > 200); // At least some audio consumed
+ assert(frames_consumed < 5000); // Not excessive
- // During acceleration with jitter, some underruns are expected but not excessive
+ // During acceleration with jitter, some underruns are expected but not
+ // excessive
assert(underruns < 10); // Less than 10 underruns in 0.6 seconds
printf(" ✓ Jittered audio with acceleration PASSED\n");
diff --git a/src/tests/test_variable_tempo.cc b/src/tests/test_variable_tempo.cc
index cd83a06..bbc9ebf 100644
--- a/src/tests/test_variable_tempo.cc
+++ b/src/tests/test_variable_tempo.cc
@@ -32,8 +32,8 @@ static void simulate_tempo(AudioEngine& engine, float& music_time,
// Helper: Simulate tempo with variable scaling function
static void simulate_tempo_fn(AudioEngine& engine, float& music_time,
- float& physical_time, float duration, float dt,
- float (*tempo_fn)(float)) {
+ float& physical_time, float duration, float dt,
+ float (*tempo_fn)(float)) {
const int steps = (int)(duration / dt);
for (int i = 0; i < steps; ++i) {
physical_time += dt;
@@ -96,9 +96,7 @@ void test_2x_speedup_reset_trick() {
// Phase 1: Accelerate from 1.0x to 2.0x over 5 seconds
printf(" Phase 1: Accelerating 1.0x → 2.0x\n");
- auto accel_fn = [](float t) {
- return fminf(1.0f + (t / 5.0f), 2.0f);
- };
+ auto accel_fn = [](float t) { return fminf(1.0f + (t / 5.0f), 2.0f); };
simulate_tempo_fn(engine, music_time, physical_time, 5.0f, dt, accel_fn);
const float tempo_scale = accel_fn(physical_time);
@@ -133,9 +131,7 @@ void test_2x_slowdown_reset_trick() {
// Phase 1: Decelerate from 1.0x to 0.5x over 5 seconds
printf(" Phase 1: Decelerating 1.0x → 0.5x\n");
- auto decel_fn = [](float t) {
- return fmaxf(1.0f - (t / 10.0f), 0.5f);
- };
+ auto decel_fn = [](float t) { return fmaxf(1.0f - (t / 10.0f), 0.5f); };
simulate_tempo_fn(engine, music_time, physical_time, 5.0f, dt, decel_fn);
const float tempo_scale = decel_fn(physical_time);
@@ -209,8 +205,9 @@ void test_continuous_acceleration() {
auto accel_fn = [min_tempo, max_tempo](float t) {
const float progress = t / 10.0f;
- return fmaxf(min_tempo, fminf(max_tempo,
- min_tempo + progress * (max_tempo - min_tempo)));
+ return fmaxf(
+ min_tempo,
+ fminf(max_tempo, min_tempo + progress * (max_tempo - min_tempo)));
};
const int steps = (int)(10.0f / dt);
@@ -252,9 +249,7 @@ void test_oscillating_tempo() {
printf(" Oscillating tempo: 0.8x ↔ 1.2x\n");
- auto oscil_fn = [](float t) {
- return 1.0f + 0.2f * sinf(t * 2.0f);
- };
+ auto oscil_fn = [](float t) { return 1.0f + 0.2f * sinf(t * 2.0f); };
const int steps = 100;
for (int i = 0; i < steps; ++i) {