1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//!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](https://codeberg.org/soundtouch/soundtouch).
//!## High Level Example
//!```rust
//!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
//!```rust
//!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.
//!
//!## Features
//!This create is `no_std` but does provide the [`generate_audio`] utility function, which requires the `alloc` feature (enabled by default).
//!
//!To run in a completely `no_std` environment, disable the default features.
//!
//!- `alloc` (enabled by default): Enables the use of the [`generate_audio`] function.
//!
//![`generate_audio`]: SoundTouch::generate_audio
pub use *;
pub use *;