Skip to content

an audio visualizer in python, final project for cs50p

Notifications You must be signed in to change notification settings

heyitsR1/rhymlizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rhythmlizer 🎧

Video Demo: https://youtu.be/ku2HHsIalDY


Description

Rhythmlizer is a collection of audio visualizers that react to the music you input.

I decided on keeping 6 different visualizers each with their unique flair. And if the number 6 feels weird to you, it might be because there were close to 10 of them, but the four that didn't make it felt a bit under polished. Simply run the program in your terminal alongside the name/path of the audiofile you want to visualize.


Project Files

Following typical protocol, there's the project.py file, a requirements.txt file, and this README.md file. + (some sample .wav files)


How It Works

The program uses Python's wave module to open the audio file, then converts into a NumPy array which is then used as impact values / amplitude for the visualizers. The fundamentals of all visualizers excluding the line is to draw a lot of tiny circles whose radius is determined by the values in the NumPy array.


Notes

  • The audio file is read in chunks of 1024 which can be altered as well.
  • There's a 22ms delay between the audio playing and visualization which is something to take note of. It's because there's actually nothing linking to the music playing and the visualization being drawn.
  • If nothing else is changed and delay is set to 0ms, the visualization just happens very fast and ends while the music lags behind. This could be something to fix in future.

The_Line Visualizer

The most basic of the bunch is the_line visualizer which just draws lines. For every data point in the 1024 member array (1 chunk), it draws a small line which continues from the last. The x coordinate values are simply moving a bit forward every time, while the y react to the amplitude values (data point). This creates an engaging visualizer.


Rest of the Visualizers

All the rest work on a different fundamental. There are a bunch of tiny circles who individually react to the amplitudes. By altering where these tiny circles are drawn, you can create different patterns.


Other Stuff

Some other things that can affect behaviour are labelled sensi and consistency.

The data from the NumPy array spans over a large range -32k to +32k (for typical .wav). So, to make the visualization a bit more practical, these values are divided by a sensi value before being fed. Increasing this will result in less sensitive visualization. But since that might be counterintuitive to a typical user, there's a match statement that matches higher values of sensi to lower dividing values.

Consistency just refers to how the for loop works and whether it skips through values in the NumPy array of a particular chunk or not. So, if it's not 1, some values in the NumPy array will be skipped. This might be useful if the current pattern looks too cluttered or you want less density overall.


That Was Fun

I think the most fun I had in this project was the math bit and checking out other people approach making visualizers in Python. Getting acquainted with how audio is read and can be processed was fun too.


Hurdles

Being a beginner, one of the things that stumped me was actually writing unit tests for the project. I somewhat knew about mock functions but figuring out how to implement them kinda slowed me down for a while.


What's More

I think the project could use a different approach to synching music and visualization in the future. Moreover, it could also feature a lot more visualizers. But for now, I am satisfied with the offerings here.


Requirements

Install the dependencies using:

pip install -r requirements.txt

About

an audio visualizer in python, final project for cs50p

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages