标签: audiounit

IOS 5和RemoteIO的CABasicAnimation延迟问题

我正在为iPhone创作一种乐器.在我的应用程序中,当我触摸CALayer时,会弹奏一个音符,并且该音符会在音符持续时间内摆动.

这一切都在iOS 4.1上完美运行,但是我刚刚升级到iOS 5.0.1,并且如果我连续按下多个音符,则会遇到严重的滞后问题.在经历了很多痛苦之后,我将其缩小到以下针对触摸的CALayer的摆动动画代码.

// here is an example wiggle
CABasicAnimation *wiggle = [CABasicAnimation animationWithKeyPath:@"transform"];
wiggle.duration = 0.1;
//wiggle.repeatCount = 1e100f;
wiggle.repeatCount = 100;
wiggle.autoreverses = YES;
wiggle.toValue = [NSValue valueWithCATransform3D:CATransform3DRotate(fret.fretLayer.transform,0.2, 0.0 ,1.0 ,2.0)]; //angle, x , y , z
wiggle.fromValue = [NSValue valueWithCATransform3D:CATransform3DRotate(fret.fretLayer.transform,-0.2, 0.0 ,1.0 ,2.0)]; //angle, x , y , z

// doing the wiggle
[note.noteLayer addAnimation:wiggle forKey:@"wiggle"];
Run Code Online (Sandbox Code Playgroud)

如果我阻挡了动画添加到图层的最后一行,则所有延迟都会立即消失.这感觉就像在主线程被阻塞不知何故,或者它不是在主线程上运行,但我试图调用与performSelectorOnMainThread功能:withObject:waitUntilDone:NO,它并没有区别.如果我非常快速地按下大量的音符,整个应用程序会暂停,然后大约一秒钟之后,就像它会自动赶上并突然播放所有声音,动画最终开始变得不稳定并且在此之后窒息.

有谁知道iOS 5中CABasicAnimation的任何异常问题?是否有任何其他可以尝试的动画API,可以在重复时为CALayers设置一个未指定的持续时间?任何人都有任何建议或猜测如何解决/问题可能源于什么?

编辑:我已经确定它绝对与动画的本质无关.我用简单地淡化颜色的代码替换了摆动代码,但是我仍然得到相同的滞后效果,因为音符有些滞后.

CABasicAnimation *wiggle = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
wiggle.duration = 2;
wiggle.toValue = (id)[UIColor whiteColor].CGColor ;
wiggle.fromValue = (id)[UIColor …
Run Code Online (Sandbox Code Playgroud)

iphone core-animation core-audio audiounit ios

5
推荐指数
1
解决办法
977
查看次数

试图找出 Core Audio 的 NBandEQ

所以我试图找出苹果在 iOS 5 中添加的不良记录的 NBandEQ。我能够让它在 16 频段以下的任何东西上都能很好地工作,但我想要更多:) 如果我把它变成一个 15 频段的均衡器会发生什么一切正常,但如果我选择 16 及以上的任何数字kAudioUnitErr_InvalidPropertyValue,我在设置时会收到 -10851 ( ) 错误,kAUNBandEQProperty_NumberOfBands然后前 8 个频段设置良好,其余部分会导致 -10878 ( kAudioUnitErr_InvalidParameter) 错误。所以可以成功完成 15 个乐队,但是当我突然达到 16 个时,只能完成 8 个。有kAUNBandEQProperty_MaxNumberOfBands我可以读到我认为这是当前状态下的设备可以处理的限制。好吧,它会吐出从 12 位数字到 4 位数字的所有不稳定数字。我想我自己是不是不喜欢我给它的极端频率。我排除了这种可能性。然后我意识到频段的带宽可能重叠,它不喜欢那样。所以我将带宽从默认的 0.5 减少到最小。.05 没有帮助有以太。

我确实意识到,在我弄乱了所有愚蠢的设置之后,因为它在我什至没有进入这些设置之前就开始抱怨。它已经给出了频带数量的错误。

我发布这个问题是为了看看是否有更多有经验的程序员可以在我的代码中看到一些让我感到困惑的东西并向我指出。我意识到没有多少人涉足核心音频,更不用说 NBandEQ,但也许我搞砸了一些基本的 C,所以请看一看。我会很感激的。我显然很沮丧。同样在发布此代码时(即使它是丑陋的测试代码),也许我可以帮助落后的其他人。我知道我希望至少有一段代码可以让我看看与 NBandEQ 相关的内容

在此先感谢您的帮助!

    //Getting max bands for this device???
UInt32 maxNumOfBands;
UInt32 propSize = sizeof(maxNumOfBands);
AudioUnitGetProperty([_equilizer audioUnit],
                     kAUNBandEQProperty_MaxNumberOfBands,
                     kAudioUnitScope_Output,
                     0,
                     &maxNumOfBands,
                     &propSize);
NSLog(@"THIS IS THE MAX NUMBER OF BANDS?---%u",(unsigned int)maxNumOfBands);

UInt32 noBands = [eqFrequencies …
Run Code Online (Sandbox Code Playgroud)

c audio core-audio audiounit ios

5
推荐指数
1
解决办法
920
查看次数

iOS 后台重新获取麦克风

我试图在应用程序处于后台时获取麦克风。我正在使用音频单元技术,并且能够在后台录制音频。但是一旦我的 AudioSession 被中断,我就无法在后台使用应用程序重新启动 AudioSession。注意:如果应用程序位于前台,我可以重新启动 AudioSession。下面是中断对应的代码:

- (void) beginInterruption {
    [[AVAudioSession sharedInstance] setActive:NO error:&error];
    AudioOutputUnitStop(m_audioUnit);
}
- (void) endInterruptionWithFlags:(NSUInteger) flags{
    [[AVAudioSession sharedInstance] setActive:YES error:&error];
    AudioOutputUnitStart(m_audioUnit);
}
Run Code Online (Sandbox Code Playgroud)

AudioSession设置对应的代码

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:&error];
[[AVAudioSession sharedInstance] setActive:YES error:&error];
Run Code Online (Sandbox Code Playgroud)

AudioUnit对应的代码

// 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
oserr = AudioComponentInstanceNew(inputComponent, &m_audioUnit);
checkStatus(oserr);

// Enable IO for recording
UInt32 flag …
Run Code Online (Sandbox Code Playgroud)

audiounit ios avaudiosession avaudiosessiondelegate

5
推荐指数
1
解决办法
4598
查看次数

核心音频(音频单元)音频会话和MPVolumeView

我在VOIP应用程序上工作.我使用Core Audio Audio Units播放和录制音频.我需要能够操纵音量和输出设备.我正在尝试使用MPVolumeView设置音量并选择输出设备.

我的问题是:当我开始使用(开始播放和捕获RemoteIO音频单元)音频单元时,似乎MPVolumeView不再控制我的会话音量,而是控制系统范围的声音首选项.同时,硬件按钮控制音频单元播放的声音音量.此外,当我开始使用音频单元MPVolumeView开始显示按钮来更改输出设备但在此之前它没有.

似乎MPVolumeView控制某些系统范围音频会话的音量,但是当我开始使用音频单元时,会创建另一个应用程序范围(甚至音频单元宽)音频会话并用于播放声音.

那么问题是如何为我的Core Audio音频会话制作MPVolumeView控制音量?

我会很感激为什么会发生这种情况.我几乎整天都在谷歌上搜索,我发现有些人有相关问题,但没有任何提示:(.如果需要,我也可以发布更多细节.

iphone core-audio audiounit ios mpvolumeview

5
推荐指数
1
解决办法
480
查看次数

在 iPhone 设备上运行时 AUIOClient_StartIO 失败 (-66628)

我在 iOS7.1.1(设备:iPhone 5)的音频单元中遇到以下错误。

AUIOClient_StartIO 尝试在后台播放时失败错误:[0x3ce1a18c] 1202:AUIOClient_StartIO 失败(-66628)错误:-66628

我的是一个 PitchDetector 应用,参考GitHub 上的“ PitchDetectorExample ”项目(https://github.com/liggitt/PitchDetectorExample

我试图在后台接收音频数据。它在 iOS 7 模拟器中完美运行,但有时无法在 iOS 设备上运行

iphone audio record audiounit ios

5
推荐指数
0
解决办法
663
查看次数

渲染回调函数和输入回调函数有什么区别

虽然我在互联网上搜索,但我仍然找不到我的问题的任何答案。我看到有两种回调函数,作为音频单元属性的描述,一种称为inputcallback函数,另一种称为rendercallback函数。

@constant       kAudioOutputUnitProperty_SetInputCallback
@discussion         Scope: Global
                    Value Type: AURenderCallbackStruct
                    Access: read/write


@constant       kAudioUnitProperty_SetRenderCallback
                    Scope:          Input
                    Value Type:     AURenderCallbackStruct
                    Access:         Write
Run Code Online (Sandbox Code Playgroud)

我不知道这两者之间有什么区别,我不知道什么时候或该选择哪一个。如果有人知道这件事,请帮助我。

也许这不是一个很难的问题,但我几天都无法解决。非常感谢。

callback audiounit ios

5
推荐指数
1
解决办法
1302
查看次数

iOS:是否可以同时从多个麦克风录音

所有最近的 iPhone 都有 2 个以上的麦克风。是否可以同时从所有麦克风录音?如果可能,最好的 iOS 音频库是什么(AudioKit、EzAudio、AudioUnits、CoreAudio)?AudioKit 和 EzAudio 中没有提到这个功能。

core-audio audiounit ios ezaudio audiokit

5
推荐指数
1
解决办法
339
查看次数

iOS 16 RemoteIO:输入数据过程返回不一致的 2 个数据包

我在 iOS 16 中收到错误。此错误不会出现在以前的 iOS 版本中。我正在使用 RemoteIO 以 4000 Hz 播放实时音频。错误如下:

输入数据过程返回不一致的2个186字节数据包;每个数据包 2 字节,实际上是 93 个数据包

这是音频格式和回调的设置方式:

// Set the Audio format
AudioStreamBasicDescription audioFormat;        
audioFormat.mSampleRate         = 4000;
audioFormat.mFormatID           = kAudioFormatLinearPCM;
audioFormat.mFormatFlags        = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket    = 1;
audioFormat.mChannelsPerFrame   = 1;
audioFormat.mBitsPerChannel     = 16;
audioFormat.mBytesPerPacket     = 2;
audioFormat.mBytesPerFrame      = 2;

AURenderCallbackStruct callbackStruct;
// Set output callback
callbackStruct.inputProc = playbackCallback;
callbackStruct.inputProcRefCon = (__bridge void * _Nullable)(self);
status = AudioUnitSetProperty(audioUnit,
                              kAudioUnitProperty_SetRenderCallback,
                              kAudioUnitScope_Global,
                              kOutputBus,
                              &callbackStruct,
                              sizeof(callbackStruct));
Run Code Online (Sandbox Code Playgroud)

请注意,我设置的 mSampleRate 为 4000 Hz。在 iOS 15 …

audiounit ios remoteio ios16

5
推荐指数
0
解决办法
579
查看次数

CAStreamBasicDescription和AudioStreamBasicDescription有什么区别?

CAStreamBasicDescription和之间有什么区别AudioStreamBasicDescription?谢谢.

core-audio audiounit ios

4
推荐指数
1
解决办法
2781
查看次数

在iOS Audio Calling APP中使用循环缓冲区的原因是什么?

我的问题几乎是自我解释的.抱歉,如果它看起来太愚蠢了.

我正在编写一个iOS VoIP拨号器,并检查了一些开源代码(iOS音频呼叫应用程序).几乎所有这些都使用循环缓冲区来存储录制和接收的PCM音频数据.所以我想知道为什么在这种情况下我们需要使用循环缓冲区.使用这种音频缓冲区的确切原因是什么?

提前致谢.

audio objective-c core-audio audiounit ios

4
推荐指数
2
解决办法
2014
查看次数