diff options
| author | skal <pascal.massimino@gmail.com> | 2026-01-27 23:09:27 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-01-27 23:10:49 +0100 |
| commit | 9dcf94ab01269311b4e5d39be23c95560904c626 (patch) | |
| tree | ac271af3d51d7ee1bce6827f81e97f1f463336db /src/main.cpp | |
| parent | 364d9e60e3c27cb131a598fe5f83deb74493319f (diff) | |
feat: Implement spectool & specview; refactor coding style; update docs
This commit introduces new tools for spectrogram manipulation and visualization, establishes a consistent coding style, and updates project documentation.
Key changes include:
- **Spectrogram Tools:
- : A command-line utility for analyzing WAV/MP3 files into custom spectrogram format and playing back these spectrograms via the synth engine.
- : A command-line tool for visualizing spectrogram files as ASCII art in the console.
- **Coding Style Enforcement:
- Added a configuration file enforcing LLVM-based style with 2-space indentation, no tabs, and an 80-column line limit.
- Renamed all C++ source files from to for project consistency.
- Applied automatic formatting using
exit across the entire codebase.
- **Documentation & Workflow:
- Created to define a commit policy requiring tests to pass before committing.
- Updated with instructions for building and using and , and referenced .
- Updated and to reflect the new tools, audio architecture decisions (real-time additive synthesis, double-buffering for dynamic updates, WAV/MP3 support), coding style, and development workflow.
- **Build System:
- Modified to:
- Include new targets for and under the option.
- Update source file extensions to .
- Add a new end-to-end test for to the suite.
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index c1e2789..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "platform.h" -#include "gpu/gpu.h" -#include "audio/audio.h" -#include "audio/synth.h" -#include "util/math.h" -#include <string.h> -#include <math.h> - -#define DEMO_BPM 120.0f -#define SECONDS_PER_BEAT (60.0f / DEMO_BPM) -#define SPEC_FRAMES 16 - -static float g_spec_buffer_a[SPEC_FRAMES * DCT_SIZE]; -static float g_spec_buffer_b[SPEC_FRAMES * DCT_SIZE]; - -void generate_tone(float* buffer, float freq) { - memset(buffer, 0, SPEC_FRAMES * DCT_SIZE * sizeof(float)); - for (int frame = 0; frame < SPEC_FRAMES; ++frame) { - float* spec_frame = buffer + frame * DCT_SIZE; - float amplitude = 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; - } - } -} - -int main() { - platform_init(); - gpu_init(platform_get_window()); - audio_init(); - - generate_tone(g_spec_buffer_a, 440.0f); // A4 - generate_tone(g_spec_buffer_b, 880.0f); // A5 - - Spectrogram spec = { g_spec_buffer_a, g_spec_buffer_b, SPEC_FRAMES }; - int tone_id = synth_register_spectrogram(&spec); - - double last_beat_time = 0.0; - int beat_count = 0; - - while (!platform_should_close()) { - platform_poll(); - - double current_time = platform_get_time(); - if (current_time - last_beat_time > SECONDS_PER_BEAT) { - synth_trigger_voice(tone_id, 0.5f, 0.0f); - last_beat_time = current_time; - beat_count++; - - if (beat_count == 8) { - // Time to update the sound! - float* back_buffer = synth_begin_update(tone_id); - if (back_buffer) { - generate_tone(back_buffer, 220.0f); // A3 - synth_commit_update(tone_id); - } - } - } - - gpu_draw(); - audio_update(); - } - - audio_shutdown(); - gpu_shutdown(); - platform_shutdown(); - return 0; -} |
