将音频录制到NSData [英] Record audio to NSData

查看:193
本文介绍了将音频录制到NSData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个iPhone之间建立了TCP连接,我可以在两者之间发送NSData包。
我想谈谈麦克风并将录音作为NSData对象并将其发送到另一部iPhone。
我成功地使用了音频队列服务来录制音频并播放它,但我还没有设法将录音作为NSData。我发布了一个关于在使用音频队列服务时将录音转换为NSData的问题但它还没有让我更进一步。

I have set up a TCP connection between two iPhones and I am able to send NSData packages between the two. I would like to talk into the microphone and get the recording as an NSData object and send this to the other iPhone. I have successfulyl used Audio Queue Services to record audio and play it but I have not managed to get the recording as NSData. I posted a question about converting the recording to NSData when using Audio Queue Services but it has not got me any further.

因此我想知道是否还有其他方法可以用来对付iPhone的麦克风并将输入作为原始数据?

Therefore I would like to hear if there is any other approach I can take to speak into the microphone of an iPhone and have the input as raw data?

更新:

我需要录制时连续发送包裹。例如。记录时每秒钟我将发送在那一秒内记录的数据。

I need to send the packages continuous while recording. E.g. every second while recording I will send the data recorded during that second.

推荐答案

音频队列和RemoteIO音频单元都会给你实时原始音频缓冲器具有相当低的延迟。您可以获取缓冲区指针和每个音频回调中给出的字节长度,以创建新的NSData块。 RemoteIO将提供最低延迟,但可能需要在回调线程外部完成网络消息传递。

Both Audio Queues and the RemoteIO Audio Unit will give you buffers of raw audio in real-time with fairly low latency. You can take the buffer pointer and the byte length given in each audio callback to create a new block of NSData. RemoteIO will provide the lowest latency, but may require the network messaging to be done outside the callback thread.

这篇关于将音频录制到NSData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆