sound result for IF statement

Hello, i need the result for my if statement to be sound, i mean can i attach mp3 (or something like this) file and for ex:

int result;
cout << " 1+4=?" << endl;
cin >> result;
if (result == 5)
{
.............. //result to be sound
}
If you use Windows you can use the PlaySound function - though not for mp3 but for .wav files.
https://msdn.microsoft.com/en-us/library/windows/desktop/dd743680(v=vs.85).aspx
closed account (E0p9LyTq)
There is an MP3 Decoder, in the Microsoft Media Foundation:
https://msdn.microsoft.com/en-us/library/windows/desktop/ff819077(v=vs.85).aspx

MMF replaces DirectShow.
Last edited on
where that .wav files should be located?
Last edited on
i mean, i want program to make sounds that i record, not sounds that are already included in visual studio
You can play any sound - doesn't matter where it comes from. Here is an example:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <windows.h>

#pragma comment(lib, "Winmm.lib")

const char *FILENAME = "C:\\Windows\\Media\\Speech On.wav";

int main() 
{
  PlaySoundA(FILENAME, 0, SND_FILENAME);

  system("pause");
  return 0;
}


I didn't have a .wav file so I used this windows file, but it will work with all .wav files
Topic archived. No new replies allowed.