music player

P

paytam

How can I design a simple sound player in C.I also don't know the
structre of music files format.Please help me.
 
E

Emmanuel Delahaye

How can I design a simple sound player in C.I also don't know the
structre of music files format.Please help me.

The use of the '\a' caracter may produce a sound (actually, it's
system-dependent), but it might be probably unsufficient to produce any
music of interst.

There is no alternative in standard C. You want systm calls or third
party more or less portable libraries like fmod.

It's not a C question.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

..sig under repair
 
H

Himanshu

Hi!

if you are using windows, refer to the mmio and waveout function in
your msdn, If you are on a mac os x try using auhal,

http://developer.apple.com/technotes/tn2002/tn2091.html

try the above link for it. Its for recording but interchanging the
scopes and using kAudioOutputUnitProperty_SetRenderCallback instead of
kAudioOutputUnitProperty_SetInputCallback would get it done.

if you are on linux try alsa sound programming. For alsa the following
link might be of help to you:
http://www.linuxjournal.com/article/6735

I would suggest that you start with uncompressed linear pcm data files
like Wave files.
try
http://www.borg.com/~jglatt/tech/wave.htm

for wave format. Its pretty straight forward.

Hope this helps

Thanks and regards
--Himanshu
 
M

Malcolm

How can I design a simple sound player in C.I also don't know the
structre of music files format.Please help me.
C doesn't have any standard sound facilities. However every compiler will
offer some sort of interface to the sound system.
Audio is difficult because it is usually asynchronous. Only rarely will you
want to play a sound, wait until it has finished, and then resume execution.
This means that C or most other languages are not ideal, and you are
frequently messing about with threads and flags and suchlike annoyances.
 
J

Jack Klein

C doesn't have any standard sound facilities. However every compiler will
offer some sort of interface to the sound system.

That's a bit of an overstatement, don't you think? I just double
checked, and the Keil C compiler for the 8051 microcontroller doesn't
seem to offer an interface to "the sound system". Probably a good
thing, since most systems using a member of the 8051 family don't have
a sound system to interface to.
Audio is difficult because it is usually asynchronous. Only rarely will you
want to play a sound, wait until it has finished, and then resume execution.
This means that C or most other languages are not ideal, and you are
frequently messing about with threads and flags and suchlike annoyances.

You just can't resist straying more and more off topic, can you?
 
P

Pramod Subramanyan

Malcolm said:
C doesn't have any standard sound facilities. However every compiler will
offer some sort of interface to the sound system.
Audio is difficult because it is usually asynchronous. Only rarely will you
want to play a sound, wait until it has finished, and then resume execution.
This means that C or most other languages are not ideal, and you are
frequently messing about with threads and flags and suchlike annoyances.

Just curious, but what language would meet you exacting criterion for
playing sounds?
 
M

Malcolm

Emmanuel Delahaye said:
It's not a language question but a hardware and system issue.
No, you need a language with good support for multithreading, which C hasn't
got - threads are a common extension but raise problems, such as trampling
over global variables and not having any easy way of scheduling.
You do of course need a sound board attached to the computer to physically
produce the sounds. Not too long ago, computers like games consoles would
produce sounds of a quality the CPU wasn't really capable of managing, by
using DMA engines and the like to feed samples to the card. So you get CD
quality audio, but as soon as you try to stray away from playing little
snatches mixed together in the specified way, you quickly find that the
system cannot cope. Nowaday that is less of an issue - a decent PC can
decompress an MPEG file, manipulate the audio data, and send to the the card
in real time.
Trying to do it in C is however a real nuisance - I don't know what language
you would use for prefenence.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top