iPhone SDK:在不同级别平移音频
我试图控制播放音频文件的通道(左/右)及其音量。如果有人可以解释如何做到这一点或向我指出一些解释这一点的文档或教程,那就太好了。
I am trying to control the channel (left/right) and its volume from which the audio file is played. It will be great if someone can explain how this can be done or point me to some document or tutorial which explains this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果源音频是单声道的,则平移是通过降低左声道或右声道之一的音量来完成的,因此在中心,它们都处于 100%,并且当您向左或右平移时,其中一个声道会逐渐降低。
如果您的源音频是立体声的,则称为“平衡”,其操作方式与平移相同,只不过两个通道保持独立,而不是将一个通道同时放入左右两侧。
可以通过将每个样本乘以一个百分比来控制音量。
但这是在您在样本级别读取和混合音频的情况下。如果您使用的是更高级别的 API 之一,通常会有一个混音器单元或混音器控件,您可以在其中设置值,它会自动完成所有操作。
以下是有关 Core Audio 的更多底层文档:
http://developer.apple.com/Mac/library/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/AQuickTouroftheCoreAudioSDK/AQuickTouroftheCoreAudioSDK.html
If your source audio is monophonic, panning is done by reducing the volume in one of the left or right channels, so at center, they're both at 100%, and one channel is ramped down as you pan left or right.
If your source audio is stereophonic, then it's called "balance" and that's done the same way as panning, except that the two channels are kept separate instead of one channel being put into both left and right.
Volume can be controlled by multiplying each sample by a percentage.
But that's if you're reading and mixing audio at the sample level. If you're using one of the higher-level APIs there's usually a mixer unit or mixer controls where you set values for it and it does all that automatically.
Here's more low-level documentation on Core Audio:
http://developer.apple.com/Mac/library/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/AQuickTouroftheCoreAudioSDK/AQuickTouroftheCoreAudioSDK.html