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?

James McNellis
  • 348,265
  • 75
  • 913
  • 977
xyz
  • 27,223
  • 29
  • 105
  • 125
  • not exactly what you asked, but maybe it can help you, too: http://stackoverflow.com/questions/379353/what-is-a-lightweight-cross-platform-wav-playing-library/ – quinmars Jan 22 '10 at 14:01
  • @quinmars libao does looks excellent and lightweight. Please put it as an answer so that you can get some rep points. – xyz Jan 22 '10 at 14:50
  • done, but I haven't found any reference that libao supports OSX – quinmars Jan 22 '10 at 23:03

2 Answers2

3

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
  • 10,455
  • 1
  • 44
  • 80
1

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.

Community
  • 1
  • 1
quinmars
  • 11,175
  • 8
  • 32
  • 41
  • libao-0.8.8\src\plugins\macosx :-) – xyz Jan 23 '10 at 12:14
  • 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` – xyz Jan 25 '10 at 08:03