Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically stream audio in Cocoa on the Mac

How do I go about programmatically creating audio streams using Cocoa on the Mac. To make, say a white-noise generator using core frameworks on Mac OSX in Cocoa apps?

like image 359
Hans Sjunnesson Avatar asked Mar 31 '26 01:03

Hans Sjunnesson


1 Answers

One way is using the CoreAudio DefaultOutputUnit.

You can configure it with parameters such as output sampling rate, resolution, and output sample format. Then you can programmatically create a raw sound wave and provide this to the output unit.

Take a look at this example on your machine at /Developer/Examples/CoreAudio/SimpleSDK/DefaultOutputUnit/

Which uses the default output unit to play a programmatically rendered sine wave. Using that as a starting point and you can write a routine to render any thing else to output.

This location at /Developer/Examples/CoreAudio/ also contains tons of other core audio examples.

like image 85
robottobor Avatar answered Apr 02 '26 21:04

robottobor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!