matthewreagan / Starling

Simple low-latency audio library for iOS + macOS
Other
77 stars 9 forks source link

macOS playback #1

Closed aleclarson closed 5 years ago

aleclarson commented 5 years ago

Hey, I'm working on a react-native-macos plugin that uses Starling: https://github.com/alloc/react-native-sound

I've patched Starling to support playing "raw data" (see here), but I'm getting an EXC_BAD_ACCESS error every time I try to play .wav file data (loaded over-the-wire) from its generated AVAudioPCMBuffer object.

I'm opening this issue to ask for advice on what I should do next. Do you think the .wav buffer needs a specific format for macOS, or perhaps it needs to be manually decoded first? Would you suggest I just save the data to a file and use the AVAudioFile API instead? Or maybe I should just use AVAudioPlayer instead of AVAudioEngine? Any suggestions would be great!

I also created a SO thread for this: https://stackoverflow.com/questions/55306996/playing-wav-data-with-avaudioengine

aleclarson commented 5 years ago

I noticed in this documentation (which may be outdated), Apple says:

In OS X, Core Audio expects audio data to be in native-endian, 32-bit floating-point, linear PCM format.

Do you know if my .wav files are required to meet these criteria?

aleclarson commented 5 years ago

Got it working with a bit depth of 32.

matthewreagan commented 5 years ago

Hey @aleclarson , thanks for the comment on where you're using Starling, glad your issue was resolved. This library was thrown together a bit quickly for one of my personal projects and I haven't revisited it since then, but if anything else comes up during integration let me know and I'll help out if I can.