Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c program to play audio file

Tags:

c

audio

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.

like image 844
user292387 Avatar asked Mar 12 '10 14:03

user292387


3 Answers

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.

like image 68
Free PDF Ebook Download Avatar answered Sep 28 '22 22:09

Free PDF Ebook Download


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.

like image 20
unwind Avatar answered Sep 28 '22 20:09

unwind


See best c audio library linux

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

like image 32
Yktula Avatar answered Sep 28 '22 22:09

Yktula