- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我在这里的第一篇文章,我希望你能帮助我。我正在处理这段代码以获得基于 AudioQueue 的 AAC 播放,我用 WAV 格式测试了它,它可以工作。当我放入 .CAF 或 .M4A 文件然后触发播放方法时,会发生此错误:
ERROR: >aq> 1608: failed (-66674); will stop (66150/0 frames)
我一直在 Apple 的开发支持文档中搜索此错误代码 -66674,并说我有一个涉及 AudioQueuePrime 或 AudioQueueStart 问题的错误(现在 AudioQueuePrime 不在代码中,但我一直在测试这个还)。我知道可以使用带 AudioQueues 的 AAC,就我而言,我相信这是准确同步声音的最可靠方法。
- (IBAction)play:(id)sender {
//OSStatus result;
NSArray *audioTracks = [NSArray arrayWithObjects:
@"/Users/mauro_ptt/Documents/XCODE/SimpleAQPlayViewController/Sample01.caf",
nil];
for (id object in audioTracks) {
// Open the audio file from an existing NSString path
NSURL *sndFileURL = [NSURL fileURLWithPath:object];
AudioFileOpenURL((__bridge CFURLRef)sndFileURL, kAudioFileReadPermission, 0, &mAudioFile);
// get audio format
UInt32 dataFormatSize = sizeof(mDataFormat);
AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataFormat, &dataFormatSize, &mDataFormat);
// create playback queue
AudioQueueNewOutput(&mDataFormat, AQOutputCallback, (__bridge void *)(self), CFRunLoopGetCurrent(), kCFRunLoopCommonModes, 0, &mQueue);
// get buffer size, number of packets to read
UInt32 maxPacketSize;
UInt32 propertySize = sizeof(maxPacketSize);
// get the theoretical max packet size without scanning the entire file
AudioFileGetProperty(mAudioFile, kAudioFilePropertyPacketSizeUpperBound, &propertySize, &maxPacketSize);
// get sizes for up to 0.5 seconds of audio
DeriveBufferSize(mDataFormat, maxPacketSize, 0.5, &bufferByteSize, &mNumPacketsToRead);
// allocate packet descriptions array
bool isFormatVBR = (mDataFormat.mBytesPerPacket == 0 || mDataFormat.mFramesPerPacket == 0);
if (isFormatVBR) {
mPacketsDescs = (AudioStreamPacketDescription*) malloc(mNumPacketsToRead * sizeof(AudioStreamPacketDescription));
} else {
mPacketsDescs = NULL;
}
// Get magic cookie (COMPRESSED AAC)
UInt32 cookieSize = sizeof(UInt32);
OSStatus couldNotGetProperty = AudioFileGetPropertyInfo(mAudioFile, kAudioFilePropertyMagicCookieData, &cookieSize, NULL);
if ((couldNotGetProperty == noErr) && cookieSize) {
char *magicCookie = (char *) malloc(cookieSize);
AudioFileGetProperty(mAudioFile, kAudioFilePropertyMagicCookieData, &cookieSize, magicCookie);
AudioQueueSetProperty(mQueue, kAudioQueueProperty_MagicCookie, magicCookie, cookieSize);
free(magicCookie);
}
// Allocate and prime audio queue buffers
mCurrentPacket = 0;
for (int i=0; i < kNumberBuffers; ++i) {
AudioQueueAllocateBuffer(mQueue, bufferByteSize, &mBuffers[i]);
AQOutputCallback((__bridge void *)(self), mQueue, mBuffers[i]);
}
mIsRunning = true;
AudioQueueStart(mQueue, NULL);
}
}
提前致谢!
最佳答案
关于 AQOutputCallback 的问题,必须小心将正确的类型放在每个函数参数上。
关于ios - iOS (Objective-C) 在 AudioQueue 中播放 AAC 文件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21962742/
我对 AudioQueues 有一个基本的疑问,我正在使用 AudioQueue 进行录音,并且基本上遵循 SpeakHere 应用程序。我发现每当我在 AudioQueue 对象上使用 api: A
我创建了一个 iOS 5/iOS 6 应用程序,该应用程序的显示屏可响应用户演奏的音高变化。它使用示例 SpeakHere 代码中的记录功能,但实际上并不保存文件,因为它旨在实时响应。 我现在想扩展这
我需要读取音频样本值。我正在使用该 audioQueue 回调(来自 Apple SpeakHere 示例): UInt32 samplesCount = inCompleteAQBuffe
我正在使用 AudioQueues 获取音频样本的 block 。 这是我的回调方法 void AQRecorder::MyInputBufferHandler( void *
我正在使用文字转语音,开始音频效果很好,但我无法停止。这是我如何开始音频: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORI
我的应用使用ffmpeg 解析彩信流 到缓冲区,并使用音频队列 播放缓冲数据。现在我可以确认缓冲数据是好的,但我无法播放。播放结构基于AudioFileStreamExample demo客户端,可以
我目前正在构建一个应用程序,该应用程序从我的 iPhone 的麦克风中读取音频,然后进行一些处理和视觉处理。当然,我首先从音频开始,但有一个小问题。 我将采样率定义为 44100 Hz,并将缓冲区定义
我目前正在开发音频 DSP 应用程序。该项目需要直接访问和修改音频数据。现在我可以使用 AudioQueue 成功访问和修改原始音频数据,但在播放过程中遇到错误。任何修改后的输出音频都是噪音。 简而言
我有一个基于 AudioQueue 的应用程序几乎可以完美运行。但是,我遇到了一个问题。当我调用 AudioQueueAllocateBuffer 时,我特别请求缓冲区大小为 512(因为我正在对数据
我正在尝试设置一个音频队列来播放流式音频数据。到目前为止,这就是我所拥有的: var audioStream = AudioStreamBasicDescription() audio
尽管应用程序按预期工作,但我在控制台中收到一条消息,我想更详细地了解它。 设置如下。创建一个 AVAudioPlayer 并加载一个 .m4a 文件(长度为 03:22,大小为 618 KB)。该文件
我有一个音频队列,可以正确播放、停止和暂停,但我发现 AudioQueueStop() 函数需要很长时间才能执行。 我想立即停止然后重新开始播放音频队列,并且想知道这样做的最快方法是什么。 在我的项目
我正在尝试使用声能从麦克风确定每分钟节拍数 (BPM),我想我已经找到了确定 BPM 的部分,但在获取原始数据时遇到了一些麻烦。 该示例基于 Apples SpeakHere 应用程序 - 基于我正在
好像无法播放提示音 AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 当 AudioQueue 用于录制音频时。那是对的吗?也许我做错了什么。除
我分析了iPhone开发论坛的“SpeakHere”示例代码。 启动 AudioQueue 的代码如下.. AudioTimeStamp ats = {0}; AudioQueueStart(mQue
我正在使用AudioQueue读取AudioBuffer,它间接读取来自Mic的音频输入,但看来,回调没有命中, 下面是简要的逻辑 1--运行音频线程 2 -- 创建音频队列 3 -- 配置音频队列,
我正在编写一个类,该类打开 AudioQueue 并分析其特征,然后在某些条件下可以开始或结束从已实例化的 AudioQueue 中写出文件。这是我的代码(完全基于 SpeakHere),它打开 Au
如何获取audioQueue中音乐的总持续时间。我正在使用 NSTimeInterval AQPlayer::getCurrentTime() { NSTimeInterval timeInt
我的音频流有问题(这是内部有 6 个 channel 的 LPCM 流)。但是当我通过 AudioQueue 在 iPhone 上播放这个流时,我只听到前两个 channel 。 这里AudioQue
我正在构建一个应用程序,该应用程序需要真正准确的位置音频,直至建模耳间时间差 (ITD) 水平,即立体声 channel 之间的轻微延迟差异随声音相对于听众的位置而变化。不幸的是,iPhone 的 O
我是一名优秀的程序员,十分优秀!