将 IeeeFloat 缓冲区中的音频数据转换为缓冲区中的 PCM [英] Convert Audio data in IeeeFloat buffer to PCM in buffer

查看:147
本文介绍了将 IeeeFloat 缓冲区中的音频数据转换为缓冲区中的 PCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 NAudio 来捕获声音输入,输入显示为包含 IeeeFloat 格式的声音信息的缓冲区.

I use NAudio to capture sound input and the input appears as a buffer containing the sound information in IeeeFloat format.

既然我在缓冲区中有这些数据,我想以不同的采样率将其转换为 PCM.

Now that I have this data in the buffer, I want to translate it to PCM at a different sampling rate.

我已经想出了如何从 IeeeFloat 转换为 PCM,以及如何在单声道和立体声之间进行转换.转换采样率是一项艰巨的任务.

I have already figured out how to convert from IeeeFloat to PCM, and also convert between mono and stereo. Converting the sampling rate is the tough one.

任何解决方案,最好使用 NAudio,可以将 IeeeFLoat 缓冲区转换为具有所选 PCM 格式的缓冲区(包括更改采样率)?

Any solution, preferable using NAudio, that can convert the IeeeFLoat buffer to a buffer with PCM format of choice (including changing sampling rate)?

推荐答案

如果您想在接收数据的同时重新采样,那么您需要执行输入驱动的重新采样.不久前我写了一篇关于此的文章.

If you want to resample while you receive data, then you need to perform input driven resampling. I wrote an article on this a while ago.

NAudio 有一些从单声道到立体声,从浮动到 PCM 的辅助类,但它们倾向于对 IWaveProviderISampleProvider 输入进行操作.通常,如果我只是将样本作为原始字节块,我会通过自己的简单代码编写从浮点数到 PCM 并将样本加倍.这并不难,WaveBuffer 类将允许您直接从 byte[] 读取浮点样本.

NAudio has some helper classes to go from mono to stereo, and float to PCM, but they tend to operate on IWaveProvider or ISampleProvider inputs. Typically if I just had the samples as a raw block of bytes I'd write by own simple code to go from float to PCM and double up the samples. It's not that hard to do and the WaveBuffer class will allow you to read float samples directly from a byte[].

这篇关于将 IeeeFloat 缓冲区中的音频数据转换为缓冲区中的 PCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆