An Android application that captures live audio, performs FFT analysis using multiple language implementations (C++, Java, Python), and provides real-time visualization with performance benchmarking.
- ✅ Real-time Audio Capture: Uses Android's AudioRecord API for low-latency microphone input
- ✅ Multi-Language FFT Processing: Runs FFT implementations from:
- C++ (via JNI/NDK)
- Java (native Kotlin port)
- Python (using Java as fallback - Python JNI integration is complex)
- ✅ Live Visualization: Grid layout displaying three simultaneous FFT visualizations
- Waveform view (time domain)
- Frequency spectrum view (frequency domain)
- Real-time FPS and latency metrics
- ✅ Performance Benchmarking:
- Processing speed measurement per implementation
- FPS tracking
- Frequency detection accuracy
- Divergence calculation between implementations
- ✅ Data Export: CSV export of all collected metrics
- ✅ Performance Charts: Line charts showing metrics over time using MPAndroidChart
- Android SDK 34+ (Android 14+)
- Gradle 8.2+
- NDK (for C++ FFT compilation)
- Kotlin 1.9.20+
- Samsung Galaxy S25 Ultra
- Samsung Tab S10+
- Any Android device running Android 14+
android/
├── app/
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/com/flaccidfacade/fftvisualizer/
│ │ │ │ ├── MainActivity.kt # Main activity with grid layout
│ │ │ │ ├── PerformanceChartActivity.kt # Charts activity
│ │ │ │ ├── fft/
│ │ │ │ │ ├── JavaFFT.kt # Java FFT implementation
│ │ │ │ │ └── NativeFFT.kt # JNI wrapper for C++ FFT
│ │ │ │ ├── view/
│ │ │ │ │ ├── WaveformView.kt # Custom waveform view
│ │ │ │ │ └── FrequencyView.kt # Custom frequency view
│ │ │ │ ├── audio/
│ │ │ │ │ └── AudioCaptureManager.kt # Audio capture logic
│ │ │ │ ├── data/
│ │ │ │ │ └── FFTMetrics.kt # Metrics data classes
│ │ │ │ └── utils/
│ │ │ │ ├── CSVExporter.kt # CSV export utility
│ │ │ │ └── FFTUtils.kt # FFT utility functions
│ │ │ ├── cpp/
│ │ │ │ ├── CMakeLists.txt # CMake build configuration
│ │ │ │ └── fft_jni.cpp # JNI wrapper for C++ FFT
│ │ │ ├── res/ # Android resources
│ │ │ └── AndroidManifest.xml
│ │ └── build.gradle.kts
│ └── proguard-rules.pro
├── build.gradle.kts
├── settings.gradle.kts
└── README.md
- Install Android Studio Arctic Fox or later
- Install Android SDK 34
- Install NDK (via SDK Manager)
- Install CMake (via SDK Manager)
-
Clone the repository:
git clone https://github.com/FlaccidFacade/FFT.git cd FFT/android -
Open in Android Studio:
- File → Open → Select the
androiddirectory
- File → Open → Select the
-
Sync Gradle:
- Android Studio will automatically sync Gradle dependencies
-
Build the project:
./gradlew build
-
Install on device:
./gradlew installDebug
Or use Android Studio's "Run" button.
- Launch the app
- Grant microphone permission when prompted
- Tap "Start Audio Capture" button
- Speak, play music, or generate sound near the device microphone
- Observe real-time FFT visualizations for each implementation
- Tap "View Performance Charts" button
- View three charts:
- Processing speed over time
- Detected frequency accuracy
- Implementation divergence
- Tap "Export CSV Data" button
- Data is saved to app-specific storage:
Android/data/com.flaccidfacade.fftvisualizer/files/Documents/ - Access via file manager or ADB:
adb pull /sdcard/Android/data/com.flaccidfacade.fftvisualizer/files/Documents/
- AudioCaptureManager: Captures PCM audio data from microphone at 44.1kHz
- Windowing: Applies Hamming window to reduce spectral leakage
- FFT Processing: Computes FFT using three implementations:
- C++ (native via JNI)
- Java (Kotlin port)
- Python (Java fallback)
- Frequency Analysis: Detects dominant frequency and peak magnitude
- Metrics Collection: Records processing time, FPS, and accuracy
- Visualization: Updates waveform and frequency views in real-time
- Coroutines: Audio processing runs on background threads
- Native Code: C++ FFT provides lowest latency
- Efficient Rendering: Custom views minimize overdraw
- Buffering: Audio buffer size optimized for real-time performance
- AndroidX: Core Android libraries
- Kotlin Coroutines: Asynchronous programming
- MPAndroidChart: Chart visualization
- Oboe: Low-latency audio (library available, not yet integrated)
- OpenCSV: CSV file export
- Python FFT: Currently uses Java implementation as fallback. Full Python integration via Chaquopy or similar would require additional setup.
- Storage Permissions: On Android 14+, app-specific storage is used (no broad storage permission needed)
- Background Processing: Audio capture stops when app is backgrounded
- Microphone permission request/grant
- Audio capture start/stop
- Real-time waveform visualization
- Real-time frequency visualization
- FPS counter updates
- Latency measurement displays correctly
- Frequency detection works with tone generator app
- Performance charts display data
- CSV export creates file successfully
- App works on phone (portrait/landscape)
- App works on tablet with larger grid
- Install a tone generator app (e.g., "Tone Generator" by netigen)
- Generate a 440 Hz sine wave
- Verify all three implementations detect ~440 Hz
- Compare processing latencies
- Full Python FFT integration via Chaquopy
- Go FFT implementation (via gomobile)
- Rust FFT implementation via JNI
- Real-time divergence calculation between implementations
- Spectrogram view
- Frequency range selection
- Audio file playback and analysis
- Benchmark mode with synthetic signals
- Play Store deployment automation
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test on physical devices
- Submit a pull request
MIT License - See main repository LICENSE file
- FFT implementations from FlaccidFacade/FFT repository
- MPAndroidChart by PhilJay
- Android AudioRecord API documentation