Transform your music into a mesmerizing light show with real-time FFT audio analysis and Arduino-controlled RGB LEDs
Features β’ Demo β’ Quick Start β’ Architecture β’ API β’ Contributing
ColorfulSound is a sophisticated audio visualization system that bridges digital sound with physical RGB lighting. Using Fast Fourier Transform (FFT) analysis and beat detection algorithms, it maps audio frequencies to a rainbow color spectrum in real-time, creating immersive lighting experiences synchronized to your music.
Whether you're building an ambient lighting setup, enhancing your music room, or creating a DJ booth visualization, ColorfulSound provides the software foundation to bring audio to life through color.
| Feature | Description |
|---|---|
| Real-Time FFT Analysis | 2048-sample buffer FFT processing using the Minim audio library |
| Beat Detection | Dual-mode detection: overall energy onset + frequency-range beats |
| Dynamic Range Mapping | Automatically adapts to the frequency content of your music |
| Rainbow Color Blending | Maps 7 rainbow colors (ROYGBIV) to frequency bands with smooth blending |
| Cross-Platform | Windows, Linux, macOS, and Raspberry Pi support |
| System Tray Control | Lightweight tray icon with full feature control |
| Visual Debugging | Optional Processing-based visualization window |
- Enable/Disable - Toggle LED output on/off
- Color Change Mode - Switch between dynamic colors and fixed color
- Default Color Picker - Choose your preferred static color with alpha
- Sensitivity Modes - High/Low sensitivity for different music types
- Rainbow Shuffle - Randomize the color-to-frequency mapping
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ColorfulSound System β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββββββββββ ββββββββββββββββ β
β β Audio Input ββββββΆβ Beat Detection & ββββββΆβ Arduino β β
β β (Minim) β β FFT Analysis β β Connector β β
β ββββββββββββββββ ββββββββββββββββββββββββ ββββββββββββββββ β
β β β β β
β β βΌ β β
β β ββββββββββββββββββββ β β
β β β Color Mapping β β β
β β β (Rainbow Blend) β β β
β β ββββββββββββββββββββ β β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ β
β β System Tray β β Visualization β β RGB LEDs β β
β β UI β β (Processing) β β (Hardware) β β
β ββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
com.ayush.colorfulsound
βββ SoundEnergyBeatDetection.java # Main application & audio processing
β βββ BeatListener # AudioListener implementation
β βββ setup() # Initialize audio, UI, Arduino
β βββ draw() # Main loop: FFT + color calculation
β βββ sendToArduino() # Queue RGB values to serial port
β βββ blend() # Multi-color weighted averaging
β
βββ SoundEnergyBeatDetectionGUI.java # Processing visualization mode
β βββ PApplet extension # Processing application base
β βββ Visual beat feedback # Animated circles on beat
β
βββ ArduinoConnector.java # Serial communication handler
βββ Platform detection # Auto-detect serial ports
βββ RXTX integration # Cross-platform serial I/O
βββ Event handling # Bidirectional communication
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Audio Thread β β Queue Worker β β Update Thread β
β (Minim) β β (Executor) β β (15ms loop) β
βββββββββββββββββββ€ βββββββββββββββββββ€ βββββββββββββββββββ€
β β’ Sample captureβ β β’ Process queue β β β’ Decay radius β
β β’ Beat detectionβ β β’ Serial write β β β’ Refresh LEDs β
β β’ Color calc β β β’ Order guaranteeβ β β’ State sync β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β² β
ββββββββββββββββββββββ΄βββββββββββββββββββββββ
BlockingQueue<Runnable>
Audio Input (Stereo, 2048 samples)
β
βΌ
βββββββββββββββββββββββββββββββββββ
β BeatDetect (Energy) β βββΆ Onset Detection (eRadius = 500)
β Sensitivity: 100ms β
βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββ
β BeatDetect (Frequency) β βββΆ Per-band beat detection
β Full spectrum analysis β
βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββ
β Dynamic Range Tracking β βββΆ Exponential smoothing (0.97)
β Identify active frequencies β
βββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββ
β Rainbow Color Mapping β βββΆ 7 colors: R-O-Y-G-B-I-V
β Blend matching frequencies β High freq β Violet
βββββββββββββββββββββββββββββββββββ Low freq β Red
β
βΌ
βββββββββββββββββββββββββββββββββββ
β Amplitude Scaling β βββΆ RGB * (radius / 500)
β Based on beat intensity β
βββββββββββββββββββββββββββββββββββ
β
βΌ
Serial Output (R, G, B)
- Java 8+ - Download
- Arduino IDE - Download
- RGB LED Strip or Module - Common cathode or anode
- Arduino Board - Uno, Nano, or compatible
Arduino Uno
βββββββββββββ
β β
RGB LED β D11 ββββΌβββΆ Red (with resistor)
(Common β D10 ββββΌβββΆ Green (with resistor)
Cathode) β D9 ββββΌβββΆ Blue (with resistor)
β GND ββββΌβββΆ Common Cathode
β β
βββββββββββββ
Note: Use 220Ξ©-330Ξ© current limiting resistors
Warning: Arduino is a 5V device! For 12V LED strips, you must use transistors (TIP120/IRLZ44N) or a MOSFET driver. See this guide for proper wiring.
// Arduino/colorfulsound/colorfulsound.ino
// Pin configuration:
int redPin = 11; // PWM pin for red
int greenPin = 10; // PWM pin for green
int bluePin = 9; // PWM pin for blue- Open
Arduino/colorfulsound/colorfulsound.inoin Arduino IDE - For common anode LEDs, uncomment:
#define COMMON_ANODE - Upload to your Arduino board
Copy the appropriate DLL to your system:
| Architecture | Source | Destination |
|---|---|---|
| 64-bit | libraries/rxtx-2.2pre2-bins/win64/rxtxSerial.dll |
C:\Windows\System32\ |
| 32-bit | libraries/rxtx-2.2pre2-bins/win32/rxtxSerial.dll |
C:\Windows\SysWOW64\ |
Important: ColorfulSound listens to your system's audio output via "Stereo Mix" or "What U Hear"
Windows:
- Right-click speaker icon β Sounds β Recording tab
- Right-click β Show Disabled Devices
- Enable Stereo Mix β Set as Default Device
- Start ColorfulSound, then switch back to Microphone if desired
Linux:
# Use PulseAudio monitor
pactl load-module module-loopbackmacOS:
- Use Soundflower or BlackHole
Option A: Pre-built Executable (Windows)
exe/ColorfulSound.exeOption B: Java JAR (Cross-platform)
java -jar exe/ColorfulSound.jarOption C: With Visualization (Development)
# Run from IDE: SoundEnergyBeatDetectionGUI.main()-
Test Serial Port:
# Run ArduinoConnector standalone java -cp "exe/ColorfulSound.jar" com.ayush.colorfulsound.ArduinoConnector # Type RGB values (0-255) to test LED response 255 # Red full 0 # Green off 0 # Blue off
-
Verify Detection:
- Check console output for detected COM port
- LEDs should respond to typed values
The main application class managing audio processing and LED control.
| Field | Type | Default | Description |
|---|---|---|---|
enabled |
volatile boolean |
true |
Master on/off for LED output |
colorEnabled |
volatile boolean |
true |
Dynamic colors vs fixed color |
defaultColor |
volatile Color |
RED |
Static color when dynamic disabled |
threshold1 |
volatile boolean |
false |
High sensitivity mode |
threshold2 |
volatile boolean |
false |
Low sensitivity mode |
eRadius |
volatile float |
500 |
Beat intensity (decays to 50) |
// Initialize audio, UI, and Arduino connection
public void setup()
// Main audio processing loop (called per sample buffer)
public void draw()
// Queue RGB values to Arduino (thread-safe)
private synchronized void sendToArduino(int r, int g, int b, float a)
// Blend multiple colors with weighted averaging
public static Color blend(List<Color> colors)Cross-platform serial communication handler.
| Platform | Port Pattern |
|---|---|
| macOS | /dev/tty.usbserial-* |
| Linux | /dev/ttyUSB0, /dev/ttyACM0 |
| Windows | COM3 (configurable) |
| Raspberry Pi | /dev/ttyACM0 |
BAUD_RATE = 9600
DATA_BITS = 8
STOP_BITS = 1
PARITY = NONE
TIMEOUT = 2000msThe Arduino expects 3 consecutive bytes per frame:
| Byte | Range | Description |
|---|---|---|
| 1 | 0-255 | Red intensity |
| 2 | 0-255 | Green intensity |
| 3 | 0-255 | Blue intensity |
// Arduino receives RGB in sequence
void loop() {
if (Serial.available() > 0) {
// Reads R, G, B sequentially
// Calls setColor(r, g, b) when complete
}
}| Library | Version | License | Purpose |
|---|---|---|---|
| Minim | Latest | LGPL | Audio input, FFT, beat detection |
| Processing Core | Latest | LGPL | Graphics framework |
| RXTX | 2.2pre2 | LGPL | Serial communication |
| JOGL | Latest | BSD | OpenGL for Processing |
ColorfulSound/
βββ Arduino/
β βββ colorfulsound/
β βββ colorfulsound.ino # Arduino firmware
βββ src/
β βββ com/ayush/colorfulsound/
β βββ SoundEnergyBeatDetection.java # Main app (449 lines)
β βββ SoundEnergyBeatDetectionGUI.java # Visual mode (133 lines)
β βββ ArduinoConnector.java # Serial handler (134 lines)
βββ libraries/
β βββ minim/ # Audio processing
β βββ processing/ # Graphics + OpenGL natives
β βββ rxtx-2.2pre2-bins/ # Serial natives (Win/Linux/Mac)
βββ exe/
β βββ ColorfulSound.jar # Compiled JAR
β βββ ColorfulSound.exe # Windows executable
βββ images/
β βββ icon.png # Application icon (legacy)
β βββ icon.svg # Application icon (scalable)
βββ launch4j/
β βββ config.xml # EXE wrapper config
βββ docs/
βββ ... # Documentation
- Import as existing project (Eclipse metadata included)
- Libraries are pre-configured in
.classpath - Run
SoundEnergyBeatDetection.main()
# From Eclipse: Export β Runnable JAR File
# Main class: com.ayush.colorfulsound.SoundEnergyBeatDetection
# Library handling: Package required libraries into JAR- Install Launch4j
- Open
launch4j/config.xml - Build β Creates
exe/ColorfulSound.exe
| Issue | Solution |
|---|---|
| "Could not find COM port" | Check Arduino connection, verify drivers installed |
| No audio response | Enable Stereo Mix in Recording devices |
| LEDs always off | Check common anode/cathode setting in Arduino code |
| Colors inverted | Toggle COMMON_ANODE define in Arduino sketch |
| Port locked (Linux) | Run sudo chmod 666 /dev/ttyUSB0 or add user to dialout group |
Run the GUI version for visual debugging:
// Shows real-time beat visualization
SoundEnergyBeatDetectionGUI.main()Contributions are welcome! Please see our Contributing Guidelines for details.
- Fork the repository
- Clone your fork
- Import into Eclipse or your preferred IDE
- Make changes and test thoroughly
- Submit a pull request
- Maven/Gradle build system
- Additional color mapping algorithms
- Web-based configuration interface
- Support for addressable LED strips (WS2812B)
- Audio file input mode
- Network streaming support
- Minim - Powerful audio library
- Processing Foundation - Creative coding framework
- RXTX Project - Cross-platform serial communication
- Icon by Alecive Flatwoken
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2016 Ayush Jain
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...
If you find ColorfulSound useful, consider supporting its development:
Made with by Ayush Jain

