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

前端 未结 3 1664
时光说笑
时光说笑 2021-01-22 17:58

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.

相关标签:
3条回答
  • 2021-01-22 18:06

    You could always port Secret Rabbit Code to C#?

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

    0 讨论(0)
  • 2021-01-22 18:08

    For Alvas.Audio see code below

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

    0 讨论(0)
  • 2021-01-22 18:28

    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?

    0 讨论(0)
提交回复
热议问题