Reputation: 3
I Wanted To Make A Simple Piano Using C++. I Will Check If User Pressed A Key On Keyboard And Play The Piano Sound. Key Sounds Are Downloaded On Desktop And They Are .mp3 Files. So Just For Test I Wrote This Code :
#include "MyTestCodes.h"
//MyTestCodes.h Includes
/*
#include <iostream> //Input/Output Stream For Console
#include <string> //For String
#include <fstream> //File Stream
#include <vector> //Changable Index Structure
#include <Windows.h>//For System Commands
#include <algorithm>//Easy Sorting For Arrays/Vectors ...
#include <iomanip> //For Outputting With Given Precision
#include <cmath> //Easy Math Functions
#include <stdio.h> //Standard Input/Output For Given Types
#include <conio.h> //For Getting Key Presses
#include <ctime> //For Getting Real Time
#include <filesystem>
#include <mmsystem.h>
#include <Mmsystem.h>
#include <mciapi.h>
*/
using namespace std;
#pragma comment(lib, "Winmm.lib")
int main(int argc, char* argv[])
{
PlaySound("C:/Users/niko/Desktop/key01 F.mp3", NULL, SND_FILENAME);
// Tried With "\\" Too
}
I Also Tried Without MyTestCodes.h
And Include Other Libraries And Header Files By Myself (I Wrote MyTestCodes.h
By Myself Too). I Mostly Included Those :
#include <Windows.h>
#include <mmsystem.h>
#include <Mmsystem.h>
#include <mciapi.h>
Upvotes: 0
Views: 124
Reputation: 1
I'm not sure exactly what is the problem, but here is an idea: try converting mp3 to wav
For some reason WinMM doesn't like .mp3 files, and only accepts .wav
I hope this solves it
Upvotes: 0