#latency #oboe #buffering #android #audio

aloe-oboe-latencytuner

Aloe Oboe Latency Tuner is a Rust crate for dynamically adjusting the latency of audio streams using Oboe on Android, optimizing for low-latency scenarios with state management and buffer size adjustments. This crate is a translation of the c++ juce module serving the same function.

1 unstable release

Uses new Rust 2024

new 0.1.2 Apr 3, 2025

#7 in #oboe


Used in 2 crates

GPL-3.0 license

100KB
614 lines

aloe-oboe-latencytuner

Aloe Oboe Latency Tuner is a Rust crate designed for dynamically adjusting the latency of an output audio stream that uses Oboe, an audio library for Android. It optimizes audio latency by modifying the stream's buffer size, based on observed underruns, within the constraints of application-level buffering.

Features

  • Dynamic Latency Management: Automatically adjusts buffer size to optimize for low latency while maintaining audio quality.
  • State Management: Monitors and operates in different states such as Idle, Active, AtMax, and Unsupported.
  • Compatibility: Specifically designed for streams utilizing AAudio, with operations such as tune(), reset(), and state inquiries.

Usage

To utilize OboeLatencyTuner, instantiate it with your mutable OboeAAudioStream instance. Invoke the tune() method right before your data callback returns, if using callbacks, or before write() when using blocking writes.

Example:

let mut my_stream: OboeAAudioStream = ...;
let mut tuner = OboeLatencyTuner::from(&mut my_stream);
tuner.set_minimum_buffer_size(256);
tuner.set_buffer_size_increment(128);

// Use in audio processing loop
loop {
    // audio processing occurs here
    
    let result = tuner.tune();
    match result {
        OboeResult::OK => println!("Tuning successful."),
        OboeResult::ErrorUnimplemented => println!("Tuning not supported."),
        _ => println!("Tuning error encountered.")
    }
}

Note:

This README.md was generated by an AI model and might not be completely accurate, but it should provide a solid foundation for understanding how to use this crate.

Contributions

Contributions are welcome through GitHub at https://github.com/klebs6/aloe-rs.

This crate is a translation of the JUCE module.

JUCE is a c++ software framework for developing high performance audio applications.

Usage falls under the GPLv3 as well as the JUCE commercial license.

See github.com/juce-framework/JUCE and the JUCE license page for details.

This crate is in the process of being translated from c++ to rust. For progress updates, please see the workspacer rust project. designed specifically for rust projects.

Dependencies

~39MB
~626K SLoC