A simple real-time audio visualizer built with Python that captures live microphone input and transforms it into dynamic frequency-based visualizations using Fast Fourier Transform (FFT) analysis. You can check out the mini research I did for the project to understand the fundamentals here 👉 Mini Research Dump
- Real-time Audio Processing: Captures live microphone input using PyAudio
- Frequency Analysis: FFT-based frequency spectrum analysis with logarithmic frequency bins
- Smooth Animations: Gravity-based bar animations with peak detection
sound-visualizer.mp4
AudioStream(audio_stream.py): Handles real-time audio capture from microphone inputDSPProcessor(dsp_processor.py): Performs Fast Fourier Transform and frequency analysisRenderer(renderer.py): Manages pygame-based visualization rendering and animationsmain.py: Application entry point and main event loop
All settings are centralized in config.py:
- Audio stream parameters (sample rate, chunk size, channels)
- DSP processing settings (frequency ranges, smoothing)
- Visualization options (screen dimensions, colors, bar count)
- Python 3.12 or higher
- System audio drivers and microphone access
- uv Python package manager
- Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh- Clone the repository:
git clone <repository-url>
cd sound-visualizer/py-soundxy- Create virtual environment and install dependencies:
uv syncuv run main.py- ESC or Close Window: Exit the application
- The visualizer will automatically start capturing audio from your default microphone
Edit config.py to customize
- pygame: Graphics rendering and window management
- numpy: Numerical computations and FFT operations
- pyaudio: Real-time audio input capture
- ruff: Code formatting and linting (development)
-
No Audio Input:
- Check microphone permissions in your system
- Ensure microphone is not muted
- Verify PyAudio can access your audio device
-
Performance Issues:
- Reduce
CHUNK_SIZEfor lower latency - Decrease
NUM_BARSfor less computational load - Lower
FPStarget in config
- Reduce
-
Installation Errors:
- Install system audio development libraries
- On Linux:
sudo apt-get install portaudio19-dev - On macOS:
brew install portaudio
The application uses your default recording device. To use a specific device, modify the AudioStream class to accept device indices.
This project uses Ruff for code formatting and linting. Run checks with:
uv run ruff check .
uv run ruff format .This project is open source under MIT License.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
- Multiple visualization modes (waveform, circular, particles)
- Audio file playback support
- Advanced audio effects (filters, reverb visualization)# sound-visualizer