diff options
| -rw-r--r-- | .clang-format | 11 | ||||
| -rw-r--r-- | src/audio/audio.cc | 3 | ||||
| -rw-r--r-- | src/audio/gen.cc | 27 | ||||
| -rw-r--r-- | src/audio/synth.cc | 11 | ||||
| -rw-r--r-- | src/gpu/demo_effects.cc | 6 | ||||
| -rw-r--r-- | src/gpu/effect.cc | 23 | ||||
| -rw-r--r-- | src/gpu/effect.h | 21 | ||||
| -rw-r--r-- | src/gpu/gpu.cc | 10 | ||||
| -rw-r--r-- | src/gpu/gpu.h | 17 | ||||
| -rw-r--r-- | src/main.cc | 19 | ||||
| -rw-r--r-- | src/platform.cc | 16 | ||||
| -rw-r--r-- | src/tests/test_maths.cc | 19 | ||||
| -rw-r--r-- | src/tests/test_sequence.cc | 16 | ||||
| -rw-r--r-- | src/util/asset_manager.cc | 6 | ||||
| -rw-r--r-- | src/util/mini_math.h | 61 | ||||
| -rw-r--r-- | tools/asset_packer.cc | 12 | ||||
| -rw-r--r-- | tools/seq_compiler.cc | 10 | ||||
| -rw-r--r-- | tools/spectool.cc | 4 | ||||
| -rw-r--r-- | tools/specview.cc | 7 |
19 files changed, 94 insertions, 205 deletions
diff --git a/.clang-format b/.clang-format index b9e86d8..cb492a9 100644 --- a/.clang-format +++ b/.clang-format @@ -4,7 +4,16 @@ BasedOnStyle: LLVM IndentWidth: 2 UseTab: Never ColumnLimit: 80 -AllowShortFunctionsOnASingleLine: None +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AllowShortNamespacesOnASingleLine: true +MaxEmptyLinesToKeep: 1 +KeepEmptyLinesAtTheStartOfBlocks: false AlwaysBreakBeforeMultilineStrings: true FixNamespaceComments: false ... 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; } diff --git a/src/gpu/demo_effects.cc b/src/gpu/demo_effects.cc index 27712d3..77fb152 100644 --- a/src/gpu/demo_effects.cc +++ b/src/gpu/demo_effects.cc @@ -320,8 +320,7 @@ static void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline, WGPUBindGroup *bind_group, WGPUTextureView input_view, GpuBuffer uniforms) { - if (*bind_group) - wgpuBindGroupRelease(*bind_group); + if (*bind_group) wgpuBindGroupRelease(*bind_group); WGPUBindGroupLayout bgl = wgpuRenderPipelineGetBindGroupLayout(pipeline, 0); WGPUSamplerDescriptor sd = {}; sd.magFilter = WGPUFilterMode_Linear; @@ -386,8 +385,7 @@ ParticleSprayEffect::ParticleSprayEffect(WGPUDevice device, WGPUQueue queue, gpu_create_buffer(device, sizeof(float) * 4, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); std::vector<Particle> init_p(NUM_PARTICLES); - for (auto &p : init_p) - p.pos[3] = 0.0f; + for (auto &p : init_p) p.pos[3] = 0.0f; particles_buffer_ = gpu_create_buffer( device, sizeof(Particle) * NUM_PARTICLES, WGPUBufferUsage_Storage | WGPUBufferUsage_Vertex, init_p.data()); diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index f9ebf0c..054c0ef 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -35,8 +35,7 @@ void Sequence::add_effect(std::shared_ptr<Effect> effect, float start_time, } void Sequence::sort_items() { - if (is_sorted_) - return; + if (is_sorted_) return; std::sort(items_.begin(), items_.end(), [](const SequenceItem &a, const SequenceItem &b) { return a.priority < b.priority; @@ -130,9 +129,7 @@ void MainSequence::init(WGPUDevice d, WGPUQueue q, WGPUTextureFormat f, create_framebuffers(width, height); passthrough_effect_ = std::make_unique<PassthroughEffect>(device, format); - for (auto &entry : sequences_) { - entry.seq->init(this); - } + for (auto &entry : sequences_) { entry.seq->init(this); } } void MainSequence::add_sequence(std::shared_ptr<Sequence> seq, float start_time, @@ -259,17 +256,11 @@ void MainSequence::render_frame(float global_time, float beat, float peak, } void MainSequence::shutdown() { - if (framebuffer_view_a_) - wgpuTextureViewRelease(framebuffer_view_a_); - if (framebuffer_a_) - wgpuTextureRelease(framebuffer_a_); - if (framebuffer_view_b_) - wgpuTextureViewRelease(framebuffer_view_b_); - if (framebuffer_b_) - wgpuTextureRelease(framebuffer_b_); - for (auto &entry : sequences_) { - entry.seq->reset(); - } + if (framebuffer_view_a_) wgpuTextureViewRelease(framebuffer_view_a_); + if (framebuffer_a_) wgpuTextureRelease(framebuffer_a_); + if (framebuffer_view_b_) wgpuTextureViewRelease(framebuffer_view_b_); + if (framebuffer_b_) wgpuTextureRelease(framebuffer_b_); + for (auto &entry : sequences_) { entry.seq->reset(); } } #ifndef STRIP_ALL diff --git a/src/gpu/effect.h b/src/gpu/effect.h index 1d339e2..0b791a3 100644 --- a/src/gpu/effect.h +++ b/src/gpu/effect.h @@ -15,11 +15,8 @@ class PostProcessEffect; class Effect { public: virtual ~Effect() = default; - virtual void init(MainSequence *demo) { - (void)demo; - } - virtual void start() { - } + virtual void init(MainSequence *demo) { (void)demo; } + virtual void start() {} virtual void compute(WGPUCommandEncoder encoder, float time, float beat, float intensity, float aspect_ratio) { (void)encoder; @@ -30,21 +27,15 @@ public: } virtual void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) = 0; - virtual void end() { - } + virtual void end() {} bool is_initialized = false; - virtual bool is_post_process() const { - return false; - } + virtual bool is_post_process() const { return false; } }; class PostProcessEffect : public Effect { public: - bool is_post_process() const override { - return true; - } - void compute(WGPUCommandEncoder, float, float, float, float) override { - } + bool is_post_process() const override { return true; } + void compute(WGPUCommandEncoder, float, float, float, float) override {} void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override; virtual void update_bind_group(WGPUTextureView input_view) = 0; diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index b9545bf..ebf709e 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -327,8 +327,7 @@ void gpu_init(GLFWwindow *window, int width, int height) { adapter_cb.userdata1 = &g_adapter; wgpuInstanceRequestAdapter(g_instance, &adapter_opts, adapter_cb); #endif - while (!g_adapter) - wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); + while (!g_adapter) wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); WGPUDeviceDescriptor device_desc = {}; #ifndef STRIP_ALL @@ -347,8 +346,7 @@ void gpu_init(GLFWwindow *window, int width, int height) { device_cb.userdata1 = &g_device; wgpuAdapterRequestDevice(g_adapter, &device_desc, device_cb); #endif - while (!g_device) - wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); + while (!g_device) wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); #if defined(DEMO_CROSS_COMPILE_WIN32) && !defined(STRIP_ALL) set_error_callback(g_device, handle_device_error); @@ -384,6 +382,4 @@ void gpu_simulate_until(float time) { } #endif -void gpu_shutdown() { - g_main_sequence.shutdown(); -}
\ No newline at end of file +void gpu_shutdown() { g_main_sequence.shutdown(); }
\ No newline at end of file diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h index c2c0670..eb3dd8a 100644 --- a/src/gpu/gpu.h +++ b/src/gpu/gpu.h @@ -16,13 +16,9 @@ #include <webgpu/wgpu.h> -static inline const char *str_view(const char *str) { - return str; -} +static inline const char *str_view(const char *str) { return str; } -static inline const char *label_view(const char *str) { - return str; -} +static inline const char *label_view(const char *str) { return str; } #define WGPUSType_ShaderSourceWGSL WGPUSType_ShaderModuleWGSLDescriptor @@ -40,8 +36,6 @@ using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor; #else - - // Native (macOS/Linux) using newer wgpu-native #include <webgpu.h> @@ -49,9 +43,7 @@ using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor; #include <wgpu.h> static inline WGPUStringView str_view(const char *str) { - - if (!str) - return {nullptr, 0}; + if (!str) return {nullptr, 0}; return {str, strlen(str)}; } @@ -60,8 +52,7 @@ static inline WGPUStringView label_view(const char *str) { #ifndef STRIP_ALL - if (!str) - return {nullptr, 0}; + if (!str) return {nullptr, 0}; return {str, strlen(str)}; diff --git a/src/main.cc b/src/main.cc index c0f6770..f63c803 100644 --- a/src/main.cc +++ b/src/main.cc @@ -2,10 +2,10 @@ // It serves as the application entry point. // Orchestrates platform initialization, main loop, and subsystem coordination. -#include "generated/assets.h" // Include generated asset header #include "audio/audio.h" #include "audio/gen.h" #include "audio/synth.h" +#include "generated/assets.h" // Include generated asset header #include "gpu/gpu.h" #include "platform.h" #include "util/math.h" @@ -29,8 +29,7 @@ struct SpecHeader { int register_spec_asset(AssetId id) { size_t size; const uint8_t *data = GetAsset(id, &size); - if (!data || size < sizeof(SpecHeader)) - return -1; + if (!data || size < sizeof(SpecHeader)) return -1; const SpecHeader *header = (const SpecHeader *)data; const float *spectral_data = (const float *)(data + sizeof(SpecHeader)); @@ -62,13 +61,11 @@ int generate_melody() { srand(12345); // Fixed seed for reproducibility for (int i = 0; i < 128; ++i) { - if (i % 4 == 0) - continue; // Rest on beat 1 of every bar + if (i % 4 == 0) continue; // Rest on beat 1 of every bar NoteParams params = {}; params.base_freq = notes[rand() % num_notes]; - if (rand() % 4 == 0) - params.base_freq *= 2.0f; // Occasional octave up + if (rand() % 4 == 0) params.base_freq *= 2.0f; // Occasional octave up params.duration_sec = (rand() % 2 == 0) ? 0.2f : 0.4f; params.amplitude = 0.4f; @@ -121,9 +118,7 @@ float *generate_tone(float *buffer, float freq) { float amplitude = 1000. * powf(1.0f - (float)frame / SPEC_FRAMES, 2.0f); int bin = (int)(freq / (32000.0f / 2.0f) * DCT_SIZE); - if (bin > 0 && bin < DCT_SIZE) { - spec_frame[bin] = amplitude; - } + if (bin > 0 && bin < DCT_SIZE) { spec_frame[bin] = amplitude; } } return buffer; } @@ -188,9 +183,7 @@ int main(int argc, char **argv) { } // Hihat on every offbeat - if (step % 2 == 1) { - synth_trigger_voice(hihat_id, 0.5f, 0.3f); - } + if (step % 2 == 1) { synth_trigger_voice(hihat_id, 0.5f, 0.3f); } // Bass pattern if (step % 4 == 0) { diff --git a/src/platform.cc b/src/platform.cc index f0ef553..04bbf09 100644 --- a/src/platform.cc +++ b/src/platform.cc @@ -46,13 +46,9 @@ void platform_shutdown() { glfwTerminate(); } -void platform_poll() { - glfwPollEvents(); -} +void platform_poll() { glfwPollEvents(); } -bool platform_should_close() { - return glfwWindowShouldClose(window); -} +bool platform_should_close() { return glfwWindowShouldClose(window); } void platform_toggle_fullscreen() { g_is_fullscreen = !g_is_fullscreen; @@ -70,13 +66,9 @@ void platform_toggle_fullscreen() { } } -GLFWwindow *platform_get_window() { - return window; -} +GLFWwindow *platform_get_window() { return window; } -double platform_get_time() { - return glfwGetTime(); -} +double platform_get_time() { return glfwGetTime(); } WGPUSurface platform_create_wgpu_surface(WGPUInstance instance) { return glfwCreateWindowWGPUSurface(instance, window); diff --git a/src/tests/test_maths.cc b/src/tests/test_maths.cc index d9bc4d1..e7a686c 100644 --- a/src/tests/test_maths.cc +++ b/src/tests/test_maths.cc @@ -9,9 +9,7 @@ #include <vector> // Checks if two floats are approximately equal -bool near(float a, float b, float e = 0.001f) { - return std::abs(a - b) < e; -} +bool near(float a, float b, float e = 0.001f) { return std::abs(a - b) < e; } // Generic test runner for any vector type (vec2, vec3, vec4) template <typename T> void test_vector_ops(int n) { @@ -24,19 +22,16 @@ template <typename T> void test_vector_ops(int n) { // Add T c = a + b; - for (int i = 0; i < n; ++i) - assert(near(c[i], (float)(i + 1) + 10.0f)); + for (int i = 0; i < n; ++i) assert(near(c[i], (float)(i + 1) + 10.0f)); // Scale T s = a * 2.0f; - for (int i = 0; i < n; ++i) - assert(near(s[i], (float)(i + 1) * 2.0f)); + for (int i = 0; i < n; ++i) assert(near(s[i], (float)(i + 1) * 2.0f)); // Dot Product // vec3(1,2,3) . vec3(1,2,3) = 1+4+9 = 14 float expected_dot = 0; - for (int i = 0; i < n; ++i) - expected_dot += a[i] * a[i]; + for (int i = 0; i < n; ++i) expected_dot += a[i] * a[i]; assert(near(T::dot(a, a), expected_dot)); // Norm (Length) @@ -48,8 +43,7 @@ template <typename T> void test_vector_ops(int n) { // Lerp T l = lerp(a, b, 0.3f); - for (int i = 0; i < n; ++i) - assert(near(l[i], .7 * (i + 1) + .3 * 10.0f)); + for (int i = 0; i < n; ++i) assert(near(l[i], .7 * (i + 1) + .3 * 10.0f)); } // Specific test for padding alignment in vec3 @@ -133,8 +127,7 @@ void test_spring() { std::cout << "Testing Spring..." << std::endl; float p = 0, v = 0; // Simulate approx 1 sec with 0.5s smooth time - for (int i = 0; i < 60; ++i) - spring::solve(p, v, 10.0f, 0.5f, 0.016f); + for (int i = 0; i < 60; ++i) spring::solve(p, v, 10.0f, 0.5f, 0.016f); assert(p > 8.5f); // Test vector spring diff --git a/src/tests/test_sequence.cc b/src/tests/test_sequence.cc index db66b8a..363846b 100644 --- a/src/tests/test_sequence.cc +++ b/src/tests/test_sequence.cc @@ -26,16 +26,13 @@ public: int end_calls = 0; bool is_pp = false; - DummyEffect(bool post_process = false) : is_pp(post_process) { - } + DummyEffect(bool post_process = false) : is_pp(post_process) {} void init(MainSequence *demo) override { init_calls++; (void)demo; } - void start() override { - start_calls++; - } + void start() override { start_calls++; } void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override { render_calls++; @@ -53,12 +50,8 @@ public: (void)intensity; (void)aspect_ratio; } - void end() override { - end_calls++; - } - bool is_post_process() const override { - return is_pp; - } + void end() override { end_calls++; } + bool is_post_process() const override { return is_pp; } }; // --- Dummy PostProcessEffect for Tracking (unused in simplified tests) --- @@ -169,7 +162,6 @@ void test_simulate_until() { } int main() { - printf("Running Sequence/Effect System tests...\n"); // TODO: Re-enable and fix test_effect_lifecycle once GPU resource mocking is diff --git a/src/util/asset_manager.cc b/src/util/asset_manager.cc index 33b697b..de3934b 100644 --- a/src/util/asset_manager.cc +++ b/src/util/asset_manager.cc @@ -12,14 +12,12 @@ extern const size_t g_assets_count; const uint8_t *GetAsset(AssetId asset_id, size_t *out_size) { uint16_t index = (uint16_t)asset_id; if (index >= g_assets_count) { - if (out_size) - *out_size = 0; + if (out_size) *out_size = 0; return nullptr; } const AssetRecord &record = g_assets[index]; - if (out_size) - *out_size = record.size; + if (out_size) *out_size = record.size; return record.data; } diff --git a/src/util/mini_math.h b/src/util/mini_math.h index 3024737..d3c9bc5 100644 --- a/src/util/mini_math.h +++ b/src/util/mini_math.h @@ -18,25 +18,18 @@ // T: Class Name (e.g., vec3) // N: Number of active components for math (e.g., 3) #define VEC_OPERATORS(T, N) \ - float &operator[](int i) { \ - return v[i]; \ - } \ - const float &operator[](int i) const { \ - return v[i]; \ - } \ + float &operator[](int i) { return v[i]; } \ + const float &operator[](int i) const { return v[i]; } \ T &operator+=(const T &r) { \ - for (int i = 0; i < N; ++i) \ - v[i] += r.v[i]; \ + for (int i = 0; i < N; ++i) v[i] += r.v[i]; \ return *this; \ } \ T &operator-=(const T &r) { \ - for (int i = 0; i < N; ++i) \ - v[i] -= r.v[i]; \ + for (int i = 0; i < N; ++i) v[i] -= r.v[i]; \ return *this; \ } \ T &operator*=(float s) { \ - for (int i = 0; i < N; ++i) \ - v[i] *= s; \ + for (int i = 0; i < N; ++i) v[i] *= s; \ return *this; \ } \ T operator+(const T &r) const { \ @@ -56,32 +49,22 @@ } \ T operator-() const { \ T res; \ - for (int i = 0; i < N; ++i) \ - res.v[i] = -v[i]; \ + for (int i = 0; i < N; ++i) res.v[i] = -v[i]; \ return res; \ } \ static float dot(const T &a, const T &b) { \ float s = 0; \ - for (int i = 0; i < N; ++i) \ - s += a.v[i] * b.v[i]; \ + for (int i = 0; i < N; ++i) s += a.v[i] * b.v[i]; \ return s; \ } \ - float dot(const T &a) const { \ - return dot(*this, a); \ - } \ - float norm() const { \ - return std::sqrt(dot(*this, *this)); \ - } \ - float len() const { \ - return norm(); \ - } \ + float dot(const T &a) const { return dot(*this, a); } \ + float norm() const { return std::sqrt(dot(*this, *this)); } \ + float len() const { return norm(); } \ float inv_norm() const { \ float l2 = dot(*this, *this); \ return l2 > 0 ? 1.0f / std::sqrt(l2) : 0; \ } \ - T normalize() const { \ - return (*this) * inv_norm(); \ - } + T normalize() const { return (*this) * inv_norm(); } #ifdef USE_VEC2 struct vec2 { @@ -91,8 +74,7 @@ struct vec2 { }; float v[2]; }; - vec2(float x = 0, float y = 0) : x(x), y(y) { - } + vec2(float x = 0, float y = 0) : x(x), y(y) {} VEC_OPERATORS(vec2, 2) }; #endif @@ -106,8 +88,7 @@ struct vec3 { }; // _ is padding for 16-byte alignment float v[4]; // Size 4 to match alignment }; - vec3(float x = 0, float y = 0, float z = 0) : x(x), y(y), z(z), _(0) { - } + vec3(float x = 0, float y = 0, float z = 0) : x(x), y(y), z(z), _(0) {} VEC_OPERATORS(vec3, 3) // Operators only touch x,y,z (indices 0,1,2) static vec3 cross(vec3 a, vec3 b) { @@ -126,8 +107,7 @@ struct vec4 { float v[4]; }; vec4(float x = 0, float y = 0, float z = 0, float w = 0) - : x(x), y(y), z(z), w(w) { - } + : x(x), y(y), z(z), w(w) {} VEC_OPERATORS(vec4, 4) }; #endif @@ -179,8 +159,7 @@ struct quat { float v[4]; }; quat(float x = 0, float y = 0, float z = 0, float w = 1) - : x(x), y(y), z(z), w(w) { - } + : x(x), y(y), z(z), w(w) {} VEC_OPERATORS(quat, 4) quat operator*(const quat &q) const { @@ -198,8 +177,7 @@ struct quat { static quat from_to(vec3 a, vec3 b) { float d = vec3::dot(a, b); vec3 axis = vec3::cross(a, b); - if (d < -0.9999f) - return {0, 1, 0, 0}; + if (d < -0.9999f) return {0, 1, 0, 0}; float s = std::sqrt((1.0f + d) * 2.0f), inv_s = 1.0f / s; return {axis.x * inv_s, axis.y * inv_s, axis.z * inv_s, s * 0.5f}; } @@ -259,8 +237,7 @@ inline quat slerp(quat a, quat b, float t) { } if (d > 0.9995f) { // Linear fall-back quat r; - for (int i = 0; i < 4; ++i) - r.v[i] = a.v[i] + (b.v[i] - a.v[i]) * t; + for (int i = 0; i < 4; ++i) r.v[i] = a.v[i] + (b.v[i] - a.v[i]) * t; return r; } float th0 = std::acos(d), th = th0 * t, s0 = std::sin(th0), @@ -275,9 +252,7 @@ template <typename T> inline T lerp(const T &a, const T &b, float t) { #ifdef USE_EASING namespace ease { -inline float out_cubic(float t) { - return 1.0f - std::pow(1.0f - t, 3.0f); -} +inline float out_cubic(float t) { return 1.0f - std::pow(1.0f - t, 3.0f); } inline float in_out_quad(float t) { return t < 0.5f ? 2.0f * t * t : 1.0f - std::pow(-2.0f * t + 2.0f, 2.0f) / 2.0f; diff --git a/tools/asset_packer.cc b/tools/asset_packer.cc index 6e939cf..4a2e631 100644 --- a/tools/asset_packer.cc +++ b/tools/asset_packer.cc @@ -59,20 +59,17 @@ int main(int argc, char *argv[]) { std::vector<std::string> asset_names; while (std::getline(assets_txt_file, line)) { - if (line.empty() || line[0] == '#') - continue; + if (line.empty() || line[0] == '#') continue; size_t first_comma = line.find(','); - if (first_comma == std::string::npos) - continue; + if (first_comma == std::string::npos) continue; std::string asset_name = line.substr(0, first_comma); asset_name.erase(0, asset_name.find_first_not_of(" \t\r\n")); asset_name.erase(asset_name.find_last_not_of(" \t\r\n") + 1); size_t second_comma = line.find(',', first_comma + 1); - if (second_comma == std::string::npos) - continue; + if (second_comma == std::string::npos) continue; std::string filename = line.substr(first_comma + 1, second_comma - first_comma - 1); @@ -102,8 +99,7 @@ int main(int argc, char *argv[]) { assets_data_cc_file << "static const uint8_t ASSET_DATA_" << asset_name << "[] = {"; for (size_t i = 0; i < buffer.size(); ++i) { - if (i % 12 == 0) - assets_data_cc_file << "\n "; + if (i % 12 == 0) assets_data_cc_file << "\n "; assets_data_cc_file << "0x" << std::hex << (int)buffer[i] << std::dec << (i == buffer.size() - 1 ? "" : ", "); } diff --git a/tools/seq_compiler.cc b/tools/seq_compiler.cc index 4846244..e84877b 100644 --- a/tools/seq_compiler.cc +++ b/tools/seq_compiler.cc @@ -24,8 +24,7 @@ struct SequenceEntry { std::string trim(const std::string &str) { size_t first = str.find_first_not_of(" "); - if (std::string::npos == first) - return str; + if (std::string::npos == first) return str; size_t last = str.find_last_not_of(" "); return str.substr(first, (last - first + 1)); } @@ -52,8 +51,7 @@ int main(int argc, char *argv[]) { while (std::getline(in_file, line)) { line_num++; std::string trimmed = trim(line); - if (trimmed.empty() || trimmed[0] == '#') - continue; + if (trimmed.empty() || trimmed[0] == '#') continue; std::stringstream ss(trimmed); std::string command; @@ -87,9 +85,7 @@ int main(int argc, char *argv[]) { // Remove leading whitespace from getline if any (getline reads the space // after priority) extra_args = trim(extra_args); - if (!extra_args.empty()) { - extra_args = ", " + extra_args; - } + if (!extra_args.empty()) { extra_args = ", " + extra_args; } current_seq->effects.push_back( {class_name, start, end, priority, extra_args}); diff --git a/tools/spectool.cc b/tools/spectool.cc index 97c5997..5c05a03 100644 --- a/tools/spectool.cc +++ b/tools/spectool.cc @@ -57,9 +57,7 @@ int analyze_audio(const char *in_path, const char *out_path) { } // 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]; diff --git a/tools/specview.cc b/tools/specview.cc index d2f5489..59b6d70 100644 --- a/tools/specview.cc +++ b/tools/specview.cc @@ -64,11 +64,8 @@ int main(int argc, char **argv) { // Find max magnitude for normalization float max_mag = 0.0f; - for (float val : spec_data) { - max_mag = std::max(max_mag, fabsf(val)); - } - if (max_mag == 0.0f) - max_mag = 1.0f; // Avoid division by zero + for (float val : spec_data) { max_mag = std::max(max_mag, fabsf(val)); } + if (max_mag == 0.0f) max_mag = 1.0f; // Avoid division by zero // ASCII visualization const char *gradient = " .:-=+*#%@"; |
