简体   繁体   中英

Real time audio recording in Swift

I am building an application which needs to do real time audio recording. I am using Swift for the project - so unable to use Novocaine library (as it has some Obj-C++ code).

What I need is get small chunks of the audio recording (real-time) which I can process or send to my websocket. Is there a Swift library that I can use to achieve this?

In addition to getting the live audio from the microphone, I also need to show a real time waveform.

  • Start recording
  • Get an event every for few bytes of recorded data, where I can send these bytes to my websocket.
  • Showing a waveform for the audio.

Let me know.

You do not need any of 3-rd party tools for getting audio from mic. It can be set up easily using AVAudioEngine. However, for minimising network traffic I suggest to use lame for compressing raw PCM audio stream into mp3.

Here you can find project with minimal functionality for getting mic input and compressing into mp3. In this example project mp3 stores into Documents folder, so you can try and listen to make sure it works.

From this point you can take mp3 buffer and send via socket. You can also play with lame settings to change quality, etc.

There is another branch called no-lame where same functionality implemented without lame encoding. Look here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM