showcase.mp4
A Rust-built music visualiser, built as an exercise to practice both the Rust programming language and homegrown digital signal processing.
DSP Feature | Description |
---|---|
Pad | Zero-pads the FFT input to a desired buffer size (to make it valid input in the first place) |
Hann window | Applies the Hann function to an input signal for cleaner FFT results. |
FFT | Performs a Fast Fourier Transform on sample data to obtain frequency ranges |
Demangle | Takes the FFT output in [DC, +Freq, -Freq] format and returns only the positive frequency range. |
Squish | Squishes the frequency domain by a factor 0 < f < 1 by skipping i * f elements after each element at index i. |
LimitFrequencyRange | Limits the range of frequencies for FFT output to the given range. |
ToDBFS | Converts FFT output from amplitude ranges to decibels relative to full scale. |
Subsample | Subsamples data by a given factor by only taking every factor -th element. |
Supersample | Supersamples data using a given interpolation function and supersampling factor. |
Note
Subsampling and supersampling can be used together to smooth the output signal while retaining scale. Additionally, the Supersample step provides cosine interpolation by default (viaSupersample::with_cosine_interpolation(...)
)
Prepare for some fun and exciting platform-specific setup!
- First, follow the
nannou
setup steps1 - Either
- Download and extract the sources from GitHub (with the
Code > Download ZIP
button at the top right), or - Clone the repository with Git's
git clone https://github.com/bluelhf/audio-whiz
command
- Download and extract the sources from GitHub (with the
- Navigate to the project directory (folder) in the terminal, and run it with the
cargo run --release
command. - You are done! Enjoy the visualisation!
Note
Because the project's dependencies are gigantic (about half the averagenode_modules
directory), it's recommended to use a fast linker like mold. If you have mold installed, you can use it by runningmold -run cargo run --release
instead.
You can change the song by changing the path in the model(...)
function in src/main.rs
.
fn model(_app: &App) -> Model {
let manager = AudioManager::new();
- manager.play(audrey::read::open(Path::new("./music/the_music_i_like.wav"))
+ manager.play(audrey::read::open(Path::new("./music/good_music.wav"))
.expect("failed to read audio")).expect("failed to play audio");
Model { manager }
}
Note
Due to strange sample rate issues, only .WAV files are supported.
Footnotes
-
Archived from the original at 2022-05-20T17:36:32Z ↩