我的问题涉及AudioUnits.为了设计iPhone的语音交换应用程序(使用Objective-C xCode),我使用本网站的RemoteIO audioUnit示例:
http://atastypixel.com/blog/using-remoteio-audio-unit/
audioUnit缓冲区的长度设置为256个样本.对于我的项目,我需要更多(约22050).引用的页面说明audioUnit缓冲区的长度可以像这样调整:
float aBufferLength = 0.005; // In seconds
AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration,
sizeof(aBufferLength), &aBufferLength);
Run Code Online (Sandbox Code Playgroud)
现在我的具体问题:上面的代码不适合上面提到的audioUnit,因为没有使用AudioSession,从未初始化,因此产生错误.除了"kAudioSessionProperty_PreferredHardwareIOBufferDuration"之外,还有其他可能的调整缓冲区持续时间吗?在这种情况下,文档并不十分有用......提前感谢Lukas.
有没有办法让音频单元主机逐步执行插件的参数并获取以下信息:
AFAICT这个信息在插件中可用,但我无法弄清楚如何从主机端查询它.
我一直在网上寻找教授如何在应用程序中使用音频单元的东西,没有运气.我正在尝试创建一个允许用户动态应用AUTimePitch来播放音频文件的应用程序.但我在网上找不到任何东西来教一个初学者如何使用音频单元.
另外,我是为mac而不是iOS制作的
我在iOS上使用音频单元处理图形服务来创建一个音频单元的小图形来输出音频.我设置了一个渲染回调,并在调用回调时将音频数据输入到图形中.
这可以正常工作,直到我的音频会话中断(例如通过电话或闹钟); 此时回调停止,即使在中断结束后也不会再次调用.
我尝试在图表上再次调用AUGraphStart(),但这似乎没有帮助.有任何想法吗?
我在音频单元图中有一个AudioUnit Reverb,它可以很好地处理音频数据(扬声器中有很好的混响声).但我无法设置效果的参数.我能设置的唯一一个paraemter是DryWet设置.其他的未能修改.
以下是有效的:
AudioUnitSetParameter(reverbUnit,kAudioUnitScope_Global,0,kReverb2Param_DryWetMix,50,0);
Run Code Online (Sandbox Code Playgroud)
但不是这些:
AudioUnitSetParameter(reverbUnit,kAudioUnitScope_Global,0,kReverb2Param_DecayTimeAt0Hz,4.0,0); AudioUnitSetParameter(reverbUnit,kAudioUnitScope_Global,0,kReverb2Param_DecayTimeAtNyquist,4.0,0);
AudioUnitSetParameter(reverbUnit,kAudioUnitScope_Global,0,kReverb2Param_Gain,3.0,0);
AudioUnitSetParameter(reverbUnit,kAudioUnitScope_Global,0,kReverbParam_FilterBandwidth,3.0,0);
AudioUnitSetParameter(reverbUnit,kAudioUnitScope_Global,0,kReverbParam_FilterGain,3.0f,0);
Run Code Online (Sandbox Code Playgroud)
我看过一个帖子(Core Audio(iOS 5.1)Reverb2属性不存在,错误代码-10877)引用了同样的问题,但无法解决问题.
有帮助吗?非常感谢.
安德烈
我正在尝试根据麦克风的输入创建自己的自定义音效音频单元.该应用程序允许从麦克风到扬声器的同时输入/输出.我可以使用模拟器应用效果和工作,但当我尝试在iPhone上测试时,我听不到任何声音.如果有人可以帮我,我会粘贴我的代码:
- (id) init{
self = [super init];
OSStatus status;
// Describe audio component
AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_RemoteIO;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
// Get component
AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc);
// Get audio units
status = AudioComponentInstanceNew(inputComponent, &audioUnit);
checkStatus(status);
// Enable IO for recording
UInt32 flag = 1;
status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input,
kInputBus,
&flag,
sizeof(flag));
checkStatus(status);
// Enable IO for playback
status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Output,
kOutputBus,
&flag,
sizeof(flag));
checkStatus(status); …Run Code Online (Sandbox Code Playgroud) OSStatus status;
/******** Number of input channels ***************/
UInt32 inputchannels;
UInt32 sizeofdata= sizeof(inputchannels);
//problematic: gives number of potential inputs, not number actually connected
status= AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels,&sizeofdata,&inputchannels);
[self checkStatus:status]; //prints statement 1 if OSStatus !=0
NSLog(@"Inputs %d \n",inputchannels); //prints statement 2
Run Code Online (Sandbox Code Playgroud)
上面的代码结果是OSStatus 560161140(语句1).....和输入0(语句2).
任何人请帮助我知道为什么我得到这个错误状态,它可以导致什么,以及如何防止它........
我正在尝试播放我在一系列UDP数据包中收到的音频.它们被解码为具有以下属性的PCM帧:
每个UDP数据包包含480个帧,因此缓冲区的大小为480*2(通道)*2(每个通道的字节数).
我需要设置一个音频单元来播放这些数据包.所以,我的第一个问题是,我应该如何为音频单元设置AudioStreamBasicDescription结构?查看文档我甚至不确定交错PCM是否是可接受的格式.
这是我到目前为止所得到的:
struct AudioStreamBasicDescription {
Float64 mSampleRate; //48000
UInt32 mFormatID; //?????
UInt32 mFormatFlags; //?????
UInt32 mBytesPerPacket; //Not sure what "packet" means here
UInt32 mFramesPerPacket; //Same as above
UInt32 mBytesPerFrame; //Same
UInt32 mChannelsPerFrame; //2?
UInt32 mBitsPerChannel; //16?
UInt32 mReserved; //???
};
typedef struct AudioStreamBasicDescription AudioStreamBasicDescription;
Run Code Online (Sandbox Code Playgroud)
其次,在设置之后,我不确定如何将帧从UDP回调到实际的音频单元渲染功能.
我目前有一个来自套接字监听器的回调函数,我在其中生成包含我想要播放的音频的int16*缓冲区.据我了解,我还必须为以下形式的音频单元实现渲染回调:
OSStatus RenderFrames(
void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData)
{
//No idea what I should do here.
return noErr;
}
Run Code Online (Sandbox Code Playgroud)
总而言之,我认为我的套接字接收回调应该做的是解码帧,并将它们放在缓冲结构中,以便RenderFrames回调可以从该缓冲区中获取帧,并播放它们.它是否正确? …
Apple的MIDI合成代码中有一个严重的错误,或者我做错了什么.这是我对它的理解.当您发送弯音MIDI命令时,弯曲的范围是-8192到8191,转换为0.(所以实际范围是0到16383.)这个数字被分成两个7位字段,所以真的这意味着你有128个粗控制值和128个精细控制值.
这是我写的弯音样本,类似于Apple的LoadPresetDemo中的命令.
// 'ratio' is the % amount to bend in current pitch range, from -1.0 to 1.0
// 'note' is the MIDI note to bend
NSUInteger bendValue = 8191 + 1 + (8191 * ratio);
NSUInteger bendMSB = (bendValue >> 7) & 0x7F;
NSUInteger bendLSB = bendValue & 0x7F;
UInt32 noteNum = note;
UInt32 noteCommand = kMIDIMessage_PitchBend << 4 | 0;
OSStatus result = MusicDeviceMIDIEvent(self.samplerUnit, noteCommand, noteNum, bendMSB, bendLSB);
Run Code Online (Sandbox Code Playgroud)
当弯曲MSB(粗调)改变时,音高弯曲得很好.但是当bendLSB(精细控制)改变时,没有任何反应.换句话说,似乎Apple的MIDI合成器忽略了LSB,这意味着音符仅在丑陋的离散块中弯曲.
这是另一种做同样事情的方式:
// 'ratio' is the % amount …Run Code Online (Sandbox Code Playgroud) 我打算在我的iOS应用程序中重构我的录音系统.背景:到目前为止,我分别录制视频和音频,同时开始大致录制.一旦完成记录,同样的系统,我分别播放视频和音频,在音频上动态应用AudioUnits.最后,我合并了视频和修改过的音频.碰巧两个记录不会同时启动(出于任何原因),从而产生不同步的结果.
是否可以像这样重构我的系统:
1) Record normal video with audio into mov file --> I would be sure that audio+video would be synchronized.
2) During viewing the result with AVPlayer, process the audio part on the fly. (I will use AudioKit) --> that's the part I m not confident.
Would I be able to send the audio buffer to Audiokit (which would process it) and give back the processed audio to AVPlayer like if it was the original AVPlayer audio part?
3) …Run Code Online (Sandbox Code Playgroud) audiounit ×10
ios ×6
core-audio ×5
audio ×3
iphone ×3
objective-c ×2
audiokit ×1
audiosession ×1
avplayer ×1
buffer ×1
coremidi ×1
duration ×1
microphone ×1
midi ×1
video ×1