Skip to content

A Rust-built music visualiser demonstrating homegrown DSP :)

Notifications You must be signed in to change notification settings

bluelhf/audio-whiz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

audio-whiz

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 (via Supersample::with_cosine_interpolation(...))

Usage

Prepare for some fun and exciting platform-specific setup!

  1. First, follow the nannou setup steps1
  2. 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
  3. Navigate to the project directory (folder) in the terminal, and run it with the cargo run --release command.
  4. You are done! Enjoy the visualisation!

Note
Because the project's dependencies are gigantic (about half the average node_modules directory), it's recommended to use a fast linker like mold. If you have mold installed, you can use it by running mold -run cargo run --release instead.

How do I play good music 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

  1. Archived from the original at 2022-05-20T17:36:32Z

About

A Rust-built music visualiser demonstrating homegrown DSP :)

Topics

Resources

Stars

Watchers

Forks

Languages