| Crates.io | ssstretch |
| lib.rs | ssstretch |
| version | 0.1.0 |
| created_at | 2025-03-01 19:32:39.869239+00 |
| updated_at | 2025-03-01 19:32:39.869239+00 |
| description | Rust bindings for the Signalsmith Stretch time-stretching and pitch-shifting library |
| homepage | |
| repository | https://github.com/bmisiak/ssstretch |
| max_upload_size | |
| id | 1573957 |
| size | 906,987 |
This crate provides Rust bindings for the Signalsmith Stretch time-stretching and pitch-shifting library.
use ssstretch::Stretch;
// Create and configure a stretcher instance
let mut stretch = Stretch::new();
stretch.preset_default(2, 44100.0); // 2 channels, 44.1kHz sample rate
// Optional: Set pitch shift (in semitones)
stretch.set_transpose_semitones(3.0, None); // Shift up by 3 semitones
// Process audio with time stretching
// Here we're creating output that's 1.5x longer than input (slower)
let output_len = (input_len as f32 * 1.5) as usize;
let mut output = vec![vec![0.0f32; output_len]; channels];
stretch.process_vec(
&input, // Input audio (array of channels)
input_len, // Input length in samples
&mut output, // Output buffer
output_len, // Output length in samples
);
This crate uses the cxx crate to provide safe Rust bindings to the C++ library. The C++ template class SignalsmithStretch<float> is wrapped with a type alias and exposed through the cxx FFI boundary.
The library requires a C++ compiler that supports C++14 or newer.
cargo build
See the examples/ directory for sample code demonstrating how to use the library.
This crate is available under the MIT License, see LICENSE for details.