Skip to main content

Module convert

Module convert 

Source
Expand description

What the device delivers, turned into the mono model-rate signal.

Re-exportsΒ§

use rubato::Resampler as _; πŸ”’
use rubato::audioadapter_buffers::direct::SequentialSliceOfSlices; πŸ”’
use rubato::audioadapter_buffers::direct::SequentialSliceOfVecs; πŸ”’
use crate::Error; πŸ”’
use crate::SAMPLE_RATE; πŸ”’

StructsΒ§

InputConverter πŸ”’
Turns what the device delivers into the mono SAMPLE_RATE signal everything downstream reads. Pass-through when the device natively offers the model rate; otherwise downmix to mono, then resample with a windowed-sinc filter. Decimating without the filter would fold everything above the new Nyquist into the speech band as confident wrong words.
Resampling πŸ”’

ConstantsΒ§

RESAMPLE_CHUNK πŸ”’
Resampler input per call, in device frames. 10 ms at 48 kHz; any block size the device delivers is staged up to it.

FunctionsΒ§

channel_mean πŸ”’
Mean of one interleaved frame, so every channel contributes. Discarding a capsule silently halves the signal on hardware where the speaker sits nearer one of them.
raw_peak πŸ”’
The loudest absolute sample of a raw block, before any downmix: a meter should show a channel clipping even where the mono mix halves it.
resample_mono
A buffer of mono audio at from, converted to to with the input path’s own filter. The same rate hands the buffer straight back.
sinc_parameters πŸ”’
The windowed-sinc filter both resampling paths use: f_cutoff is relative to the lower of the two Nyquists, so speech below it passes and everything that would alias is in the stopband.