diff options
| author | skal <pascal.massimino@gmail.com> | 2026-05-21 08:10:47 +0200 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-05-21 08:10:47 +0200 |
| commit | d806027dcaeadcdd8d2febd88bc46b2fd2c465de (patch) | |
| tree | 30bc1ef9f40ccab7c00e31ee20e62bb86755fa26 /src/audio | |
| parent | 680042a18c11ad5e58757e45b260745c2f52417f (diff) | |
Diffstat (limited to 'src/audio')
| -rw-r--r-- | src/audio/audio_engine.cc | 3 | ||||
| -rw-r--r-- | src/audio/backend/miniaudio_backend.cc | 2 | ||||
| -rw-r--r-- | src/audio/backend/miniaudio_backend.h | 3 | ||||
| -rw-r--r-- | src/audio/gen.cc | 3 | ||||
| -rw-r--r-- | src/audio/ola.h | 4 | ||||
| -rw-r--r-- | src/audio/synth.cc | 9 | ||||
| -rw-r--r-- | src/audio/tracker.cc | 20 |
7 files changed, 25 insertions, 19 deletions
diff --git a/src/audio/audio_engine.cc b/src/audio/audio_engine.cc index 1d6659d..3033882 100644 --- a/src/audio/audio_engine.cc +++ b/src/audio/audio_engine.cc @@ -170,7 +170,8 @@ void AudioEngine::seek(float target_time) { // 1. Reset synth state (clear all active voices) synth_init(); - // 2. Re-init tracker: re-registers all spectrograms with now-clean synth slots + // 2. Re-init tracker: re-registers all spectrograms with now-clean synth + // slots resource_mgr_.reset(); ::tracker_init(&resource_mgr_); diff --git a/src/audio/backend/miniaudio_backend.cc b/src/audio/backend/miniaudio_backend.cc index 8871d10..e591c72 100644 --- a/src/audio/backend/miniaudio_backend.cc +++ b/src/audio/backend/miniaudio_backend.cc @@ -286,7 +286,7 @@ float MiniaudioBackend::get_realtime_peak() { } void MiniaudioBackend::get_callback_state(double* out_time, - int64_t* out_samples) { + int64_t* out_samples) { *out_time = last_callback_time_.load(std::memory_order_acquire); *out_samples = last_callback_samples_.load(std::memory_order_acquire); } diff --git a/src/audio/backend/miniaudio_backend.h b/src/audio/backend/miniaudio_backend.h index 01fa790..c959f2b 100644 --- a/src/audio/backend/miniaudio_backend.h +++ b/src/audio/backend/miniaudio_backend.h @@ -36,7 +36,8 @@ class MiniaudioBackend : public AudioBackend { static std::atomic<float> realtime_peak_; // Smooth playback time interpolation (updated in callback) - static std::atomic<double> last_callback_time_; // Absolute CLOCK_MONOTONIC time + static std::atomic<double> + last_callback_time_; // Absolute CLOCK_MONOTONIC time static std::atomic<int64_t> last_callback_samples_; // Static callback required by miniaudio C API diff --git a/src/audio/gen.cc b/src/audio/gen.cc index 9d18517..723a9cb 100644 --- a/src/audio/gen.cc +++ b/src/audio/gen.cc @@ -12,7 +12,8 @@ std::vector<float> generate_note_spectrogram(const NoteParams& params, int* out_num_frames) { - int num_frames = (int)(params.duration_sec * RING_BUFFER_SAMPLE_RATE / DCT_SIZE); + int num_frames = + (int)(params.duration_sec * RING_BUFFER_SAMPLE_RATE / DCT_SIZE); if (num_frames < 1) num_frames = 1; *out_num_frames = num_frames; diff --git a/src/audio/ola.h b/src/audio/ola.h index 1fb2a4a..33ec674 100644 --- a/src/audio/ola.h +++ b/src/audio/ola.h @@ -21,6 +21,6 @@ void ola_decode(const float* spec, int num_frames, float* pcm); // Single-frame OLA-IDCT decoder. // spec_frame: single DCT_SIZE spectral frame. -// overlap: OLA_OVERLAP buffer (read/write). Must be zero-initialized for first frame. -// out_hop: OLA_HOP_SIZE buffer for the resulting time-domain samples. +// overlap: OLA_OVERLAP buffer (read/write). Must be zero-initialized for first +// frame. out_hop: OLA_HOP_SIZE buffer for the resulting time-domain samples. void ola_decode_frame(const float* spec_frame, float* overlap, float* out_hop); diff --git a/src/audio/synth.cc b/src/audio/synth.cc index d584c62..57972cc 100644 --- a/src/audio/synth.cc +++ b/src/audio/synth.cc @@ -110,8 +110,8 @@ int synth_register_spectrogram(const Spectrogram* spec) { for (int i = 0; i < MAX_SPECTROGRAMS; ++i) { if (!g_synth_data.spectrogram_registered[i]) { g_synth_data.spectrograms[i] = *spec; - g_synth_data.active_spectrogram_data[i].store( - spec->spectral_data_a, std::memory_order_release); + g_synth_data.active_spectrogram_data[i].store(spec->spectral_data_a, + std::memory_order_release); g_synth_data.spectrogram_registered[i] = true; return i; } @@ -184,9 +184,8 @@ void synth_trigger_voice(int spectrogram_id, float volume, float pan, volume, spectrogram_id); } if (pan < -1.0f || pan > 1.0f) { - DEBUG_SYNTH( - "[SYNTH WARNING] Invalid pan=%.2f for spectrogram_id=%d\n", - pan, spectrogram_id); + DEBUG_SYNTH("[SYNTH WARNING] Invalid pan=%.2f for spectrogram_id=%d\n", pan, + spectrogram_id); } if (start_offset_samples < 0) { DEBUG_SYNTH("[SYNTH WARNING] Negative start_offset=%d, clamping to 0\n", diff --git a/src/audio/tracker.cc b/src/audio/tracker.cc index e634333..f9657e9 100644 --- a/src/audio/tracker.cc +++ b/src/audio/tracker.cc @@ -176,7 +176,8 @@ void tracker_update(double music_time_sec, double dt_music_sec) { const TrackerPatternTrigger& trigger = g_tracker_score.triggers[g_last_trigger_idx]; - const double trigger_time_sec = (double)trigger.unit_time * unit_duration_sec; + const double trigger_time_sec = + (double)trigger.unit_time * unit_duration_sec; if (trigger_time_sec > end_music_time) break; @@ -214,8 +215,8 @@ void tracker_update(double music_time_sec, double dt_music_sec) { // Offset = (music_time_delta / tempo_scale) * sample_rate int sample_offset = 0; if (event_music_time > music_time_sec) { - sample_offset = (int)((event_music_time - music_time_sec) / tempo_scale * - (double)RING_BUFFER_SAMPLE_RATE); + sample_offset = (int)((event_music_time - music_time_sec) / + tempo_scale * (double)RING_BUFFER_SAMPLE_RATE); } // Apply humanization if enabled @@ -230,9 +231,10 @@ void tracker_update(double music_time_sec, double dt_music_sec) { // Timing variation: jitter by % of beat duration if (g_tracker_score.timing_variation_pct > 0.0f) { double beat_sec = 60.0 / (double)g_tracker_score.bpm; - double jitter = dist(rng) * - (double)(g_tracker_score.timing_variation_pct / 100.0f) * - beat_sec; + double jitter = + dist(rng) * + (double)(g_tracker_score.timing_variation_pct / 100.0f) * + beat_sec; sample_offset += (int)(jitter / tempo_scale * (double)RING_BUFFER_SAMPLE_RATE); } @@ -240,7 +242,8 @@ void tracker_update(double music_time_sec, double dt_music_sec) { // Volume variation: vary by % if (g_tracker_score.volume_variation_pct > 0.0f) { volume_mult += - (float)(dist(rng) * (double)(g_tracker_score.volume_variation_pct / 100.0f)); + (float)(dist(rng) * + (double)(g_tracker_score.volume_variation_pct / 100.0f)); } } @@ -250,7 +253,8 @@ void tracker_update(double music_time_sec, double dt_music_sec) { // Pattern remains active until full duration elapses const double pattern_end_time = - active.start_music_time + (double)pattern.unit_length * unit_duration_sec; + active.start_music_time + + (double)pattern.unit_length * unit_duration_sec; if (pattern_end_time <= end_music_time) { active.active = false; } |
