I am trying to make a music player in C++ with irrKlang. I want to make it so that you can enter the sound file's path with getline(cin, filename)
and the engine plays that sound file for you. The problem is, getline()
returns type string
whereas irrKlang requires its own type ISoundSource*
. I can't use cin
either, as any space in the file path will just cut off everything after the character before it.
For example:
#include <iostream>
#include <string>
#include <irrKlang.h>
using namespace std;
using namespace irrklang;
int main()
{
ISoundEngine* engine = createIrrKlangDevice();
cout << "Enter path to sound: ";
string filename;
getline(cin, filename) //returns string
/*
ISoundSource* ikfilename;
getline(cinm ikfilename) //E0304 no instance of overloaded function "getline" matches the argument list
*/
engine->Play2D(filename); //E0304 no instance of overloaded function "irrklang::ISoundEngine::play2D" matches the argument list
}
I tried looking everywhere. There is no thread asking the same question as I am. I could not find any way to convert string
into ISoundSource*
. I have read the entire documentation and there is no mention of using a string
variable as input anywhere. I'd need to embed the file path in the code itself for it to work.
Any help would be greatly appreciated!