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/audio/fdct.cc | |
| 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/audio/fdct.cc')
| -rw-r--r-- | src/audio/fdct.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/audio/fdct.cc b/src/audio/fdct.cc new file mode 100644 index 0000000..5cf0211 --- /dev/null +++ b/src/audio/fdct.cc @@ -0,0 +1,17 @@ +#include "dct.h" +#include "util/math.h" +#include <math.h> + +void fdct_512(const float input[DCT_SIZE], float output[DCT_SIZE]) { + float scale_k0 = sqrtf(1.0f / DCT_SIZE); + float scale_kn = sqrtf(2.0f / DCT_SIZE); + + for (int k = 0; k < DCT_SIZE; ++k) { + float sum = 0.0f; + for (int n = 0; n < DCT_SIZE; ++n) { + sum += input[n] * cosf((PI / DCT_SIZE) * (n + 0.5f) * k); + } + float scale = (k == 0) ? scale_k0 : scale_kn; + output[k] = sum * scale; + } +} |
