@@ -87,11 +87,15 @@ The resamplers allow specifying which side should have a fixed size.
8787 The input chunk size will vary depending on how many new samples the resampler needs to calculate the output.
8888 This is meant to be used for resampling data that will be sent to some target that requires fixed size chunks.
8989* ** Both input and output fixed** : Both input and output chunk sizes are fixed.
90- This is only available for the synchronous resampler.
90+ This mode is only available for the synchronous resampler.
9191 In this mode, the chunk size parameter is used as a hint,
9292 and the actual chunk sizes are calculated to fit the resampling ratio exactly.
9393 For example, a 44.1 kHz to 48 kHz resampler must use an input chunk size that is a multiple of 147,
9494 and an output chunk size that is a multiple of 160, in order to maintain the correct resampling ratio.
95+
96+ This mode avoids some internal buffering compared to fixed input or fixed output modes,
97+ and is therefore somewhat more efficient.
98+
9599 For asynchronous resamplers, fixing both input and output chunk sizes is not possible
96100 since the resampling ratio can change, requiring at least one side to be variable.
97101
@@ -130,8 +134,11 @@ The resampler trait provides the `Resampler::process_all_into_buffer()` method
130134for resampling a full audio clip of arbitrary length.
131135To use this, create a resampler of suitable type, for example ` Fft ` which is fast and gives good quality.
132136The chunk size can be chosen arbitrarily. Start with a chunk size of for example 1024.
133- Then call ` Resampler::process_all_needed_output_len() ` to find out the length of the result.
134- Create an output buffer, and call ` Resampler::process_all_into_buffer() ` .
137+ In this application, the exact input or output chunk sizes are not important
138+ and therefore the ` FixedSync::Both ` setting can be used for the ` Fft ` resampler.
139+ After creating the resampler, call ` Resampler::process_all_needed_output_len() `
140+ to find out the minimum length of the needed output buffer.
141+ Create a suitable output buffer, and then call ` Resampler::process_all_into_buffer() ` .
135142
136143If there is more than one clip to resample from and to the same sample rates,
137144the same resampler should be reused.
@@ -232,27 +239,11 @@ Resample a dummy audio file from 44100 to 48000 Hz.
232239See also the "process_f64" example that can be used to process a file from disk.
233240``` rust
234241use rubato :: {
235- Resampler , Async , FixedAsync , Indexing ,
236- SincInterpolationType , SincInterpolationParameters ,
237- WindowFunction
242+ Resampler , Fft , FixedSync , Indexing
238243};
239244use audioadapter_buffers :: direct :: InterleavedSlice ;
240245
241- let params = SincInterpolationParameters {
242- sinc_len : 256 ,
243- f_cutoff : 0.95 ,
244- interpolation : SincInterpolationType :: Linear ,
245- oversampling_factor : 256 ,
246- window : WindowFunction :: BlackmanHarris2 ,
247- };
248- let mut resampler = Async :: <f64 >:: new_sinc (
249- 48000 as f64 / 44100 as f64 ,
250- 2.0 ,
251- & params ,
252- 1024 ,
253- 2 ,
254- FixedAsync :: Input ,
255- ). unwrap ();
246+ let mut resampler = Fft :: <f64 >:: new (48000 , 44100 , 1024 , 2 , 2 , FixedSync :: Both ). unwrap ();
256247
257248// create a short dummy audio clip, assuming it's stereo stored as interleaved f64 values
258249let audio_clip = vec! [0.0 ; 2 * 10000 ];
@@ -322,6 +313,8 @@ Many audio editors, for example Audacity, are also able to directly import and e
322313The ` rubato ` crate requires rustc version 1.74 or newer.
323314
324315## Changelog
316+ - v1.0.1
317+ - Fix calculation in process_all_needed_output_len method.
325318- v1.0.0
326319 - New API using the AudioAdapter crate to handle different buffer layouts and sample formats.
327320 - Merged the FixedIn, FixedOut and FixedInOut resamplers into single types that supports all modes.
0 commit comments