Playing Music

M

Malcolm

Is there a way to play music(MP3 or Wav) using c or c++?
The short answer is use a platform-specific library.

The long answer is no. Music inherently demands parallel processing and
accurate timing so that the soundtrack is not interrupted by the other tasks
the computer is doing. There is no way to achieve this in ANSI C, though of
course there are manyextensions available which will give you some parallel
capacity.
 
W

Walter Roberson

The long answer is no. Music inherently demands parallel processing and
accurate timing so that the soundtrack is not interrupted by the other tasks
the computer is doing.

Say wot?

You've made a poor assumption, that the computer -has- other things
to do. That wasn't the case on the PDP-11 I studied "computer music" on.

And even if there were other things to do, sound boards have had queues
for over a decade: you toss some samples in, go and service your other
task, come back and put more samples in.

C doesn't make any real-time guarantees, but if you have output
queues you can probably fudge it *well enough* for most purposes.
[People tend not to expect 32 note polyphony in 128 voice harmony while
defragmenting the disk at the same time as they are doing a full
virus scan.]


More of a problem, perhaps, is that C provides no mechanism for
writing to fixed hardware addresses. (Conversion between integral
types and pointers is implementation defined, and in practice usually
only gives access to process virtual memory unless one is working at
the kernel or device driver level.)
 
V

vinodit205

Checkout the source of mpg123, its written in c and it plays mp3 songs
on linux platforms with ease.
 
A

a.dheeraj.kumar

well, im developing in dos(thats right, no windows)

can someone help me with the code of mpg123? i downloaded it, but i
feel it is sorta complex...i am not able to understand some of the
coding(Im just 16 yrs old...)
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top