Crates.io | soundtouch |
lib.rs | soundtouch |
version | 0.4.2 |
source | src |
created_at | 2023-10-15 03:26:28.19681 |
updated_at | 2024-08-31 06:27:29.263264 |
description | A utility wrapper around the SoundTouch C++ audio library |
homepage | |
repository | https://github.com/Cyanistic/soundtouch |
max_upload_size | |
id | 1003444 |
size | 582,670 |
A safe utility wrapper around the SoundTouch C++ audio library. The API is very similar to the original C++ API.
Most of the documentation is copied from the SoundTouch repository.
use soundtouch::{SoundTouch, Setting};
let mut soundtouch = SoundTouch::new();
soundtouch
.set_channels(2)
.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 * 2];
let output_samples = soundtouch.generate_audio(&samples);
// do something with output_samples
use soundtouch::{SoundTouch, Setting};
let mut soundtouch = SoundTouch::new();
soundtouch
.set_channels(2)
.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 * 2];
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() / 2);
let mut n_samples = 1;
while n_samples != 0 {
n_samples = soundtouch.receive_samples(
new_samples.as_mut_slice(),
BUF_SIZE / 2
);
output_samples.extend_from_slice(&new_samples);
}
soundtouch.flush();
// do something with output_samples
Both examples should produce the same output.