Chat on IRC |
c question
Posted by gbyte222 [send private reply] at June 01, 2002, 10:26:05 AM
How do i play a sound file? Please include syntax
Posted by CViper [send private reply] at June 01, 2002, 11:26:17 AM
whow... there's no "default" way to play a sound in C.
You need a custom API, like the Win32API (if you use windows), OpenAL (cross platform) or something similar.
Posted by gbyte222 [send private reply] at June 01, 2002, 05:45:11 PM
i do not have windows. i have linux.
Posted by gian [send private reply] at June 01, 2002, 09:05:08 PM
Okay, take a look at something like MPG123 or OpenAL (as was suggested) which should both work on GNU/Linux.
Posted by buzgub [send private reply] at June 01, 2002, 09:11:18 PM
You might also like to look at SDL; it has sound features. esound might also interest you.
Anyway, basic method of playing sounds in linux is just writing a sound file of the correct form to the file /dev/dsp.
Posted by unknown_lamer [send private reply] at June 01, 2002, 09:54:17 PM
If you are using ALSA try using libalsa (it is a very nice High-Level Audio Library). Or you can use SDL (or simply dumping a file to /dev/dsp (if it is a 16-bit LSB 44.1Khz interleaved 2 channel PCM...). Just fopen() /dev/dsp like any other file and dump stuff to it. You might want to open it as a file descriptor instead so you can use read() and write() for non-buffered access.
Register as a new user | ||||||||