music player

Discussion in 'C Programming' started by paytam@gmail.com, Aug 21, 2005.

  1. Guest

    How can I design a simple sound player in C.I also don't know the
    structre of music files format.Please help me.
    , Aug 21, 2005
    #1
    1. Advertising

  2. wrote on 21/08/05 :
    > 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
    Emmanuel Delahaye, Aug 21, 2005
    #2
    1. Advertising

  3. Himanshu Guest

    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
    Himanshu, Aug 21, 2005
    #3
  4. Malcolm Guest

    <> wrote
    >
    > 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.
    Malcolm, Aug 21, 2005
    #4
  5. Jack Klein Guest

    On Sun, 21 Aug 2005 21:19:55 +0000 (UTC), "Malcolm"
    <> wrote in comp.lang.c:

    > <> wrote
    > >
    > > 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.


    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?

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Aug 22, 2005
    #5
  6. Malcolm wrote:

    > <> wrote
    > >
    > > 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.


    Just curious, but what language would meet you exacting criterion for
    playing sounds?
    Pramod Subramanyan, Aug 22, 2005
    #6
  7. Emmanuel Delahaye, Aug 22, 2005
    #7
  8. Malcolm Guest

    "Emmanuel Delahaye" <> wrote
    >> Just curious, but what language would meet you exacting criterion for
    >> playing sounds?

    >
    > 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.
    Malcolm, Aug 23, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cyshao
    Replies:
    1
    Views:
    3,319
    Steve C. Orr [MVP, MCSD]
    Apr 12, 2005
  2. steven robinson
    Replies:
    0
    Views:
    649
    steven robinson
    Nov 9, 2003
  3. stevehouston

    building my own web-based music player

    stevehouston, Mar 20, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    122
    Steve C. Orr [MVP, MCSD]
    Mar 20, 2005
  4. Tejaswini Pedapati

    How to create a music player using ruby

    Tejaswini Pedapati, Dec 15, 2008, in forum: Ruby
    Replies:
    2
    Views:
    140
    Alex Fenton
    Dec 15, 2008
  5. Biku DAA
    Replies:
    1
    Views:
    112
    jake kaiden
    Apr 17, 2011
Loading...

Share This Page