@@ -32,10 +32,10 @@ where
3232 /// Construct a new `Converter` from the source frames and the source and target sample rates
3333 /// (in Hz).
3434 ///
35- /// This method calls ` interpolator.set_hz_to_hz(source_hz, target_hz)` internally .
35+ /// Configures the interpolator's bandwidth for anti-aliasing when downsampling .
3636 #[ inline]
3737 pub fn from_hz_to_hz ( source : S , mut interpolator : I , source_hz : f64 , target_hz : f64 ) -> Self {
38- interpolator. set_hz_to_hz ( source_hz , target_hz) ;
38+ interpolator. set_bandwidth ( target_hz / source_hz ) ;
3939 Self :: scale_playback_hz ( source, interpolator, source_hz / target_hz)
4040 }
4141
@@ -75,33 +75,27 @@ where
7575 /// Update the `source_to_target_ratio` internally given the source and target hz.
7676 ///
7777 /// This method might be useful for changing the sample rate during playback.
78- ///
79- /// This method calls `interpolator.set_hz_to_hz(source_hz, target_hz)` internally.
8078 #[ inline]
8179 pub fn set_hz_to_hz ( & mut self , source_hz : f64 , target_hz : f64 ) {
82- self . interpolator . set_hz_to_hz ( source_hz , target_hz) ;
80+ self . interpolator . set_bandwidth ( target_hz / source_hz ) ;
8381 self . set_playback_hz_scale ( source_hz / target_hz)
8482 }
8583
8684 /// Update the `source_to_target_ratio` internally given a new **playback rate** multiplier.
8785 ///
8886 /// This method is useful for dynamically changing rates.
89- ///
90- /// This method calls `interpolator.set_playback_hz_scale(scale)` internally.
9187 #[ inline]
9288 pub fn set_playback_hz_scale ( & mut self , scale : f64 ) {
93- self . interpolator . set_playback_hz_scale ( scale) ;
89+ self . interpolator . set_bandwidth ( 1.0 / scale) ;
9490 self . source_to_target_ratio = scale;
9591 }
9692
9793 /// Update the `source_to_target_ratio` internally given a new **sample rate** multiplier.
9894 ///
9995 /// This method is useful for dynamically changing rates.
100- ///
101- /// This method calls `interpolator.set_sample_hz_scale(scale)` internally.
10296 #[ inline]
10397 pub fn set_sample_hz_scale ( & mut self , scale : f64 ) {
104- self . interpolator . set_sample_hz_scale ( scale) ;
98+ self . interpolator . set_bandwidth ( scale) ;
10599 self . set_playback_hz_scale ( 1.0 / scale) ;
106100 }
107101
0 commit comments