summaryrefslogtreecommitdiff
path: root/src/audio/tracker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/tracker.cc')
-rw-r--r--src/audio/tracker.cc41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/audio/tracker.cc b/src/audio/tracker.cc
index 5e30281..7ad5a67 100644
--- a/src/audio/tracker.cc
+++ b/src/audio/tracker.cc
@@ -30,7 +30,7 @@ static int g_next_pool_slot = 0; // Round-robin allocation
// CACHE: Pre-registered synth_ids for all samples (indexed by sample_id)
// This eliminates redundant spectrogram generation and registration
-static int g_sample_synth_cache[256]; // Max 256 unique samples
+static int g_sample_synth_cache[256]; // Max 256 unique samples
static bool g_cache_initialized = false;
// Forward declarations
@@ -80,7 +80,8 @@ void tracker_init() {
if (data && size >= sizeof(SpecHeader)) {
const SpecHeader* header = (const SpecHeader*)data;
const int note_frames = header->num_frames;
- const float* spectral_data = (const float*)(data + sizeof(SpecHeader));
+ const float* spectral_data =
+ (const float*)(data + sizeof(SpecHeader));
Spectrogram spec;
spec.spectral_data_a = spectral_data;
@@ -91,8 +92,9 @@ void tracker_init() {
#if defined(DEBUG_LOG_TRACKER)
if (g_sample_synth_cache[sid] == -1) {
- DEBUG_TRACKER( "[TRACKER INIT] Failed to cache asset sample_id=%d (aid=%d)\n",
- sid, (int)aid);
+ DEBUG_TRACKER(
+ "[TRACKER INIT] Failed to cache asset sample_id=%d (aid=%d)\n",
+ sid, (int)aid);
}
#endif /* defined(DEBUG_LOG_TRACKER) */
}
@@ -100,7 +102,8 @@ void tracker_init() {
// GENERATED note: Generate once and cache
const NoteParams& params = g_tracker_samples[sid];
int note_frames = 0;
- std::vector<float> note_data = generate_note_spectrogram(params, &note_frames);
+ std::vector<float> note_data =
+ generate_note_spectrogram(params, &note_frames);
if (note_frames > 0) {
// Allocate persistent storage for this note
@@ -116,12 +119,14 @@ void tracker_init() {
g_sample_synth_cache[sid] = synth_register_spectrogram(&spec);
g_spec_pool[slot].synth_id = g_sample_synth_cache[sid];
- g_spec_pool[slot].active = true; // Mark as permanently allocated
+ g_spec_pool[slot].active = true; // Mark as permanently allocated
#if defined(DEBUG_LOG_TRACKER)
if (g_sample_synth_cache[sid] == -1) {
- DEBUG_TRACKER( "[TRACKER INIT] Failed to cache generated sample_id=%d (freq=%.2f)\n",
- sid, params.base_freq);
+ DEBUG_TRACKER(
+ "[TRACKER INIT] Failed to cache generated sample_id=%d "
+ "(freq=%.2f)\n",
+ sid, params.base_freq);
}
#endif /* defined(DEBUG_LOG_TRACKER) */
}
@@ -131,7 +136,8 @@ void tracker_init() {
g_cache_initialized = true;
#if defined(DEBUG_LOG_TRACKER)
- DEBUG_TRACKER( "[TRACKER INIT] Cached %d unique samples\n", g_tracker_samples_count);
+ DEBUG_TRACKER("[TRACKER INIT] Cached %d unique samples\n",
+ g_tracker_samples_count);
#endif /* defined(DEBUG_LOG_TRACKER) */
}
}
@@ -170,18 +176,18 @@ static void trigger_note_event(const TrackerEvent& event) {
#if defined(DEBUG_LOG_TRACKER)
// VALIDATION: Check sample_id bounds
if (event.sample_id >= g_tracker_samples_count) {
- DEBUG_TRACKER( "[TRACKER ERROR] Invalid sample_id=%d (max=%d)\n",
- event.sample_id, g_tracker_samples_count - 1);
+ DEBUG_TRACKER("[TRACKER ERROR] Invalid sample_id=%d (max=%d)\n",
+ event.sample_id, g_tracker_samples_count - 1);
return;
}
// VALIDATION: Check volume and pan ranges
if (event.volume < 0.0f || event.volume > 2.0f) {
- DEBUG_TRACKER( "[TRACKER WARNING] Unusual volume=%.2f for sample_id=%d\n",
- event.volume, event.sample_id);
+ DEBUG_TRACKER("[TRACKER WARNING] Unusual volume=%.2f for sample_id=%d\n",
+ event.volume, event.sample_id);
}
if (event.pan < -1.0f || event.pan > 1.0f) {
- DEBUG_TRACKER( "[TRACKER WARNING] Invalid pan=%.2f for sample_id=%d\n",
- event.pan, event.sample_id);
+ DEBUG_TRACKER("[TRACKER WARNING] Invalid pan=%.2f for sample_id=%d\n",
+ event.pan, event.sample_id);
}
#endif /* defined(DEBUG_LOG_TRACKER) */
@@ -190,8 +196,9 @@ static void trigger_note_event(const TrackerEvent& event) {
#if defined(DEBUG_LOG_TRACKER)
if (cached_synth_id == -1) {
- DEBUG_TRACKER( "[TRACKER ERROR] No cached synth_id for sample_id=%d (init failed?)\n",
- event.sample_id);
+ DEBUG_TRACKER(
+ "[TRACKER ERROR] No cached synth_id for sample_id=%d (init failed?)\n",
+ event.sample_id);
return;
}
#endif /* defined(DEBUG_LOG_TRACKER) */