Music during program

This is a discussion on Music during program within the C Programming forums, part of the General Programming Boards category; Ok so I am wondering how to make a song play during my program. I am aware that I must ...

  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    15

    Music during program

    Ok so I am wondering how to make a song play during my program. I am aware that I must compile the song and the .wav file together (link them may be the more appropriate term) but I am wondering if I must use something like fpmuisc=fopen("music.wav","r"); How do I let the program know when to start playing the music I guess.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    Well we could "guess" at your operating system and compiler, or you could tell us.

    I mean, if you're writing a win32 program using any half-decent win32 compiler, then it's as simple as falling off a log.
    PlaySound function
    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.

  3. #3
    Registered User
    Join Date
    Jun 2012
    Posts
    15
    Sorry about that. Its a win32 program and I am using the bcc32 compiler to link them into an executable file

  4. #4
    Registered User
    Join Date
    Jun 2012
    Posts
    15
    When I try to compile I get an error that it cant read the .wav file. Is there something special I have to put in for the program to use the music. I am trying the PlaySound function as described above.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    Was the wav file in the same directory as
    - the exe file
    - the source file
    - the project root

    Did you specify an absolute or relative path name?

    What is the effective "current directory" if you specified a relative path?
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Music playing program
    By corey.heffernan in forum C Programming
    Replies: 0
    Last Post: 04-07-2011, 06:37 PM
  2. Build music into a program
    By XunTric in forum C++ Programming
    Replies: 12
    Last Post: 01-10-2006, 07:16 AM
  3. Music on a program
    By XunTric in forum C++ Programming
    Replies: 27
    Last Post: 10-03-2005, 06:55 PM
  4. Music to program to...
    By gazsux in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 03-19-2003, 12:45 PM
  5. Music files to a program
    By y2jasontario in forum C Programming
    Replies: 9
    Last Post: 04-05-2002, 01:22 AM

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