C# resample audio from 8khz to 44.1/48khz

折月煮酒 提交于 2019-12-31 03:30:12

问题


I have encountered a bug in DirectShow .NET where I create a secondary buffer with a sample rate of 8khz, and upon playback, the sound plays back at approx. 8.1khz instead.

Googling this, I discovered that I might be forced to upsample the 8khz audio myself to 48khz or 44.1khz depending on the soundcard in the PC.

Is there any C# library or generic algorithm I could use for this?

Thanks!!

Roey


回答1:


For Alvas.Audio see code below

byte[] data48khz = AudioCompressionManager.Convert(format8khz, format48khz, data8khz, false);




回答2:


You could always port Secret Rabbit Code to C#?

Or how about using the Audio Compression Manager directly via platform invoke?




回答3:


Your issues of "sounds being played back too fast" may be soundcard specific. Not sure which OS you are on, but I believe Windows natively upsamples all audio streams to either 44 or 48khz before directing the samples to the soundcard (so it can properly mix it with all the other streams). So I'm not sure if you upsample with your own code if you'll get any improvements.

Have you tried using a different PC (running a different OS) or plugging in some USB headphones to see if this issue is consistent?



来源:https://stackoverflow.com/questions/3194184/c-sharp-resample-audio-from-8khz-to-44-1-48khz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!