本文介绍了将24位音频的样本转换为int32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 嘿伙计们, 我有点潜入音频。 我有一个故障但会播放的采样器。 今晚的焦点是我永远无法弄清楚为什么我在24 位样本中具有比16位更高的白噪声增益而具有显着更低的输出。 这些是针对2种费率转换的2个剪辑。 我成功地使用了waveout结构(我认为)。 I am diving back into audio a bit. I have a sampler that is glitch but will play. The focus tonight is that I never could figure out why I have a significant lower output with a higher gain of white noise in a 24 bit sample than a 16 bit. These are 2 snips of the bit converting for the 2 rates. I am successfully using the waveout structures (I think).' 16 bit '' buffer array is the file written into an array ' Dim adjustBufferVolumesFinal() As Byte For i = 0 to Size Step 4 sample = BitConverter.ToInt16(BufferArray, i) sample2 = BitConverter.ToInt16(BufferArray, i + 2) sampleVolume = BitConverter.GetBytes(sample) sampleVolume2 = BitConverter.GetBytes(sample2) adjustBufferVolumes(B)= sampleVolume(0) adjustBufferVolumes(B + 1)= sampleVolume(1) adjustBufferVolumes(B + 2)= sampleVolume2(0) adjustBufferVolumes(B + 3)= sampleVolume2(1) B + = 4 下一个 '2 4位''bufferarray是写入数组的整个文件' sampleVolume = BitConverter.GetBytes(sample) sampleVolume2 = BitConverter.GetBytes(sample2) adjustBufferVolumes(B) = sampleVolume(0) adjustBufferVolumes(B + 1) = sampleVolume(1) adjustBufferVolumes(B + 2) = sampleVolume2(0) adjustBufferVolumes(B + 3) = sampleVolume2(1) B += 4 Next' 24 bit '' bufferarray is the entire file that is written to an array ' For i = 0到大小步骤6 samplew =(BitConverter.ToInt32(New Byte(){0,BufferArray(i + 2),BufferArray(i + 1),BufferArray(i )},0)>> 8) sample2w =(BitConverter.ToInt32(New Byte(){0,BufferArray(i + 5),BufferArray(i + 4),BufferArray(i + 3)},0)>> 8) sampleVolume = BitConverter.GetBytes(samplew<< 8) sampleVolume2 = BitConverter.GetBytes(sample2w<< 8) adjustBufferVolumes(B)= sampleVolume(1) adjustBufferVolumes(B + 1)= sampleVolume(2) adjustBufferVolumes(B + 2)= sampleVolume(3) adjustBufferVolumes(B + 3)= sampleVolume2(1) adjustBufferVolumes(B + 4)= sampleVolume2(2) adjustBufferVolumes(B + 5)= sampleVolume2(3) B + = 6 下一个 adjustBufferVolumesFinal = adjustBufferVolumes For i = 0 to Size Step 6 samplew = (BitConverter.ToInt32(New Byte() {0, BufferArray(i + 2), BufferArray(i + 1), BufferArray(i)}, 0) >> 8) sample2w = (BitConverter.ToInt32(New Byte() {0, BufferArray(i + 5), BufferArray(i + 4), BufferArray(i + 3)}, 0) >> 8) sampleVolume = BitConverter.GetBytes(samplew << 8) sampleVolume2 = BitConverter.GetBytes(sample2w << 8) adjustBufferVolumes(B) = sampleVolume(1) adjustBufferVolumes(B + 1) = sampleVolume(2) adjustBufferVolumes(B + 2) = sampleVolume(3) adjustBufferVolumes(B + 3) = sampleVolume2(1) adjustBufferVolumes(B + 4) = sampleVolume2(2) adjustBufferVolumes(B + 5) = sampleVolume2(3) B += 6 NextadjustBufferVolumesFinal = adjustBufferVolumes它适用于24位。 但是,产生的噪音是不正确的,输出的音量也是不正确的(太低)It works at 24 bit. But, the noise generated is incorrect and the volume of the output is incorrect, too (too low)推荐答案 在第二种情况下,您可能应该更改订单:samplew = (BitConverter.ToInt32(New Byte() {0, BufferArray(i), BufferArray(i + 1), BufferArray(i + 2)}, 0) >> 8)sample2w = (BitConverter.ToInt32(New Byte() {0, BufferArray(i + 3), BufferArray(i + 4), BufferArray(i + 5)}, 0) >> 8) 但现在它只是从 BufferArray 复制到 adjustBufferVolumes 。如果您想要特定的转换,请提供详细信息。But now it simply copies from BufferArray to adjustBufferVolumes. If you want a specific transformation, then give details. 这篇关于将24位音频的样本转换为int32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-29 09:19