持续噪音的iOS音频单元播放 [英] iOS Audio Unit playback with constant noise

查看:225
本文介绍了持续噪音的iOS音频单元播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用音频单元进行音频播放。我已经从 http://cocoawithlove.com/下载了音源。 2010/10 / ios-tone-generator-introduction-to.html 并尝试使用它。由于某些原因,我需要使用ulaw而不是线性PCM。这是我的音频格式设置:

I am using audio unit for audio playback. I have download the tone generator from http://cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html and try to play around with it. For some reason I need to use ulaw instead of linear PCM. Here is my audio format setup:

AudioStreamBasicDescription streamFormat;
streamFormat.mSampleRate = 8000;
streamFormat.mFormatID = kAudioFormatULaw;
streamFormat.mFormatFlags = 0;
streamFormat.mFramesPerPacket = 1;
streamFormat.mBytesPerFrame = 2;
streamFormat.mBytesPerPacket = streamFormat.mBytesPerFrame;
streamFormat.mChannelsPerFrame = 1;
streamFormat.mBitsPerChannel = 16;

在运行示例代码时,我会不断听到杂音。有谁可以帮助解决这个问题?非常感谢。

When I run the sample code, I get a constant noise. Does anyone could help on this issue? Thanks a lot.

推荐答案

使用音频单元只能使用linearPCM格式。甚至kAudioUnitType_FormatConverter都提供线性PCM格式之间的转换(具有不同的采样率,bytesPerPacket等)。要从压缩格式转换,应使用AudioConverter。

You can use only linearPCM format using Audio Units. Even kAudioUnitType_FormatConverter provides conversions betwean linearPCM formats (with different sample rate, bytesPerPacket, etc). To convert from compressed format you should use AudioConverter.

https://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/AudioConverterServicesReference/Reference/reference.html

这篇关于持续噪音的iOS音频单元播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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