Thread: Build music into a program

  1. #1
    Pawn, Pascal and C++
    Join Date
    Sep 2005
    Posts
    90

    Build music into a program

    I made a post about this like 4 months ago but never got a good answer.

    Is it possible to build a music file into a program?
    So you dont need the .wav or .mp3 or whatever file?

    Thanks

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Yes, If you're on windows then you can add then file as a resource.

  3. #3
    Pawn, Pascal and C++
    Join Date
    Sep 2005
    Posts
    90
    How I play it when its a resource then?
    Still PlaySound?

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    For Win32 look at the winmm.lib. Check the SDK for multi-media support via winmm.

  5. #5
    Pawn, Pascal and C++
    Join Date
    Sep 2005
    Posts
    90
    Sorry I got no idea what ur talking about to be honest. :P
    All I know I need to use winmm in the compiler to make my exe play songs.
    I know how to use PlaySound, but not when my song is builded into the exe?
    Last edited by XunTric; 01-08-2006 at 02:10 PM.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660

  7. #7
    Pawn, Pascal and C++
    Join Date
    Sep 2005
    Posts
    90
    Like this?

    Code:
    #include <iostream>
    #include <windows.h>
    #include <mmsystems.h>
    
    using namespace std;
    
    int main(void)
    {
        sndPlaySound("test.wav", SND_MEMORY | SND_NODEFAULT);
        
        //To not make the program quit right after the song starts to play
        cin.get();
    
        return 0;
    }
    Btw, how do I add a song as a resource?
    Sorry for my dumbness.

  8. #8
    Pawn, Pascal and C++
    Join Date
    Sep 2005
    Posts
    90
    Bump...

  9. #9
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    I'll let you in on a little secret: if you want an instant answer, use this. put your question in there, and somebody will check this thread and give you an answer within hours.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Bump...
    I see you didn't bother to wait for my PM response then...

  11. #11
    Pawn, Pascal and C++
    Join Date
    Sep 2005
    Posts
    90
    Quote Originally Posted by Salem
    > Bump...
    I see you didn't bother to wait for my PM response then...
    You said you didnt know so much about windows programming?

    major_small, lol, report bad post?

  12. #12
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Hey, look at this thread, it should help you, and you should be asking this in windows HERE.

  13. #13
    Pawn, Pascal and C++
    Join Date
    Sep 2005
    Posts
    90
    Thats for playing a .wav file outside the program.
    Which I said Ive already know how to do.
    Not a song builded into the .exe...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Music Programming - Serial Matrix Display (Help needed)
    By CrazyHorse in forum C Programming
    Replies: 1
    Last Post: 11-13-2007, 04:28 PM
  2. my server program auto shut down
    By hanhao in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-13-2004, 10:49 PM
  3. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 09:48 AM
  4. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM