How to pass a String variable into AudioPlaySerialflashRaw::play() ??

Status
Not open for further replies.

Electric Potato

Well-known member
Hey guys,

Maybe a silly question but I can't figure out how to assign a filename to a String, say "KICK014.RAW" for example, and then pass that String into AudioPlaySerialflashRaw :: play(const char *filename). Obviously it says it takes a char variable, but I dont understand what to do with that information, since my only experience with chars has been that they hold a single character.

To be clear this is all I want to do:

Code:
String filename = "K014.RAW";
serialFlashRaw.play(filename);

But it won't compile, cause there's no matching function for passing in a String like that.
Thanks for any help!
 
Just say no to string ;)

Need to pass c string to function,so look at string member c_str()
 
Hey thanks for the help! Unfortunately it still isn't working... based on what I've read about c_str() this should be correct, no?

Code:
String filename = "K014.RAW";
serialFlashRaw.play(filename.c_str());
 
Okay problem solved: The code I included in my second post works fine but I was using 85% of dynamic memory and at runtime my string variable was getting scrambled to where it was blank if I tried to print it. I brought AudioMemory(140) down to 100 and now it works like it should. Thanks for the help you two!
 
Status
Not open for further replies.
Back
Top