summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_tracker.cc43
-rw-r--r--src/tests/test_tracker_timing.cc14
-rw-r--r--src/tests/test_variable_tempo.cc14
-rw-r--r--src/tests/test_wav_dump.cc9
4 files changed, 35 insertions, 45 deletions
diff --git a/src/tests/test_tracker.cc b/src/tests/test_tracker.cc
index 7ef7172..9285728 100644
--- a/src/tests/test_tracker.cc
+++ b/src/tests/test_tracker.cc
@@ -8,11 +8,12 @@
#include <assert.h>
#include <stdio.h>
-// Forward declaration for generated data to avoid compilation issues before
-// generation extern const NoteParams g_tracker_samples[]; extern const uint32_t
-// g_tracker_samples_count; extern const TrackerPattern g_tracker_patterns[];
-// extern const uint32_t g_tracker_patterns_count;
-// extern const TrackerScore g_tracker_score;
+// Forward declaration for generated data
+extern const NoteParams g_tracker_samples[];
+extern const uint32_t g_tracker_samples_count;
+extern const TrackerPattern g_tracker_patterns[];
+extern const uint32_t g_tracker_patterns_count;
+extern const TrackerScore g_tracker_score;
void test_tracker_init() {
synth_init();
@@ -24,43 +25,33 @@ void test_tracker_pattern_triggering() {
synth_init();
tracker_init();
- // At time 0.0f, 4 patterns are triggered:
+ // At time 0.0f, 3 patterns are triggered:
// - crash (1 event at beat 0.0)
// - kick_basic (events at beat 0.0, 2.0, 2.5)
- // - snare_basic (events at beat 1.0, 3.0)
- // - hihat_stressed (events at beat 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5)
- // With the new event-based triggering, only events at beat 0.0 trigger immediately.
+ // - hihat_basic (events at beat 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5)
+ // With event-based triggering, only events at beat 0.0 trigger immediately.
// Test 1: At music_time = 0.0f, events at beat 0.0 trigger
tracker_update(0.0f);
- printf("Actual active voice count at 0.0f: %d\n",
- synth_get_active_voice_count());
- // Expect 3 voices: crash (beat 0.0), kick_basic (beat 0.0), hihat_stressed
- // (beat 0.0)
+ // Expect 3 voices: crash (beat 0.0), kick (beat 0.0), hihat (beat 0.0)
assert(synth_get_active_voice_count() == 3);
// Test 2: At music_time = 0.25f (beat 0.5 @ 120 BPM), hihat event triggers
// beat_duration = 60.0f / 120.0f = 0.5s per beat
// beat 0.5 = 0.25s
tracker_update(0.25f);
- printf("Actual active voice count at 0.25f: %d\n",
- synth_get_active_voice_count());
- // Expect 4 voices (3 previous + 1 new hihat)
+ // Expect 4 voices (3 previous + 1 hihat at beat 0.5)
assert(synth_get_active_voice_count() == 4);
- // Test 3: At music_time = 0.5f (beat 1.0), snare event triggers
+ // Test 3: At music_time = 0.5f (beat 1.0), hihat event triggers
tracker_update(0.5f);
- printf("Actual active voice count at 0.5f: %d\n",
- synth_get_active_voice_count());
- // Expect 6 voices (4 previous + snare + hihat at beat 1.0)
- assert(synth_get_active_voice_count() == 6);
+ // Expect 5 voices (4 previous + 1 hihat at beat 1.0)
+ assert(synth_get_active_voice_count() == 5);
- // Test 4: Advance further to 2.0f (beat 4.0), new pattern triggers at 2.0f
+ // Test 4: Advance to 2.0f - new patterns trigger at time 2.0f
tracker_update(2.0f);
- printf("Actual active voice count at 2.0f: %d\n",
- synth_get_active_voice_count());
- // Multiple events have triggered by now
- assert(synth_get_active_voice_count() > 0);
+ // Many events have triggered by now
+ assert(synth_get_active_voice_count() > 5);
printf("Tracker pattern triggering test PASSED\n");
}
diff --git a/src/tests/test_tracker_timing.cc b/src/tests/test_tracker_timing.cc
index 20269a8..cf2519d 100644
--- a/src/tests/test_tracker_timing.cc
+++ b/src/tests/test_tracker_timing.cc
@@ -60,8 +60,8 @@ void test_basic_event_recording() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Trigger at t=0.0 (should trigger initial patterns)
tracker_update(0.0f);
@@ -86,8 +86,8 @@ void test_progressive_triggering() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Update at t=0
tracker_update(0.0f);
@@ -117,8 +117,8 @@ void test_simultaneous_triggers() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Clear and update to first trigger point
backend.clear_events();
@@ -163,8 +163,8 @@ void test_timing_monotonicity() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Update through several time points
for (float t = 0.0f; t <= 5.0f; t += 0.5f) {
@@ -189,8 +189,8 @@ void test_seek_simulation() {
audio_set_backend(&backend);
audio_init();
- tracker_init();
synth_init();
+ tracker_init();
// Simulate seeking to t=3.0s by rendering silent audio
// This should trigger all patterns in range [0, 3.0]
@@ -231,8 +231,8 @@ void test_timestamp_clustering() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Update through the first 4 seconds
for (float t = 0.0f; t <= 4.0f; t += 0.1f) {
@@ -264,8 +264,8 @@ void test_render_integration() {
audio_set_backend(&backend);
audio_init();
- tracker_init();
synth_init();
+ tracker_init();
// Trigger some patterns
tracker_update(0.0f);
diff --git a/src/tests/test_variable_tempo.cc b/src/tests/test_variable_tempo.cc
index d366ade..3deb97e 100644
--- a/src/tests/test_variable_tempo.cc
+++ b/src/tests/test_variable_tempo.cc
@@ -29,8 +29,8 @@ void test_basic_tempo_scaling() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Test 1: Normal tempo (1.0x)
{
@@ -74,7 +74,7 @@ void test_basic_tempo_scaling() {
// Test 3: Slow tempo (0.5x)
{
backend.clear_events();
- tracker_init();
+ synth_init();
float music_time = 0.0f;
float tempo_scale = 0.5f;
@@ -100,8 +100,8 @@ void test_2x_speedup_reset_trick() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Scenario: Accelerate to 2.0x, then reset to 1.0x
float music_time = 0.0f;
@@ -157,8 +157,8 @@ void test_2x_slowdown_reset_trick() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Scenario: Decelerate to 0.5x, then reset to 1.0x
float music_time = 0.0f;
@@ -213,8 +213,8 @@ void test_pattern_density_swap() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
// Simulate: sparse pattern → accelerate → reset + dense pattern
float music_time = 0.0f;
@@ -268,8 +268,8 @@ void test_continuous_acceleration() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
float music_time = 0.0f;
float tempo_scale = 0.5f;
@@ -320,8 +320,8 @@ void test_oscillating_tempo() {
MockAudioBackend backend;
audio_set_backend(&backend);
- tracker_init();
synth_init();
+ tracker_init();
float music_time = 0.0f;
float physical_time = 0.0f;
diff --git a/src/tests/test_wav_dump.cc b/src/tests/test_wav_dump.cc
index 7d3dbf6..753d548 100644
--- a/src/tests/test_wav_dump.cc
+++ b/src/tests/test_wav_dump.cc
@@ -33,18 +33,17 @@ void test_wav_format_matches_live_audio() {
const char* test_file = "test_format.wav";
- // Initialize audio system
- synth_init();
- tracker_init();
-
// Create WAV dump backend
WavDumpBackend wav_backend;
wav_backend.set_output_file(test_file);
audio_set_backend(&wav_backend);
- // Initialize and render 1 second of audio
+ // Initialize audio system (calls synth_init internally)
audio_init();
+ // Initialize tracker AFTER audio_init to ensure spectrograms stay registered
+ tracker_init();
+
// Manually trigger some audio for testing
tracker_update(0.0f); // Trigger patterns at t=0