A professional real-time digital signal processing application for audio analysis and frequency visualization. Built with Java 21, featuring an intuitive GUI and advanced signal processing capabilities.
- Real-time Audio Capture: Multi-device support with automatic source selection
- FFT Analysis: Fast Fourier Transform using Apache Commons Math (pure Java, cross-platform)
- Frequency Visualization: Live frequency spectrum chart with JFreeChart
- Advanced Signal Processing:
- Hamming window function for reduced spectral leakage
- Noise threshold filtering (3x average magnitude)
- DC component removal
- 5-sample frequency smoothing for stable readings
- Configurable FFT size (512, 1024, 2048, 4096, 8192 samples)
- Modern look and feel with FlatLaf theme support (Dark/Light modes)
- Intuitive controls with real-time status updates
- Dynamic audio device selection
- Configurable sample rates (8kHz - 48kHz)
- Responsive chart with auto-scaling axes
- Performance optimized with 50ms update throttling
- Java 21 or higher
- Maven 3.6+ for dependency management
- Audio input device (microphone)
- Supported Platforms: Windows, macOS (including Apple Silicon), Linux
-
Clone the repository
git clone https://github.com/YOUR_USERNAME/Java-DSP.git cd Java-DSP -
Build the project
mvn clean package
-
Run the application
mvn exec:java -Dexec.mainClass="com.gpoole.dsp.GUI"Or run the JAR directly:
java -jar target/DSP-Java-1.0-SNAPSHOT.jar
- Select Audio Source: Choose your microphone from the dropdown menu
- Configure Settings:
- Select sample rate (recommended: 48000 Hz)
- Choose FFT size (recommended: 2048 for balanced resolution/performance)
- Start Capture: Click "Start Capture" to begin real-time analysis
- View Results: Watch the frequency spectrum update in real-time
- Stop Capture: Click "Stop" when finished
Audio Input → Stereo to Mono → Hamming Window → FFT → Magnitude Calculation →
Noise Filtering → DC Removal → Frequency Smoothing → Visualization
- GUI.java: Main application window with audio capture and control logic
- XYLineChart.java: Optimized chart component with update throttling
- DSP.java: Static utility class for FFT, power spectra, and frequency detection
- SignalPipeline.java: Fluent builder API for chaining DSP operations
- WindowFunction.java: Enum of standard window functions (Hamming, Hanning, Blackman, Flat-top)
- Preconditions.java: Shared input-validation utility for fail-fast error reporting
- FFT Processing: Apache Commons Math FastFourierTransformer
- Audio API: javax.sound.sampled for cross-platform audio capture
You can use the signal-processing classes directly, without the GUI:
import com.gpoole.dsp.signal.*;
// One-shot: detect the dominant frequency of an audio buffer
double freq = DSP.dominantFrequency(samples, 48_000);
// Pipeline: chain window → DC removal → power spectrum
double[] spectrum = SignalPipeline.of(samples, 48_000)
.window(WindowFunction.HAMMING)
.removeDC()
.executeToPowerSpectrumDB(0.776);
// Available windows: RECTANGULAR, HAMMING, HANNING, BLACKMAN, FLAT_TOP
double[] coefficients = WindowFunction.BLACKMAN.getCoefficients(1024);| Library | Version | Purpose |
|---|---|---|
| Apache Commons Math | 3.6.1 | FFT computation |
| JFreeChart | 1.0.13 | Frequency visualization |
| FlatLaf | 3.6 | Modern UI theme |
| JUnit Jupiter | 5.12.2 | Unit testing |
# Compile
mvn clean compile
# Run tests
mvn test
# Generate test reports
mvn surefire-report:report
# Package
mvn packageThe project includes comprehensive test suites:
- FFTProcessingTest: FFT functionality, peak detection, windowing, noise filtering
- AudioFormatTest: Audio format handling, sample conversion, device compatibility
- XYLineChartTest: Chart rendering, data updates, performance
mvn testJava-DSP/
├── src/
│ ├── main/java/com/gpoole/dsp/
│ │ ├── GUI.java # Main application
│ │ ├── XYLineChart.java # Chart component
│ │ ├── signal/
│ │ │ ├── DSP.java # Static DSP helpers (FFT, spectra)
│ │ │ ├── SignalPipeline.java # Fluent pipeline builder
│ │ │ └── WindowFunction.java # Window function enum
│ │ └── util/
│ │ └── Preconditions.java # Input validation
│ └── test/java/com/gpoole/dsp/
│ ├── FFTProcessingTest.java
│ ├── AudioFormatTest.java
│ ├── XYLineChartTest.java
│ ├── signal/
│ │ ├── DSPTest.java # Golden-value FFT tests
│ │ ├── SignalPipelineTest.java
│ │ └── WindowFunctionTest.java
│ └── util/
│ └── PreconditionsTest.java
├── .github/workflows/
│ ├── build-and-test.yml # CI pipeline
│ ├── release.yml # Release automation
│ └── codeql.yml # Security scanning
├── pom.xml
└── README.md
This project uses GitHub Actions for automated building, testing, and releases:
- Build and Test: Runs on every push/PR across Windows, macOS, and Linux
- CodeQL Analysis: Automated security vulnerability scanning
- Release: Automated releases on version tags (v*)
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0This automatically triggers the release workflow, building artifacts for all platforms.
- ✅ Extracted reusable
DSPutility class with static FFT/spectrum helpers - ✅ Added
SignalPipelinefluent API for chaining DSP operations - ✅ Added
WindowFunctionenum with Hamming, Hanning, Blackman, Flat-top windows - ✅ Added
Preconditionsutility for fail-fast input validation - ✅ Added JaCoCo code-coverage reporting
- ✅ Added golden-value parameterized tests for FFT accuracy
- ✅ Added comprehensive Javadoc across all public APIs
- ✅ Fixed audio buffer calculation for stereo/mono handling
- Ensure your microphone is connected and enabled in system settings
- Check system permissions for microphone access
- Try running with administrator/sudo privileges
- Increase FFT size for better resolution
- Ensure adequate signal strength (speak/whistle loudly)
- Try different sample rates
- Check for background noise
- Reduce FFT size (e.g., 1024 instead of 4096)
- Lower sample rate
- Close other audio applications
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Apache Commons Math for robust FFT implementation
- JFreeChart for excellent charting capabilities
- FlatLaf for modern UI theming
- Java Sound API for cross-platform audio support