Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deckarep/zigualizer
Zigualizer: A music visualizer built with Zig, powered by the FFT algorithm.
https://github.com/deckarep/zigualizer
fft music raylib spectrum-analyzer visualizer zig zig-package ziglang
Last synced: 24 days ago
JSON representation
Zigualizer: A music visualizer built with Zig, powered by the FFT algorithm.
- Host: GitHub
- URL: https://github.com/deckarep/zigualizer
- Owner: deckarep
- License: mit
- Created: 2024-11-17T05:34:00.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-17T19:20:21.000Z (3 months ago)
- Last Synced: 2024-11-17T20:17:49.055Z (3 months ago)
- Topics: fft, music, raylib, spectrum-analyzer, visualizer, zig, zig-package, ziglang
- Language: C
- Homepage:
- Size: 6.61 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zigualizer
Zigualizer: A music visualizer built with Zig, powered by the FFT algorithm.
[Click here](https://youtu.be/6h9Bty-wdMA) for a demo on YouTube!![](screenshot.png)
## Details
This implementation was originally based on the [Musializer project by @Tsoding](https://github.com/tsoding/musializer/blob/master/src/plug.c).
This version as it stands has been tested to work with Raylib 5.0.
I have modified this version to be backed by a generic circular buffer over a
fixed size array. Additionally, I am leveraging comptime in a few spots to
generate some static windowing functions.## Raylib integration
For a more thorough example see raylib.zig in the examples/ folder.
Integration is a 4-step process (aside from music stream code).```zig
// 1. Import
const fft = @import("zigualizer");// 2. Init
fft.FFT_Analyzer.reset();// After loading up a Raylib Music stream.
track = c.LoadMusicStream(pathToTrack);
defer c.UnloadMusicStream(track);// 3. Attach
c.AttachAudioStreamProcessor(track.stream, fft.FFT_Analyzer.fft_process_callback);
c.PlayMusicStream(track);// In your update loop
fn update() void {
c.UpdateMusicStream(track);
// 4. Analyze
frames = fft.FFT_Analyzer.analyze(c.GetFrameTime());
}// In your draw loop render the FFT however you like!
fn draw() void {
c.BeginDrawing();
defer c.EndDrawing();
c.ClearBackground(c.BLACK);
// 5. Draw
renderFFT(400, 200);
}
```## Building the examples
```sh
# Run the Raylib demo.
zig build -Dexample-name=raylib.zig && zig-out/example/raylib
```