fix: update audio routing tests to record clips before checking output

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-04 22:20:56 +00:00
parent ea180f4828
commit e13dcb5e07

View File

@@ -330,11 +330,22 @@ static void test_basic_audio_routing(void) {
clear_output_buffers(); clear_output_buffers();
// Send sine wave to channel 0 // Step 1: Start recording on clip 0 (note 0 triggers clip 0)
send_sine_wave(0, 440.0, 0.5, 500); send_midi_note(0, 100);
usleep(200000); // Wait for processing usleep(100000);
// Step 2: Send audio to channel 0 while recording
send_sine_wave(0, 440.0, 0.5, 500);
usleep(200000);
// Step 3: Stop recording (toggle to looping)
send_midi_note(0, 100);
usleep(100000);
// Step 4: Clear output and check that looped audio appears
clear_output_buffers();
usleep(300000);
// Check that audio appears on channel 0 output
float rms_0 = get_channel_rms(0); float rms_0 = get_channel_rms(0);
float rms_1 = get_channel_rms(1); float rms_1 = get_channel_rms(1);
@@ -347,11 +358,19 @@ static void test_multi_channel_routing(void) {
clear_output_buffers(); clear_output_buffers();
// Send different frequencies to different channels // Record clips on channels 0, 1, 2
send_sine_wave(0, 440.0, 0.5, 300); for (int ch = 0; ch < 3; ch++) {
send_sine_wave(1, 880.0, 0.5, 300); // Note ch triggers clip ch (since note % MAX_CLIPS = ch for ch < 512)
send_sine_wave(2, 1760.0, 0.5, 300); send_midi_note(ch, 100);
usleep(200000); usleep(50000);
send_sine_wave(ch, 440.0 * (ch + 1), 0.5, 300);
usleep(50000);
send_midi_note(ch, 100); // Toggle to looping
usleep(50000);
}
clear_output_buffers();
usleep(300000);
float rms[3]; float rms[3];
for (int ch = 0; ch < 3; ch++) { for (int ch = 0; ch < 3; ch++) {
@@ -369,21 +388,21 @@ static void test_midi_clip_trigger(void) {
clear_output_buffers(); clear_output_buffers();
// Send MIDI note to trigger clip recording // Send MIDI note to trigger clip recording (note 0 triggers clip 0)
send_midi_note(60, 100); // Middle C, velocity 100 send_midi_note(0, 100);
usleep(100000); usleep(100000);
// Send audio to channel 0 while clip is recording // Send audio to channel 0 while clip is recording
send_sine_wave(0, 440.0, 0.5, 500); send_sine_wave(0, 440.0, 0.5, 500);
usleep(200000); usleep(200000);
// Send another MIDI note to stop recording (toggle) // Send another MIDI note to stop recording (toggle to looping)
send_midi_note(60, 100); send_midi_note(0, 100);
usleep(100000); usleep(100000);
// Now the clip should be looping - send no audio input // Now the clip should be looping - clear output and check
clear_output_buffers(); clear_output_buffers();
usleep(200000); usleep(300000);
// Check that audio is still coming out (from the looped clip) // Check that audio is still coming out (from the looped clip)
float rms = get_channel_rms(0); float rms = get_channel_rms(0);
@@ -395,18 +414,18 @@ static void test_midi_scene_launch(void) {
clear_output_buffers(); clear_output_buffers();
// Record clips on multiple channels for scene 0 // Record clips on channels 0-3 using notes 0-3
for (int ch = 0; ch < 4; ch++) { for (int ch = 0; ch < 4; ch++) {
send_midi_note(60 + ch, 100); // Start recording send_midi_note(ch, 100); // Start recording
usleep(50000); usleep(50000);
send_sine_wave(ch, 440.0 * (ch + 1), 0.3, 200); send_sine_wave(ch, 440.0 * (ch + 1), 0.3, 200);
usleep(50000); usleep(50000);
send_midi_note(60 + ch, 100); // Stop recording send_midi_note(ch, 100); // Toggle to looping
usleep(50000); usleep(50000);
} }
clear_output_buffers(); clear_output_buffers();
usleep(200000); usleep(300000);
// All 4 channels should have audio from their looped clips // All 4 channels should have audio from their looped clips
for (int ch = 0; ch < 4; ch++) { for (int ch = 0; ch < 4; ch++) {
@@ -422,9 +441,16 @@ static void test_channel_independence(void) {
clear_output_buffers(); clear_output_buffers();
// Send audio only to channel 0 // Record on channel 0 only
send_midi_note(0, 100);
usleep(50000);
send_sine_wave(0, 440.0, 0.8, 500); send_sine_wave(0, 440.0, 0.8, 500);
usleep(200000); usleep(50000);
send_midi_note(0, 100); // Toggle to looping
usleep(50000);
clear_output_buffers();
usleep(300000);
float rms_0 = get_channel_rms(0); float rms_0 = get_channel_rms(0);
float rms_1 = get_channel_rms(1); float rms_1 = get_channel_rms(1);
@@ -438,12 +464,18 @@ static void test_channel_independence(void) {
static void test_volume_control(void) { static void test_volume_control(void) {
printf("\nTest: Volume Control\n"); printf("\nTest: Volume Control\n");
// Note: Volume control would need to be set via CLI commands
// For now, test that audio passes through at default volume
clear_output_buffers(); clear_output_buffers();
// Record on channel 0
send_midi_note(0, 100);
usleep(50000);
send_sine_wave(0, 440.0, 0.5, 500); send_sine_wave(0, 440.0, 0.5, 500);
usleep(200000); usleep(50000);
send_midi_note(0, 100); // Toggle to looping
usleep(50000);
clear_output_buffers();
usleep(300000);
float rms = get_channel_rms(0); float rms = get_channel_rms(0);
TEST("Audio passes through at default volume", rms > 0.01f); TEST("Audio passes through at default volume", rms > 0.01f);