views:

104

answers:

2

I want to do some sound synthesis on Mac OS X (and ideally other Unix-like OS) using ANSI C.

This is for learning purposes rather than "I need a solution, any solution, quick!"

Say I have an 8-bit buffer in my C program that I update 22050 times a second. How can I get my speakers to output that as a waveform?

+2  A: 

SDL can play sound buffers. But PortAudio may work better PA will call your C callback when it needs more data, and then you can hand it the next buffer. It's fairly easy actually.

Timothy Baldridge
+1 for portaudio. A simple sound output can be written in less than 20 line.. Open an Output-Stream and write to it.. Done!
Nils Pipenbrinck
Looks good! Thank you
frou
+1  A: 

There is no POSIX audio API or something similar. So if you want sound support on Linux, OSX, etc. you need a library that wraps around the native sound APIs of the different OSs. Take a look on this SO question. It's not asking directly for OSX, but most of the answers should also work for it, except maybe libao. At least I haven't found anything on their homepage, that says they support OSX.

quinmars
libao-0.8.8\src\plugins\macosx :-)
frou
ok, fine then :)
quinmars
Accepted this one because it's a little simpler. Anyone else on OS X, if you can't get the driver to initialise with a manually compiled version, install it using `MacPorts`
frou