Pygame EQ Visualizer is a real-time audio visualizer built using Python and Pygame. It captures audio input and generates a dynamic visual representation of sound frequencies, similar to an equalizer display. This project showcases Pygame's versatility in a fun, interactive way, extending its use beyond game development.
- Real-Time Audio Processing: Visualizes frequencies from live audio input or audio files.
- Customizable Display: Modify colors, bar sizes, animation speed, and more.
- Simple and Lightweight: Ideal for beginners learning audio processing and Pygame.
To run this project, you will need:
- Python 3.x
- Pygame installed:
pip3 install pygame
- PyAudio for real-time audio input:
pip3 install pyaudio
- PortAudio system dependency for PyAudio (Linux):
sudo apt install portaudio19-dev python3-pyaudio
-
Clone this repository:
git clone https://github.com/onojk/pygame-eq-visualizer.git
-
Navigate to the project directory:
cd pygame-eq-visualizer
-
Install the necessary system dependencies (Linux):
sudo apt update sudo apt install portaudio19-dev python3-pyaudio
For Windows and macOS, follow the specific PyAudio installation instructions from PyAudio's official page.
-
Install the Python dependencies:
pip3 install -r requirements.txt
-
Use the provided install_requirements.py script to automatically check and install dependencies:
python3 install_requirements.py
- Ensure your microphone or audio input device is connected.
- Run the visualizer:
python3 pygameeq.py
In systems with multiple audio input devices (e.g., built-in audio, USB soundcards, or HDMI outputs), managing the correct input source for the visualizer can be tricky. pavucontrol (PulseAudio Volume Control) provides an intuitive interface to switch between audio sources and adjust audio stream levels.
To install pavucontrol on Linux:
sudo apt install pavucontrol
- Open pavucontrol by typing:
pavucontrol
- Navigate to the Recording tab while the visualizer is running.
- Select the correct audio input device (e.g., microphone, system audio) from the dropdown next to the visualizer process.
- Adjust the input volume if needed.
By using pavucontrol, you can easily direct audio from different sources into the visualizer, ensuring the right input is used for your audio visualization. To visualize a specific audio file, modify the input source within the script.
You can tweak the following settings within the code:
-
Bar Colors:
# Example: Changing Bar Colors BAR_COLOR = (255, 0, 0) # Red
-
Bar Size:
# Example: Adjusting Bar Size BAR_WIDTH = 10 # Width of each bar MAX_BAR_HEIGHT = 300 # Maximum height of bars
-
Animation Speed:
# Example: Modifying Animation Speed FRAME_RATE = 60 # Frames per second
Customize these settings in the code to achieve a personalized look and behavior for your visualizer.
- Python developers learning real-time audio processing.
- Developers exploring Pygame beyond game development.
- Audio and visualization enthusiasts interested in creating personalized tools.
Compared to other audio visualizers, this project is:
- Lightweight and Easy to Use: Simple enough for beginners without requiring advanced audio processing libraries like OpenGL or external DSP tools.
- Pygame-Centric: Built entirely using Pygame, offering a great learning experience for those familiar with the library.
Contributions are welcome! Here’s how you can help:
- Fork the repository.
- Create a new branch for your feature or bugfix:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add feature-name"
- Push to the branch:
git push origin feature-name
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
If you have any questions or run into issues, feel free to contact the project owner:
- Email: onojk123@gmail.com
- GitHub: https://github.com/onojk/pygame-eq-visualizer