Problem with TMRpcm library

Hi Guys.

I use TMRpcm library to record audio files onto an SD Card and that works very well. I already reconfigured the config.h file to realize that.

But I want to set the filename dynamicly and there is a strange behaviour happening

this is the working code:

 audio.startRecording("123456.wav", 16000, A0);

and for me "123456.wav" is a classic String, aint it?

and here's the modified code, which doesn't work

  String AUDIO_FILENAME = "123456.wav"; 
audio.startRecording(AUDIO_FILENAME, 16000, A0);

Here I get this exception:

exit status 1

Compilation error: no matching function for call to 'TMRpcm::startRecording(String&, int, const uint8_t&)'

Hope someone can help

Best regards

A 'String' object and a string literal(like "123456.wav") are two different things. If your function requires a C string (string literal or character pointer) you can tell the String object to return a character pointer:
audio.startRecording(AUDIO_FILENAME.c_str(), 16000, A0);

Or you could avoid the conversion to String and back:

  const char * AUDIO_FILENAME = "123456.wav"; 
  audio.startRecording(AUDIO_FILENAME, 16000, A0);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.