Skip to content

Commit 4406cf0

Browse files
committed
Drop two redundant examples
process_all_f64 only differed from process_f64 by calling process_all_into_buffer, which is now shown by a doc example on the method itself. process_i16 duplicated process_f64 apart from wrapping the input in an integer byte adapter, which audioadapter documents. Removing it also drops the audioadapter-sample dev dependency.
1 parent 03950dc commit 4406cf0

4 files changed

Lines changed: 33 additions & 309 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ log = "0.4.18"
3939
approx = "0.5.1"
4040
test-log = "0.2.16"
4141
test-case = "3"
42-
audioadapter-sample = "5.1"
4342
waveadapter = "0.2"
4443
clap = { version = "4.6", features = ["derive"] }
4544

examples/process_all_f64.rs

Lines changed: 0 additions & 158 deletions
This file was deleted.

examples/process_i16.rs

Lines changed: 0 additions & 150 deletions
This file was deleted.

src/lib.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,39 @@ where
282282
/// [process_into_buffer](Resampler::process_into_buffer).
283283
///
284284
/// Returns the lengths of the original input and the resampled output.
285+
///
286+
/// # Example
287+
///
288+
/// Resample one second of 44.1 kHz audio to 48 kHz, into a buffer allocated
289+
/// up front. This is the variant to use when allocating during processing is
290+
/// not acceptable, such as in a realtime thread. See
291+
/// [process_all](Resampler::process_all) for the allocating counterpart.
292+
///
293+
/// ```
294+
/// use audioadapter_buffers::owned::InterleavedOwned;
295+
/// use rubato::{Fft, FixedSync, Resampler};
296+
///
297+
/// let channels = 2;
298+
/// let input_len = 44100;
299+
/// let input = InterleavedOwned::<f64>::new(0.0, channels, input_len);
300+
///
301+
/// let mut resampler =
302+
/// Fft::<f64>::new(44100, 48000, 1024, channels, FixedSync::Both).unwrap();
303+
///
304+
/// // Allocate an output buffer that is guaranteed to be big enough.
305+
/// let needed_len = resampler.process_all_needed_output_len(input_len);
306+
/// let mut output = InterleavedOwned::<f64>::new(0.0, channels, needed_len);
307+
///
308+
/// let (consumed, produced) = resampler
309+
/// .process_all_into_buffer(&input, &mut output, input_len, None)
310+
/// .unwrap();
311+
///
312+
/// // The resampled audio is the first `produced` frames of the buffer.
313+
/// // The rest is padding, since the buffer is sized for the worst case.
314+
/// assert_eq!(consumed, input_len);
315+
/// assert!(produced >= 48000);
316+
/// assert!(produced <= needed_len);
317+
/// ```
285318
fn process_all_into_buffer(
286319
&mut self,
287320
buffer_in: &dyn Adapter<T>,

0 commit comments

Comments
 (0)