@@ -101,6 +101,7 @@ fn match_device(
101
101
102
102
fn create_stream_settings (
103
103
pa : & portaudio:: PortAudio ,
104
+ processor : & Processor ,
104
105
opt : & Options ,
105
106
) -> Result < portaudio:: DuplexStreamSettings < f32 , f32 > , Error > {
106
107
let input_device = match_device ( pa, Regex :: new ( & opt. capture . device_name ) ?) ?;
@@ -127,7 +128,7 @@ fn create_stream_settings(
127
128
input_params,
128
129
output_params,
129
130
f64:: from ( AUDIO_SAMPLE_RATE ) ,
130
- NUM_SAMPLES_PER_FRAME as u32 ,
131
+ processor . num_samples_per_frame ( ) as u32 ,
131
132
) )
132
133
}
133
134
@@ -181,9 +182,9 @@ fn main() -> Result<(), Error> {
181
182
let pa = portaudio:: PortAudio :: new ( ) ?;
182
183
183
184
let mut processor = Processor :: new ( & InitializationConfig {
184
- num_capture_channels : opt. capture . num_channels as i32 ,
185
- num_render_channels : opt. render . num_channels as i32 ,
186
- .. Default :: default ( )
185
+ num_capture_channels : opt. capture . num_channels as usize ,
186
+ num_render_channels : opt. render . num_channels as usize ,
187
+ sample_rate_hz : AUDIO_SAMPLE_RATE ,
187
188
} ) ?;
188
189
189
190
processor. set_config ( opt. config . clone ( ) ) ;
@@ -208,13 +209,13 @@ fn main() -> Result<(), Error> {
208
209
let audio_callback = {
209
210
// Allocate buffers outside the performance-sensitive audio loop.
210
211
let mut input_mut =
211
- vec ! [ 0f32 ; NUM_SAMPLES_PER_FRAME as usize * opt. capture. num_channels as usize ] ;
212
+ vec ! [ 0f32 ; processor . num_samples_per_frame ( ) * opt. capture. num_channels as usize ] ;
212
213
213
214
let running = running. clone ( ) ;
214
215
let mute = opt. render . mute ;
215
216
let mut processor = processor. clone ( ) ;
216
217
move |portaudio:: DuplexStreamCallbackArgs { in_buffer, out_buffer, frames, .. } | {
217
- assert_eq ! ( frames, NUM_SAMPLES_PER_FRAME as usize ) ;
218
+ assert_eq ! ( frames, processor . num_samples_per_frame ( ) ) ;
218
219
219
220
let mut should_continue = true ;
220
221
@@ -263,7 +264,7 @@ fn main() -> Result<(), Error> {
263
264
}
264
265
} ;
265
266
266
- let stream_settings = create_stream_settings ( & pa, & opt) ?;
267
+ let stream_settings = create_stream_settings ( & pa, & processor , & opt) ?;
267
268
let mut stream = pa. open_non_blocking_stream ( stream_settings, audio_callback) ?;
268
269
stream. start ( ) ?;
269
270
0 commit comments