Skip to content

About

๐ŸŽ›๏ธ Hardware SIMD-accelerated real-time audio pitch detection, SOLA pitch shifting, and zero-allocation DSP filters for Java audio applications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

82 Commits

Folders and files

Repository files navigation

FastAudioProcess 0.1.7 โ€” High-Performance Audio Processing for Java

Status License: MIT Java Platform JitPack


โšก Hardware SIMD-accelerated real-time audio pitch detection, SOLA/WSOLA pitch shifting, multi-track timeline mixing with stereo panning, real-time noise suppression, acoustic feature extraction, and zero-allocation DSP filters.

FastAudioProcess provides native C++ AVX2 vector processing and DSP algorithms for Java audio applications, enabling high-throughput noise suppression, pitch tracking, multi-channel timeline mixing, acoustic classification, and format conversions without Garbage Collection stalls.


Quick Start โ€” Example

1. Multi-Track Timeline Audio Mixing (FastAudioMixer)

import fastaudioprocess.FastAudioMixer;
import java.nio.file.Files;
import java.nio.file.Path;

public class MixerDemo {
    public static void main(String[] args) throws Exception {
        // 1. Initialize 44.1 kHz Stereo Mixer
        FastAudioMixer mixer = new FastAudioMixer(44100, 2);

        // 2. Add background audio / music bed at t=0ms (pan center, 70% volume)
        float[] music = new float[44100 * 5]; // 5 seconds
        mixer.addTrack(music, 0, 0.70f, 0.0f);

        // 3. Layer speech audio at t=1500ms (panned slightly left, 100% volume)
        float[] narrator = new float[44100 * 3]; // 3 seconds
        mixer.addTrack(narrator, 1500, 1.0f, -0.25f);

        // 4. Export mixdown directly as complete WAV bytes with soft-limiter protection
        byte[] wavBytes = mixer.toWavBytes();
        Files.write(Path.of("mixed_output.wav"), wavBytes);
        System.out.printf("Exported mixed audio: %d ms%n", mixer.getDurationMs());
    }
}

2. Real-Time Audio DSP & Noise Suppression

import fastaudioprocess.FastAudioProcess;
import fastaudioprocess.FastAudioEqualizer;
import fastaudioprocess.FastAudioChunker;
import fastaudioprocess.FastFFT;

public class DSPDemo {
    public static void main(String[] args) {
        // 1. Generate 1 second 440Hz sine wave buffer with background noise
        float[] audio = new float[44100];
        for (int i = 0; i < audio.length; i++) {
            audio[i] = (float) Math.sin(2.0 * Math.PI * 440.0 * i / 44100.0);
        }

        // 2. Real-time Spectral Subtraction Noise Suppression (FastFFT)
        FastAudioProcess.suppressNoise(audio, 44100, 1.0f, 0.02f);

        // 3. Acoustic Feature Analysis (Crest Factor & Periodicity)
        float crest = FastAudioProcess.computeCrestFactor(audio);
        float zcr = FastAudioProcess.computeZeroCrossingRate(audio);
        float periodicity = FastAudioProcess.computeAutocorrelationPeriodicity(audio, 35, 160);

        // 4. AVX2 SIMD Pitch Detection with DC Removal
        float pitch = FastAudioProcess.detectPitchNative(audio, 44100);
        System.out.printf("Pitch: %.2f Hz | Crest: %.2f | ZCR: %.3f | Periodicity: %.2f%n", pitch, crest, zcr, periodicity);

        // 5. Stateful Streaming 3-Band Equalizer (Bass +3dB, Treble +2dB)
        FastAudioEqualizer eq = new FastAudioEqualizer();
        eq.setGains(3.0f, 0.0f, 2.0f);
        eq.process(audio);
    }
}

Table of Contents


Why FastAudioProcess?

Standard Java audio loops suffer from float boxing overhead, slow software resamplers, and JVM GC pauses that cause real-time audio crackles. FastAudioProcess solves this by:

  • AVX2 SIMD Vector Acceleration โ€” Uses 256-bit SIMD registers to process multiple float audio channels in parallel.
  • Multi-Track Timeline Mixer (FastAudioMixer) โ€” Sample-accurate track layering with constant-power stereo panning and analog-style soft-knee saturation limiter.
  • Spectral Power Noise Suppression โ€” Real-time in-place stationary noise cancellation ($&lt; 0.1\text{ ms}$ latency).
  • Acoustic Transient & Periodicity Extraction โ€” Instantaneous Zero-Crossing Rate (ZCR), Crest Factor, and Autocorrelation analysis.
  • Native Autocorrelation Pitch Tracking โ€” Detects fundamental frequencies (F0) at sub-millisecond speeds.
  • True WSOLA Pitch-Shifting โ€” Echo-free musical semitone pitch modulation preserving playback duration.
  • Off-Heap Direct Buffers โ€” Operates directly on native memory buffers to prevent JVM Garbage Collection stutters.
Feature javax.sound.sampled TarsosDSP FastAudioProcess
DSP Acceleration None (pure scalar byte loops) Scalar Java float loops AVX2 SIMD 256-bit Vectorized
Multi-Track Timeline Mixer None Limited / basic mixing FastAudioMixer with Constant-Power Pan & Limiter
Spectral Noise Reduction Not supported Slow FFT / object allocations In-place Native (< 0.1 ms latency)
Pitch Tracking (F0) Not supported Yin / MPM (~5-15 ms latency) SIMD Autocorrelation (< 0.5 ms)
Heap / GC Overhead High (buffer allocations per frame) Moderate (heap float arrays) Zero GC (Direct native buffer ops)

Key Features

  • ๐ŸŽ›๏ธ Multi-Track Timeline Mixer (FastAudioMixer) โ€” Sample-accurate audio layering, constant-power stereo panning (-1.0 to +1.0), and soft-knee limiter for dialogue, podcasts, and sound engines.
  • โšก Native AVX2 SIMD Acceleration โ€” Accelerated float audio vector math for 44.1kHz / 48kHz audio streams.
  • ๐Ÿ”‡ Real-Time Noise Suppression โ€” High-speed spectral subtraction & Wiener gain smoothing for studio voice isolation.
  • ๐Ÿ”Š VLC-Style Volume Boost & Soft-Limiter โ€” Volume scaling up to 300% on 16-bit PCM with continuous tanh soft-knee saturation limiting preventing harsh digital clipping.
  • โฑ๏ธ Pitch-Invariant Time-Stretching (WSOLA) โ€” High-fidelity Waveform Similarity Overlap-Add algorithm for speed adjustment with Hann windowing and zero Mickey-Mouse pitch distortion.
  • ๐ŸŽต Clean Echo-Free Pitch-Shifting (pitchShift) โ€” High-quality musical semitone shifting (-12.0 to +12.0) combining WSOLA duration pre-expansion with phase-aligned resampling, completely eliminating flanging and circular echo artifacts.
  • ๐Ÿ“Š Acoustic Feature Extraction โ€” Zero-allocation Crest Factor, Zero-Crossing Rate (ZCR), and Harmonic Periodicity primitives.
  • ๐ŸŽค Real-Time Pitch Tracking โ€” High-speed autocorrelation pitch estimator for voice and instrument tuning.
  • ๐ŸŽ›๏ธ Zero-GC DSP Filters โ€” Multi-channel gain, 3-band equalizer, dynamic noise gate, and FIR filters.
  • ๐Ÿ”„ Interoperable Java Audio Bridge โ€” Seamless conversion to and from standard javax.sound.sampled formats.

Real-World Use Cases

  • ๐ŸŽ™๏ธ Multi-Voice Audio Dramas & Podcasts: Assemble dialogue, background music beds, and sound effects across a sample-accurate timeline with FastAudioMixer.
  • ๐Ÿ—ฃ๏ธ Live Voice AI & STT Preprocessing: Eliminates microphone hiss, room fans, and background noise prior to Whisper/FastSTT.
  • ๐ŸŽง VAD & Voice Feature Classifiers: Supplies fundamental acoustic metrics (Crest Factor, ZCR, Periodicity) to FastVAD.
  • ๐ŸŽธ Digital Audio Workstations (DAW): High-speed audio effect plugins running on FastAudioCapture streams.
  • ๐Ÿค– Voice Bots & Agent Pipelines: Studio-quality voice clean-up with zero cloud API minute-fees.
  • ๐ŸŽฎ Game Sound Engines: Multi-channel audio mixer with real-time pitch shifting for sound effects.

Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Input Audio Tracks / Streams                โ”‚
โ”‚       (Raw Floats, 16-bit PCM, WAV Files, Microphone)       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚
                               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                       FastAudioMixer                        โ”‚
โ”‚          โ€ข Sample-Accurate Timeline Layering (addTrack)     โ”‚
โ”‚          โ€ข Constant-Power Stereo Panning law (pan)          โ”‚
โ”‚          โ€ข Tanh Soft-Knee Limiter (applySoftLimiter)        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ”‚
                               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      FastAudioProcess                       โ”‚
โ”‚    โ€ข Spectral Noise Suppression   โ€ข WSOLA Time-Stretch      โ”‚
โ”‚    โ€ข AVX2 Pitch Detection         โ€ข Clean Pitch-Shifting    โ”‚
โ”‚    โ€ข Crest Factor, ZCR, Periodicity                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚                               โ”‚
        Hardware SIMD                   Direct Output
               โ”‚                               โ”‚
               โ–ผ                               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   FastSIMD (AVX2 Engine)     โ”‚ โ”‚ Interleaved Floats / WAV    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Performance Benchmarks

In the official JMH Benchmark, FastAudioProcess measured throughput across real-time DSP audio operations on 512-sample (16 kHz / 32 ms) frames:

Benchmark                                Mode  Cnt        Score   Units
JMH_Audio.benchmarkAcousticCrestFactor  thrpt    2  1,619,341   ops/s
JMH_Audio.benchmarkAcousticZCR          thrpt    2  1,428,964   ops/s
JMH_Audio.benchmarkStreamingEqualizer   thrpt    2    416,658   ops/s
JMH_Audio.benchmarkFastFFT              thrpt    2    182,448   ops/s
JMH_Audio.benchmarkPitchDetection       thrpt    2     48,836   ops/s
JMH_Audio.benchmarkSpectralDenoise      thrpt    2      8,189   ops/s

Sub-Microsecond Latency: Acoustic features execute at 1.6M+ operations/sec, native AVX2 pitch tracking delivers 48,800+ detections/sec, and native FastFFT transforms run at 180,000+ transforms/sec with zero runtime GC allocations.


API Quick Reference

Class / Method Description Path
FastAudioMixer Multi-track timeline mixer with constant-power panning and soft limiter. Reference
suppressNoise(samples, rate, factor, floor) Real-time spectral power subtraction noise filter. Reference
pitchShift(input, semitones, rate) High-fidelity, echo-free musical pitch shifting. Reference
timeStretchWSOLA(input, speedRatio, rate) Pitch-invariant time-scale modification (WSOLA). Reference
applyVolumeGain(pcmData, volumeMultiplier) Soft-knee limiter volume boost up to 300%. Reference
detectPitchNative(samples, rate) AVX2 SIMD pitch detection using autocorrelation. Reference
computeCrestFactor(samples) Spectral Crest Factor (Peak / RMS) transient spike detector. Reference
computeZeroCrossingRate(samples) Normalized Zero-Crossing Rate (ZCR) sign-change ratio. Reference
computeAutocorrelationPeriodicity(samples, min, max) Normalized pitch harmonic periodicity ratio. Reference
FastAudioEqualizer Stateful 3-band streaming IIR equalizer. Reference
FastAudioChunker Lock-free SPSC power-of-two frame chunker. Reference
FastFFT Forward & inverse Radix-2 Fast Fourier Transform. Reference

Technical Demos & Benchmarks

Case Java Example Launcher Description
Interactive Showcase Demo Demo.java run-demo.bat End-to-end interactive demonstration of real-time audio filters, noise suppression, and pitch modulation.
JMH Microbenchmark Suite Benchmark.java run-benchmark.bat Formal OpenJDK JMH throughput measurements across native DSP audio kernels.

Installation

Option 1: Maven (Recommended via JitPack)

Add the JitPack repository and the complete dependency stack to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <!-- FastAudioProcess Engine -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastAudioProcess</artifactId>
        <version>0.1.7</version>
    </dependency>

    <!-- FastSIMD Hardware Vector Acceleration Engine -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastSIMD</artifactId>
        <version>0.1.3</version>
    </dependency>

    <!-- FastCore Native Loader -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastCore</artifactId>
        <version>0.1.0</version>
    </dependency>
</dependencies>

Option 2: Gradle (via JitPack)

Add the repository and dependencies to your build.gradle:

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:FastAudioProcess:0.1.7'
    implementation 'com.github.andrestubbe:FastSIMD:0.1.3'
    implementation 'com.github.andrestubbe:FastCore:0.1.0'
}

Option 3: Direct Download (Pre-built JAR)

Download the latest JAR directly to add it to your classpath:


Documentation

  • REFERENCE.md: Exhaustive catalog of DSP algorithms, FFT kernels, timeline mixing, and acoustics architecture.
  • CHANGELOG.md: Complete chronological record of version releases and performance improvements.
  • PHILOSOPHY.md: Zero-allocation, native-first, and low-overhead real-time DSP design principles.
  • COMPILE.md: Full compilation guide (MSVC Native AVX2 & Maven Build Setup).
  • ROADMAP.md: Planned milestone features, ARM NEON SIMD, and GPU compute extensions.

Platform Support

Platform Architecture Status Vector ISA
Windows 10 / 11 x64 (AMD64) โœ… Fully Supported AVX2 / FMA3
Windows Server 2019+ x64 โœ… Fully Supported AVX2
Linux (Ubuntu/Debian) x64 / ARM64 ๐Ÿšง Planned AVX2 / NEON
macOS (Apple Silicon) ARM64 ๐Ÿšง Planned NEON

Related Projects

  • FastVoice โ€” Zero-shot AI voice cloning and speech-to-speech conversion
  • FastAudioCapture โ€” Zero-copy WASAPI audio loopback & microphone capture
  • FastAudioPlayer โ€” Ultra low-latency WASAPI and DirectSound audio playback engine
  • FastVAD โ€” Ultra-fast real-time Voice Activity Detection (Silero-ONNX & WebRTC)
  • FastTTS โ€” Unified, zero-bloat text-to-speech backend orchestration
  • FastSTT โ€” High-throughput local speech-to-text recognition
  • FastCore โ€” Native library loader, FFM gateway, and platform abstraction
  • FastSIMD โ€” Hardware SIMD acceleration substrate

License

MIT License โ€” See LICENSE for details.
Part of the FastJava Ecosystem.

About

๐ŸŽ›๏ธ Hardware SIMD-accelerated real-time audio pitch detection, SOLA pitch shifting, and zero-allocation DSP filters for Java audio applications.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages