问题标签 [audioqueueservices]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1678 浏览

ios - AudioQueue:无法读取 AudioFileReadPackets 中的原始数据

我正在开发一个与 DSP 相关的 iOS 应用程序。部分工作是将音频数据从 outBuffer ->mAudioData 复制到用户指定的数组中进行数据处理。读取方法是这样的:

这个过程是成功的。但是当我试图从 outBuffer->mAudioData 读取数据时,总是会出现一个错误,指出从 'void* const' 到 'SInt16*' 的无效转换:

我已经经历了几个相关的问题,例如THISTHIS,似乎他们的问题正在工作......我还尝试将 outBuffer->mAudioData 替换为 AudioFileReadPackets() 中的 testBuffer,但 testBuffer 原来是一个空数组。

那么这是正确的方法吗?有没有其他方法可以将原始数据读取到 int/float 数组?

或者更一般地说,如何访问一个 void 常量指针并对它执行读/写操作?(是的,我的 C++ 没那么强……)

任何帮助将不胜感激 :-)

干杯,曼卡

0 投票
5 回答
2333 浏览

ios4 - AudioQueueStart 失败 -12985

我制作了一个流媒体音乐播放器,它在前台运行良好。但在iOS4后台,它不会自动播放下一首歌曲。(遥控有效)原因是AudioQueueStart return -12985

我已经检查了音频会话。就好了。我AudioQueueStart在它开始播放音乐时使用。你怎么能删除AudioQueueStart


AudioQueueStart我在网上阅读了有关失败主题的答案。

要检查的一件事是 AudioSession 首先是活动的。就我而言,我之前在开始新歌之前将会话设置为在歌曲更改之间处于非活动状态:AudioSessionSetActive(false);

一旦我删除了这个 AudioQueueStart 就可以从后台正常工作。

0 投票
2 回答
1512 浏览

iphone - 设置音频队列的输入音量

所以我在网上找不到任何说我不能这样做的东西,但是每当我尝试在 iPhone 上这样做时,就会从 AudioQueueSetParameter 返回错误。具体来说,如果我尝试这段代码:

然后我收到以下错误:kAudioQueueErr_InvalidParameter。苹果的文档说这意味着:“指定的参数 ID 无效”。

但是,如果我在输出队列上尝试相同的确切代码,它就可以正常工作。有谁知道为什么我可以改变输出音量,但不能改变输入?

谢谢

0 投票
1 回答
1294 浏览

cocoa - iOS背景音频图标

我完全按照 API Docs 和 WWDC Videos,通过音频会话(使用 AudioQueue 服务)在后台播放音频。一切正常,但状态栏中没有显示“播放”指示器。

我必须单独设置它还是一个错误?

0 投票
1 回答
2003 浏览

iphone - 如何识别 iPhone 应用程序中的拍手声?

在我的 iPhone 应用程序中,我如何识别拍手发出的声音?

0 投票
1 回答
1003 浏览

ios - iOS AudioQueues:音频浮动流中的故障

我正在记录来自麦克风的浮动流(应该是静音)

我设置了缓冲区大小为 256 个浮点数的音频队列

典型的缓冲区如下所示:

PACKET 0.004791, 0.012512,0.008423,0.000122,-0.000519,-0.002991,-0.000031,0.001801,-0.000641, 0.001190,-0.003143,-0.001587,0.001587,-0.015503,-0.019440,-0.015167,-0.017670, -0.018158,-0.019928 ,-0.019409,-0.024017,-0.019684,-0.024719,-0.044128,-0.043579, -0.043152,-0.046417,-0.045380,-0.050079,-0.050262,-0.049164,-0.040710,-0.036713, -0.051056,-0.045868,- 0.035034,-0.033722,-0.028534,-0.027161,-0.022186,-0.018036, -0.012207,0.004303,-0.000824,-0.000610,0.014496,0.018005,0.019745,0.019226, 0.016144,0.013184,0.009003,0.014557,0.003357,-0.011353,- 0.007751,-0.007660, -0.006409,-0.003357,-0.003510,-0.001038,-0.000092,0.007690,0.002655,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0。000000,0.0000,0000,0000,000000000000000000000000000000000000,0000,0.000000,0000,000000000000,0000,00000000,0000,0000000000,0000000000,0000,0000,000000,0000000000,000000000000000000000000来0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,-0.006897,-0.000549, 0.003174,0.003540,0.003632, 0.004578,0.005280,0.001831,0.014771,0.014954,0.001801,0.009247,0.011139, 0.005249,0.008087,0.008636,0.007385,0.007263,0.016571,0.020264,0.010590, 0.014801,0.023132,0.027039,0.031128,0.031799,0.037109, 0.038757,0.049438, 0.057098,0.042786,0.045593,0.052032,0.045380,0.045227,0.045837,0.043793, 0.041931,0.043976,0.046570,0.030182,0.024475,0.029877,0.026184,0.026001, 0.026611,0.031921,0.035736,0.040710,0.053070,0.042572,0.039917,0.051636, 0.053009,0.053528,0.053009,0.054962,0.055603,0.053833,0.060638,0.050171, 0.041779,0.049194,0.046356,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.041931, 0.038879,0.034515,0.031494,0.026337,0.034576,0.028992,0.014038,0.018127, 0.017822,0.015137,0.015778,0.013519,0.015564,0.014832,0.023285,0.022034, 0.006317,0.010254, 0.010742,0.004303,0.003784,-0.000153,-0.002502,~0.054962,0.055603,0.053833,0.060638,0.050171, 0.041779,0.049194,0.046356,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.041931, 0.038879,0.034515,0.031494,0.026337,0.034576, 0.028992,0.014038,0.018127, 0.017822,0.015137,0.015778,0.013519,0.015564,0.014832,0.023285,0.022034, 0.006317,0.010254,0.010742,0.004303,0.003784,-0.000153,-0.002502, ~0.054962,0.055603,0.053833,0.060638,0.050171, 0.041779,0.049194,0.046356,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.041931, 0.038879,0.034515,0.031494,0.026337,0.034576, 0.028992,0.014038,0.018127, 0.017822,0.015137,0.015778,0.013519,0.015564,0.014832,0.023285,0.022034, 0.006317,0.010254,0.010742,0.004303,0.003784,-0.000153,-0.002502, ~000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.041931, 0.038879,0.034515,0.031494, 0.026337,0.034576,0.028992,0.014038,0.018127, 0.017822,0.015137,0.015778,0.013519,0.015564,0.014832,0.023285,0.022034, 0.006317,0.010254,0.010742,0.004303,0.003784,-0.000153,-0.002502, ~000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.041931, 0.038879,0.034515,0.031494, 0.026337,0.034576,0.028992,0.014038,0.018127, 0.017822,0.015137,0.015778,0.013519,0.015564,0.014832,0.023285,0.022034, 0.006317,0.010254,0.010742,0.004303,0.003784,-0.000153,-0.002502, ~

我不明白为什么我在输入信号中似乎有随机的零串。似乎有一些不连续的东西。

我首先想到也许我有左声道和右声道,而右声道总是记录为零。但是查看我的代码,我已经清楚地将其设置为单个通道。

然后我想也许这些只是信号中的寂静之地。但这没有意义。如果我只有十几个零,0.000000 我肯定会期待非常小的数字,比如 .000007 .000014,但非零数字似乎在 0.01 左右。

我刚刚尝试将音频输入切换到外部 USB 麦克风,这提高了分辨率。非零数字现在似乎在 0.001 左右。但是仍然有明显的不连续性...

我想知道是否正在对四舍五入为0的芯片进行一些计算。如果是这种情况,是否可以校准?到底是怎么回事?

我注意到的第二个非常奇怪的问题是流氓值。

这是一个包含其中一些值的示例数据包(这次使用 USB 麦克风;您可以看到分辨率是如何提高的):

~ PACKET -0.001343, -0.001190,-0.001526,-0.001373,-0.000946,-0.001526,-0.001221,-0.001190,-0.001221, -0.001251,-0.001373,-0.001190,-0.001312,-0.001312,-0.001434,-0.001282, -0.001312, -0.001099,-0.001007,-0.001221,-0.001160,-0.001312,-0.001343,-0.001221,-0.001007, -0.001099,-0.001404,-0.001068,-0.001038,-0.001404,-0.001038,-0.001190,-0.001404 , -0.001099,-0.001282,-0.001221,-0.001007,-0.001007,-0.001099,-0.001221,-0.001160, -0.001038,-0.001038,-0.001007,-0.000946,-0.001129,-0.000916,-0.000946,-0.000946, - 0.000946,-0.000824,-0.000824,-0.001007,-0.000763,-0.001038,-0.000854,-0.000977, -0.000916,-0.000641,-0.000977,-0.000916,-0.000946,-0.000732,-0.000824,0.000000, 0.000000,0.000000, 0.0000,0.0000,0000,0000,0000,0000,0000,0000,0000,000000,0.000000,0000000000,0000,0.0000,0000,0000,0000,0000,000000,0000,0000,0000,0000,000000000000000000,0000,0000,0000,0.000000000000000000000000000000,0000,00,0 .0.000000,00,0 .0.000000,00,0。000000,0.0000,0000,0000,0000,0000,0000,0.00000000,000000000000000000000000,0000000000000000000000,0000,000000,0000,000000,0000000000,0000,0000,0000,0000,00000000,000000000000,00000000000000来0.000000,0.0000,0000,0000,0000,00000000,0000,000000000000000000000000,0000,0000,00000000000000,000000000000,0000,00000000,0000000000,0000,0000,0.0000,000000,00000000,0000000000,00000000000000来0.000000,0.0000,0000,0000,0000000000000000000000000000000000000000,0000,0000000000,0000,000000000000000000,0000,00000000,0000,0000,000000000000,0000000000,000000000000机构0.000000,0.0000,0.000000,0.000000,00000000,0000,000000,0000,0000,0000,0000,000000,0000,0000000000,0000,000000000000000000000000000000000000,0000,000000000000,0000,0000000000,000000,000000,0000,000000,00000000009.0000,000000,0000,0000,0000,0000,0000,0000,0000,0000,00000000号0.000000,0.000000, -0.000000,2.000000,-2.000000,0.000000,-0.000000,36893488147419103232.000000,-36893488147419103232.000000,0.000000, -0.000000,8589934592.000000,-8589934592.000000,0.000000,-0.000000,158456325028528675187087900672.000000,-158456325028528675187087900672.000000,0.000000, -0.000000,131072.000000,- 131072.000000,0.000000,-0.000000,2417851639229258349412352.000000,-2417851639229258349412352.000000,0.000000, -0.000000,562949953421312.000000,-562949953421312.000000,0.000031,-0.000031,10384593717069655257060992658440192.000000,-10384593717069655257060992658440192.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000,0.000000,0.0000,0000,0000,0000,0000,0000,00000000000000000000,0000,0000,0000000000,000000000000,0000,0000000000000000,0000,0000,000000,000000000000,0000000000,00000000000000来

这让我很困惑。这些故障的发生率很低;不到十分之一的帧。

这是否意味着我必须预处理我的音频流?

上次我使用音频单元时,我从来没有这样做过。我只是将音频直接输入到音高检测程序中。这没有问题。所以我想知道我是否也在那里遇到了故障。

内置 MacBook 麦克风和外置 USB 麦克风都出现故障

这是我的代码:

0 投票
1 回答
1348 浏览

cocoa - 音频队列服务录制到 .mp4 文件,无法播放。和魔术饼干问题

我是一个新手 Mac 程序员只有 3 个月。我遇到了音频队列服务问题,希望有人能帮助我。

我使用 Audio Queue Services API 创建了一个录音程序,并输出 AAC 格式的数据。看起来不错,一切正常。

在我使用MP4V2库(一个开源库)输出 .mp4 文件之前,问题就出现了。

问题1:

我使用魔法 cookie作为 AAC 标头来输入 MP4V2 库函数 MP4WriteSample()。.mp4 文件里面有数据,但是播放器(例如:Quicktime)不能识别.mp4 文件,它不能播放音频数据。


问题2:

我将我的音频队列基本描述格式设置如下:

并使用 AudioQueueGetProperty() 获取魔法 cookie。

比我打印出我的魔法饼干内容,像这样:

共 39 个字节。

究竟是什么意思?

每个代表的 39 个字节是什么意思?

它可以转换为 AAC 标头吗?

参考 :

为音频文件设置 Magic Cookie

为播放音频队列设置 Magic Cookie

CoreAudio - 如何确定播放aac文件的结尾


非常感谢。

瑞安

0 投票
1 回答
1232 浏览

iphone - 如何在录制时静音背景音频(使用音频队列服务)

我有一个使用音频队列来录制语音用户输入的应用程序。这只会在短时间内发生,并且仅在用户按下按钮时发生。

我想让用户的背景音乐继续播放,除非在实际进行录制时将其静音或以低得多的音量播放(以避免录制从扬声器播放的音频)。

对于我的录制队列,我使用的是 PlayAndRecord 类别,并且我将 OverrideCategoryMixWithOthers 属性设置为 true。

0 投票
2 回答
1015 浏览

iphone - AudioQueueFreeBuffer 警告

我收到 API AudioQueueFreeBuffer 的警告“ AudioQueueObject::FreeBuffer: AQBuffer * 0x6273fd0 has enqueue count of 1 ”... 如何避免此警告?

我在 AudioQueueFreeBuffer API 中收到此警告

0 投票
1 回答
889 浏览

iphone - iPhone dev - AudioQueue 服务在后台录制

我已经构建了一个录音应用程序(例如来自苹果的“SpeakHere”演示),我想知道如何修改它以在背景上工作。

每次我进入后台,AudioQueue 回调都会冻结,我没有收到一个音频字节。

我已经看到 iPhone 上的 Voice Memos 应用程序可以在后台录制。

这是我在后台不起作用的回调:

有什么想法吗?