Playing .WAV
-
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
-
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
-
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
/************************************* * 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"