diff options
| author | skal <pascal.massimino@gmail.com> | 2026-01-31 21:11:11 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-01-31 21:11:11 +0100 |
| commit | 25e693cc46324b4ec588530de542bba8af6f47c6 (patch) | |
| tree | 8a959e442f9330dd3f881fe4109e83b831f25a7e /src/audio | |
| parent | 9379697ccdf6f44ade7933d5635f72f644f6b92e (diff) | |
style: add vertical compression rules to clang-format
- Enabled AllowShortFunctionsOnASingleLine: All
- Enabled AllowShortBlocksOnASingleLine: Always
- Enabled AllowShortIfStatementsOnASingleLine: Always
- Enabled AllowShortLoopsOnASingleLine: true
- Set MaxEmptyLinesToKeep: 1
- Applied formatting to all source files.
Diffstat (limited to 'src/audio')
| -rw-r--r-- | src/audio/audio.cc | 3 | ||||
| -rw-r--r-- | src/audio/gen.cc | 27 | ||||
| -rw-r--r-- | src/audio/synth.cc | 11 |
3 files changed, 12 insertions, 29 deletions
diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 4341712..b482e64 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -64,8 +64,7 @@ void audio_render_silent(float duration_sec) { } #endif -void audio_update() { -} +void audio_update() {} void audio_shutdown() { ma_device_stop(&g_device); diff --git a/src/audio/gen.cc b/src/audio/gen.cc index 1a94b22..ddc4fa6 100644 --- a/src/audio/gen.cc +++ b/src/audio/gen.cc @@ -12,8 +12,7 @@ std::vector<float> generate_note_spectrogram(const NoteParams ¶ms, int *out_num_frames) { int num_frames = (int)(params.duration_sec * 32000.0f / DCT_SIZE); - if (num_frames < 1) - num_frames = 1; + if (num_frames < 1) num_frames = 1; *out_num_frames = num_frames; std::vector<float> spec_data(num_frames * DCT_SIZE, 0.0f); @@ -33,9 +32,7 @@ std::vector<float> generate_note_spectrogram(const NoteParams ¶ms, // Envelope (Simple Attack) float env = 1.0f; - if (t < params.attack_sec) { - env = t / params.attack_sec; - } + if (t < params.attack_sec) { env = t / params.attack_sec; } // Vibrato float vib = sinf(t * params.vibrato_rate * 2.0f * 3.14159f) * @@ -61,9 +58,7 @@ std::vector<float> generate_note_spectrogram(const NoteParams ¶ms, } // Apply window - for (int i = 0; i < DCT_SIZE; ++i) { - pcm_chunk[i] *= window[i]; - } + for (int i = 0; i < DCT_SIZE; ++i) { pcm_chunk[i] *= window[i]; } // Apply FDCT float dct_chunk[DCT_SIZE]; @@ -81,8 +76,7 @@ std::vector<float> generate_note_spectrogram(const NoteParams ¶ms, void paste_spectrogram(std::vector<float> &dest_data, int *dest_num_frames, const std::vector<float> &src_data, int src_num_frames, int frame_offset) { - if (src_num_frames <= 0) - return; + if (src_num_frames <= 0) return; int needed_frames = frame_offset + src_num_frames; if (needed_frames > *dest_num_frames) { @@ -92,8 +86,7 @@ void paste_spectrogram(std::vector<float> &dest_data, int *dest_num_frames, for (int f = 0; f < src_num_frames; ++f) { int dst_frame_idx = frame_offset + f; - if (dst_frame_idx < 0) - continue; + if (dst_frame_idx < 0) continue; for (int i = 0; i < DCT_SIZE; ++i) { dest_data[dst_frame_idx * DCT_SIZE + i] += src_data[f * DCT_SIZE + i]; @@ -114,10 +107,8 @@ void apply_spectral_noise(std::vector<float> &data, int num_frames, void apply_spectral_lowpass(std::vector<float> &data, int num_frames, float cutoff_ratio) { int cutoff_bin = (int)(cutoff_ratio * DCT_SIZE); - if (cutoff_bin < 0) - cutoff_bin = 0; - if (cutoff_bin >= DCT_SIZE) - return; + if (cutoff_bin < 0) cutoff_bin = 0; + if (cutoff_bin >= DCT_SIZE) return; for (int f = 0; f < num_frames; ++f) { for (int i = cutoff_bin; i < DCT_SIZE; ++i) { @@ -131,8 +122,6 @@ void apply_spectral_comb(std::vector<float> &data, int num_frames, for (int i = 0; i < DCT_SIZE; ++i) { float mod = 1.0f - depth * (0.5f + 0.5f * cosf((float)i / period_bins * 6.28318f)); - for (int f = 0; f < num_frames; ++f) { - data[f * DCT_SIZE + i] *= mod; - } + for (int f = 0; f < num_frames; ++f) { data[f * DCT_SIZE + i] *= mod; } } } diff --git a/src/audio/synth.cc b/src/audio/synth.cc index 523d3d7..b4aaf53 100644 --- a/src/audio/synth.cc +++ b/src/audio/synth.cc @@ -146,8 +146,7 @@ void synth_render(float *output_buffer, int num_frames) { for (int v_idx = 0; v_idx < MAX_VOICES; ++v_idx) { Voice &v = g_voices[v_idx]; - if (!v.active) - continue; + if (!v.active) continue; if (v.buffer_pos >= DCT_SIZE) { if (v.current_spectral_frame >= v.total_spectral_frames) { @@ -193,13 +192,9 @@ void synth_render(float *output_buffer, int num_frames) { int synth_get_active_voice_count() { int count = 0; for (int i = 0; i < MAX_VOICES; ++i) { - if (g_voices[i].active) { - count++; - } + if (g_voices[i].active) { count++; } } return count; } -float synth_get_output_peak() { - return g_current_output_peak; -} +float synth_get_output_peak() { return g_current_output_peak; } |
