Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Playing .WAV

Playing .WAV

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionlearning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mavgoose
    wrote on last edited by
    #1

    Hi, i have been trying to play a wav sound within my app but it will only let me play a default windows sound. I have tried various ways. Does any one know how? or does any one know of a detailed web site telling me how to play wav? Does it need to be saved as a resource? if so how. Thanks

    R M 2 Replies Last reply
    0
    • M mavgoose

      Hi, i have been trying to play a wav sound within my app but it will only let me play a default windows sound. I have tried various ways. Does any one know how? or does any one know of a detailed web site telling me how to play wav? Does it need to be saved as a resource? if so how. Thanks

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      This[^] article should help. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      1 Reply Last reply
      0
      • M mavgoose

        Hi, i have been trying to play a wav sound within my app but it will only let me play a default windows sound. I have tried various ways. Does any one know how? or does any one know of a detailed web site telling me how to play wav? Does it need to be saved as a resource? if so how. Thanks

        M Offline
        M Offline
        MeterMan
        wrote on last edited by
        #3

        /************************************* * This should be put at the top of * * the .cpp file in which you want * * the sound functions to be used * *************************************/ #INCLUDE /**************************************/ /************************************** * Go to project/settings/links * * and add winmm.lib to the listing * **************************************/ /************************************************** * Place the below code wherever you would like * * inside the .cpp file that you included the * * header file that i mentioned earlier * **************************************************/ PlaySound((LPCSTR) IDR_WAVE1, NULL, SND_ASYNC | SND_RESOURCE | SND_LOOP); // The above will play IDR_WAVE1 as a resource in sync and will loop /*************************************************************************** Now go to the resources tab and right click for simplicity the dialog folder and hit import. change the file type to wave and then find the wave that you want to make a resource. Once that is done make sure it is named IDR_WAVE1. and that should do it you should now have sound. ****************************************************************************/ /*************************************************************************** You might want to add a bool check box to turn the sound on and off cause it might sound cool but after a while it gets annoying at least in my program it did. ****************************************************************************/ //Example of how to turn sound on or off //make a check box named sound // give it a control variable call it m_soundcontrol; // In the onInit of the dialog put m_soundcontrol=true; to turn sound on // also add // PlaySound((LPCSTR) IDR_WAVE3, NULL, SND_ASYNC | SND_RESOURCE | SND_LOOP); // this will turn the sound on at the get go // then double click on the check box you made and it will make // a function called Onsound() // add some code to turn the sound on and off void CStartingOverDlg::Onsound() { if (!m_soundcontrol) { m_soundcontrol=true; PlaySound((LPCSTR) IDR_WAVE3, NULL, SND_ASYNC | SND_RESOURCE | SND_LOOP); }// end of if else { m_soundcontrol=false; PlaySound(NULL,NULL,SND_ASYNC|SND_LOOP); // sends a null sound to turn off } //end of else } // end of function Win32newb "Making windows programs worse than they already are"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups