当我使用AudioQueue录制语音时如何获取RAW数据?
当我使用 AudioQueue 将语音录制到文件时,这是可以的。
我尝试在 MyInputBufferHandler 函数中使用
AudioQueueBufferRef->mAudioData
可以获得原始数据,但是在这个 MyInputBufferHandler 函数中 无法调用其他对象,例如 oStream 。
我想获取AudioQueue Buffer的原始数据,并将这些原始数据发送到互联网,该怎么做?
when i use AudioQueue to Record voice to file, this is ok.
i try at MyInputBufferHandler function use
AudioQueueBufferRef->mAudioData
can get raw data, but in this MyInputBufferHandler function
can't call other object , like oStream .
i want get AudioQueue Buffer's raw data , and send this raw data to internet ,how to do ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要按照您想要接收数据到 AudioQueue 的方式设置格式,请参阅以下函数,
http://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference/reference.html
一个例子,
You need to set the format the way you want to receive data to AudioQueue, refer following function,
http://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference/reference.html
One example,
请参阅此问题的答案,它为您提供原始数据。然后,您可以将其捆绑为 NSData 或其他形式,压缩并上传。
See the answer to this question, which gives you raw data. You can then bundle it as NSData or whatever, zip and upload.
您需要修改 myInputBufferHandler 中的一些代码,我创建了一个 obj-c 对象以采用 Apple SpeakHere 示例中的 cpp 代码。
请放心使用:
MIP_StreamAudioRecorder.h
和 .mm 文件:MIP_StreamAudioRecorder.mm
请注意,您应该更改sampleRate 和相关条件,
我将其设置为单声道(1通道)、16位、8Khz来录制。
您可以在实现MIP_StreamAudioRecorderDelegate的obj-c代码中获取原始数据,您可以通过互联网通道发送原始数据,
或将其保存到文件中。
最良好的问候,
丹尼斯.
You need to modify some codes in myInputBufferHandler, I had created a obj-c object to adopt the cpp code from Apple SpeakHere sample.
Please feel free to use it:
MIP_StreamAudioRecorder.h
And .mm file : MIP_StreamAudioRecorder.mm
Please get informed, you should change the sampleRate and relative condition,
I set it as mono (1 channel), 16 bit, 8Khz to record.
And you can get the raw data in the obj-c code which implement MIP_StreamAudioRecorderDelegate, you can send the raw data with internet channel,
or save it to file.
Best Regard,
Dennies.