Trouble with Audio using C++
Greetings my friends.
I have been attempting to get this right for a while now, but so far no luck.
I will begin by introducing my goal, then post the script I currently possess, and the errors I wish to fix.
Goal:
My goal is to make a simple program that plays an audio file of any extension.
This audio file would be local and have a directory (say, my Desktop).
Script:
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib,"winmm.lib");
using namespace std;
int main()
{
PlaySound("C:\\Users\\Main\\Desktop\\Sample.wav", NULL, SND_FILENAME);
return 0;
}
The first limitation I am aware of with using PlaySound() is the file type can only be WAV.
I'm okay with this limitation for now - I will investigate alternatives after I have at least one working basis to rely on.
Error:
||undefined reference to `_PlaySoundA@12'|
The compiler I am using is Code::Blocks 8.02
Any help is appreciated!
Thank you everyone :)