What is the API for playing audio from the buffer in ios and osx?

I would like to make it very simple: play PCM audio data from memory.

Audio samples will come from sound synthesis algorithms, pre-loaded sample files, or something else. My question is how to play buffers, not how to fill them with data.

So, I'm looking for a better way to repurpose an old, obsolete AudioWrapper (which was based on AudioUnits V1), but I could not find in the Apple Documentation API that would do the following:

  • Compatible from 10.5 to 10.7.
  • Available on ios.
  • Does not rely on a third-party library.
  • Future proof (for example: not based on Carbon, 64 bit ...).

I am considering using OpenAL, but is this really the best option? I have seen negative reviews about this, it can be too complicated and excessive, and can add overhead to performance?

In the worst case, I could have two different implementations of this AudioWrapper, but if possible, I would really like for you to not have one version for each system (ios, 10.5, 10.6, 10.7 ...). In addition, it will be in C ++.

EDIT: I need good latency, the system should respond to user interactions in less than 20 ms (buffers should be between 128 and 512 samples at 44 kHz)

+4
source share
2 answers

AudioQueues are pretty common. However, the size of the I / O buffers is large enough that they are not ideal for interactive I / O (such as a synthesizer).

For lower latency, try AudioUnits - the MixerHost sample may be a good starting point.

+3
source

Not sure about OS X 10.5, but I directly use the audio device API to analyze and synthesize low latency audio in OS X 10.6, 10.7, and iOS 3.x through 5.x. My wrapper file for generalizing the API came to several hundred C lines, with several ifdefs.

The delay for the audio queues was too high for my low latency applications on iOS, while the iOS RemoteIO Audio Unit seems to allow buffers to be used as 256 samples (but sometimes only up to 1024 when the display turns off) at a 44100 sample rate.

+1
source

Source: https://habr.com/ru/post/1394775/


All Articles