我正在使用 Aran Mulhollan 的 RemoteIOPlayer,在 SDK iphone 中使用音频队列。
我可以毫无问题:
- 添加两个信号来混合声音
- 通过乘以从 wav 文件中获得的 UInt32 来增加音量
,但是所有其他操作都会使声音扭曲和扭曲,特别是我无法分割信号。我似乎无法弄清楚我做错了什么,除法的实际结果似乎不错;声音/信号处理的某些方面显然一定是在逃避我:)
任何帮助表示赞赏!
I'm using Aran Mulhollan' RemoteIOPlayer, using audioqueues in the SDK iphone.
I can without problems:
- adding two signals to mix sounds
- increasing sound volume by multiplying the UInt32 I get from the wav files
BUT every other operation gives me warped and distorted sound, and in particular I can't divide the signal. I can't seem to figure out what I'm doing wrong, the actual result of the division seems fine; some aspect of sound / signal processing must obviously be eluding me :)
Any help appreciated !
发布评论
评论(3)
你尝试过这样的事情吗?
Have you tried something like this?
首先,您提到的代码不使用 AudioQueues,而是使用 AudioUnits。在 iPhone 中混合音频的最佳方法是使用内置的混音器单元,您从 此处。除此之外,我会在您的代码操作系统中检查您是否具有正确的数据类型。当您应该使用有符号整数时,您是否正在尝试对无符号整数进行操作?通常会产生扭曲的结果(可以理解)
First of all the code you mention does not use AudioQueues, it uses AudioUnits. The best way to mix audio in the iphone is using the mixer units that are inbuilt, there is some code on the site you downloaded your original example from here. Other than that what i would check in your code os that you have the correct data type. Are you trying your operations on Unsigned ints when you should be using signed ones? often that produces warped results (understandably)
iPhone 将音频作为 16 位整数处理。大多数音频文件已经标准化,因此峰值样本值是适合 16 位有符号整数的最大值。这意味着如果将两个这样的样本添加在一起,就会出现溢出,或者在这种情况下,会出现音频剪辑。如果要将两个音频源混合在一起并确保没有削波,则必须对样本进行平均:将它们加在一起并除以二。或者您将音量设置为一半。如果您使用分贝,则变化约为 -6 dB。
The iPhone handles audio as 16-bit integer. Most audio files are already normalized so that the peak sample values are the maximum that fit in a 16-bit signed integer. That means if you add two such samples together, you get overflow, or in this case, audio clipping. If you want to mix two audio sources together and ensure there's no clipping, you must average the samples: add them together and divide by two. Or you set the volume to half. If you're using decibels, that would be about a -6 dB change.