#resampling audio question

6 messages · Page 1 of 1 (latest)

celest olive
#

does anyone know much about audio, im using cpal to gather bytes of microphone data to then use opus to get bytes to send over network for voip
however if i resample the audio from 48khz to 16khz i get intelligible audio, very high pitched
48khz to 24khz works fine i think
bypassing opus creates same effect so it seems im resampling incorrectly
https://github.com/bgkillas/bevy_microphone/blob/master/src/lib.rs#L195 i have a loopback as an example to help test
the framesize structs math is to target time at 48khz, not actual frame size, so 480 would mean 10ms at 48khz, and the 480 value would then scale down to 160 if we have sample rate at 16khz, so i think that math is fine

GitHub

Contribute to bgkillas/bevy_microphone development by creating an account on GitHub.

#

i also am not aiming to support stereo input atm

#

want to fix this first

#

i thought i had this working in my other game but maybe i broke it while extracting code and updating dependencies

cedar tangle
#

with the caveat that i'm passing on a recommendation, and not actually very experienced with audio stuff: ive had fixed-resample recommended to me when playing with microphone stuff, which uses rubato to do its resampling

GitHub

An asyncronous resampling library written in Rust. Contribute to HEnquist/rubato development by creating an account on GitHub.

#

so they may be worth taking a look at, either to see how the resampled audio sausage gets made, or just as libraries that solve your problem