Help in playing sound file from C

This is a discussion on Help in playing sound file from C within the C Programming forums, part of the General Programming Boards category; I want to play sound file(.wav,.avi,etc.) from C program. If anybody know something about this, please let me know. Thanx ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    6

    Help in playing sound file from C

    I want to play sound file(.wav,.avi,etc.) from C program. If anybody know something about this, please let me know. Thanx in advance.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,171
    Are you saying you want to call an external program to play the sound file or you want to interpret the sound file yourself and output it to the sound device? And which OS are you using?
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    84
    There's like zillion way you can do this in any OS. So... nobody but you understands what you want. But here perhaps quickest and dirtyest way of doing this in windows:
    Code:
    #include <windows.h>
    #pragma comment(lib, "WinMM.lib")
    
    int main(void)
    {
        PlaySound("sound.wav", NULL, SND_SYNC);
    
        return 0;
    }

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,767
    > I want to play sound file(.wav,.avi,etc.) from C program.
    Please remember to state you OS and compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Wannabe Geek
    Join Date
    Aug 2004
    Posts
    19
    If it was Windows XP and Borland C++ 5.02, how would it be done.

  6. #6
    ---
    Join Date
    May 2004
    Posts
    1,379
    the same way i suppose
    but, like iwabee said, that way is very _dirty_
    you should try to find a decent sound library like fmod or openal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 04:44 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  4. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 08:01 PM
  5. sounds?
    By BODYBUILDNERD in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2002, 03:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21