AudioUnit 基本用法总结

本文介绍了iOS中使用AudioUnit进行音频处理的基本步骤,包括配置音频单元、启用输入输出、设定音频流描述以及设置回调函数。通过AudioComponentFindNext获取音频组件,AudioComponentInstanceNew创建实例,设置AudioUnitProperty_EnableIO以启用录音和播放功能,并通过AudioUnitSetProperty设置音频流格式。最后,定义了录音回调recordingCallback和播放回调playbackCallback用于处理音频数据。
摘要由CSDN通过智能技术生成
1、描述音频单元

AudioComponentDescription desc;
    desc.componentType = kAudioUnitType_Output;
    desc.componentSubType = kAudioUnitSubType_RemoteIO;
    desc.componentFlags = 0;
    desc.componentFlagsMask = 0;
    desc.componentManufacturer = kAudioUnitManufacturer_Apple;
2、查找音频单元

AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc);
3、获取音频单元实例
status = AudioComponentInstanceNew(inputComponent, &audioUnit);
4、启用录制功能、启用播放功能

UInt32 flag = 1;
    status = AudioUnitSetProperty(audioUnit,
                                  kAudioOutputUnitProperty_EnableIO,
                                  kAudioUnitScope_Input,
                                  kInputBus,
                                  &flag,
                                 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值