32位波形转换为16位波形 [英] Converting a 32 bit wave form to a 16 bit wave form

查看:752
本文介绍了32位波形转换为16位波形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用环回捕获模式捕获音频。捕获的波形是一个32位的波形。我与这个转换为16位的波形,从而连接codeRS像跛能对付它挣扎(它说不支持的数据格式:为0x0003)。

I've been capturing audio using the loopback capture mode. The captured waveform is a 32 bit waveform. I'm struggling with converting this to a 16 bit waveform so encoders like lame can deal with it (it says Unsupported data format: 0x0003).

我试过在波移位位(而不是我的强项)从32位到16位流本身,但结果还是声音失真。

I've tried shifting the bits (not my strong point) in the wave stream itself from 32 bit to 16 bit but the result still sounds distorted.

该Wave32To16Stream类似乎炸毁在这种情况下:
            如果(!sourceStream.WaveFor​​mat.Encoding = WaveFor​​matEncoding.IeeeFloat)抛出新ApplicationException的(只有32位支持浮点);

The Wave32To16Stream class seems to blow up on this case: if (sourceStream.WaveFormat.Encoding != WaveFormatEncoding.IeeeFloat) throw new ApplicationException("Only 32 bit Floating point supported");

理想我想只是直捕捉到16位,是有没有办法设置捕获位深?如果没有,能有人帮我转换的WaveStream?

Ideally I would want to just capture straight to 16 bit, is there no way to set the capture bit depth? If not, could somebody help me with converting the wavestream?

一个捕获的波形的一个例子可以在这里找到: HTTP://dl.dropbox .COM / U / 454409 / test.wav (10MB)

An example of a captured waveform can be found here: http://dl.dropbox.com/u/454409/test.wav (10mb)

我也想用站不住脚的满足于某种方式连接code此为MP3,我已经试过每一个参数的排列我能想到的得到它接受波形文件。有趣的是无畏(使用lame_enc为en code的mp3),能够从波形创建MP3(但也许无畏自动将它传递它跛脚前16位)。

I would also settle for some way to encode this to mp3 with lame, I've tried every parameter permutation I can think of to get it to accept the wave file. What's interesting is Audacity (which uses lame_enc to encode mp3s) was able to create an mp3 from the waveform (but maybe Audacity automatically converts it to 16bit before passing it to lame).

推荐答案

格式为0x0003其实ieeeFloat,你不应该得到这个例外。更好地检查它读取的值。您不能转换与位移值,你必须从float转换为短。一个简单的铸件能够完成任务。

Format 0x0003 is in fact ieeeFloat, you shouldn't get this exception. Better check the value it read. You cannot convert the values with bit shifting, you have to convert from float to short. A simple cast gets the job done.

这篇关于32位波形转换为16位波形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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