Reputation: 3258
I need C++ code to play sound at particular decibels that are choose by user dynamically.
Upvotes: 1
Views: 2064
Reputation: 50
This was answered Here
You need to use the absolute path, make sure that you're sending a filename (use SND_FILENAME flag), and pause the program long enough to play the sound file (e.g., use getchar()). You need to link the winmm.lib library in your project settings, and #include windows.h and mmsystem.h in the header.
#include <windows.h>
#include <mmsystem.h>
int main() {
PlaySound((LPCSTR) "C:\\kenny g.WAV", NULL, SND_FILENAME | SND_ASYNC);
getchar();
}
Upvotes: 3