#audio-processing #music #audio-library

no-std soundtouch

A utility wrapper around the SoundTouch C++ audio library

12 releases

0.5.4 Mar 23, 2026
0.5.1 Aug 6, 2025
0.5.0 May 11, 2025
0.4.2 Aug 31, 2024
0.4.0 Oct 20, 2023

#599 in Audio

Download history 9/week @ 2025-12-28 23/week @ 2026-01-04 62/week @ 2026-01-11 143/week @ 2026-01-18 72/week @ 2026-01-25 20/week @ 2026-02-01 17/week @ 2026-02-08 30/week @ 2026-02-15 53/week @ 2026-02-22 113/week @ 2026-03-01 94/week @ 2026-03-08 37/week @ 2026-03-15 48/week @ 2026-03-22 74/week @ 2026-03-29 100/week @ 2026-04-05 87/week @ 2026-04-12

311 downloads per month
Used in 2 crates (via termusic-playback)

LGPL-2.1

335KB
251 lines

soundtouch

Crates.io Documentation

A safe utility wrapper around the SoundTouch C++ audio library. The API is very similar to the original C++ API. For dynamic and static linking configuration see soundtouch-ffi's linking behavior.

Most of the documentation is copied from the SoundTouch repository.

High Level Example

use soundtouch::{SoundTouch, Setting};

const CHANNELS: usize = 2;

let mut soundtouch = SoundTouch::new();
soundtouch
    .set_channels(CHANNELS as u32)
    .set_sample_rate(44100)
    .set_tempo(1.10)
    // Recommended setting to speed up processing
    .set_setting(Setting::UseQuickseek, 1);

// use actual audio samples here
let samples = vec![0.0; 44100 * CHANNELS];
let output_samples = soundtouch.generate_audio(&samples);

// do something with output_samples

Low Level Example

use soundtouch::{SoundTouch, Setting};

const CHANNELS: usize = 2;

let mut soundtouch = SoundTouch::new();
soundtouch
    .set_channels(CHANNELS as u32)
    .set_sample_rate(44100)
    .set_tempo(1.10)    
    // Recommended setting to speed up processing
    .set_setting(Setting::UseQuickseek, 1);

// use actual audio samples here
let mut samples = vec![0.0; 44100 * CHANNELS];

const BUF_SIZE: usize = 6720;
let mut new_samples: [f32; BUF_SIZE] = [0.0; BUF_SIZE];
let mut output_samples: Vec<f32> = Vec::with_capacity(samples.len());
soundtouch.put_samples(&samples, samples.len() / CHANNELS);
let mut n_samples = 1;
while n_samples != 0 {
    n_samples = soundtouch.receive_samples(
        new_samples.as_mut_slice(),
        BUF_SIZE / CHANNELS
        );
    output_samples.extend_from_slice(&new_samples[..n_samples * CHANNELS]);
}
soundtouch.flush();

// do something with output_samples

Both examples should produce the same output.

Dependencies

~1–3MB
~49K SLoC