tags:

views:

337

answers:

3

Can you give an example code to play an audio file in the C language, along with what header files are needed? I am new to this concept.... I am interested to learn this.

+2  A: 

You can't do it in C alone, you're going to have to involve something platform-specific.

One way of doing that in a way that still remains very portable, is to use existing multimedia libraries, such as SDL.

unwind
+2  A: 

See http://stackoverflow.com/questions/1042752/best-c-audio-library-linux

On *nix: Simply print a raw audio file to /dev/audio

Yktula
+1  A: 

You can use PortAudio library. PortAudio is a free, cross platform, open-source, audio I/O library. It lets you write simple audio programs in 'C' that will compile and run on many platforms including Windows, Macintosh (8,9,X), Unix (OSS), SGI, and BeOS. PortAudio is intended to promote the exchange of audio synthesis software between developers on different platforms.

Free PDF Ebook Download