How to play MemoryStream audio files on demand #1752
-
Hello everyone, sorry if this has been asked before, I checked the wiki but could not find any similar discussions. After multiple tests attempting to play Audio files on the ESP32-S2 and ESP32-S3, i've had the most success with the arduino-audio-tools library, and managed to get the "streams-memory_raw-i2s" example working successfully over I2S with an max98357a amplifier, and was able to generate my own sample audio files and play them. My next attempt is to get this audio file to play on demand, for instance, when I push a button, but I'm having problems with the right syntax for this. In the library example, most of the code is in the setup function, and void only does is:
This is my code so far:
I'm primarily having issues understanding how to instantiate and call the "MemoryStream music" and "StreamCopy copier" lines on demand, when I run this code I get: .........\PlayAudioButtonPush\PlayAudioButtonPush.ino:66:8: error: no match for call to '(audio_tools::MemoryStream) (const unsigned char [53978], unsigned int&)' Any guidance will be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think the error messages are pretty speaking: this is not valid C++ syntax! Please check the Class documentation for the methods that are available. I suggest that you read the second chapter in the Wiki or you google the topc how to debouce the input... |
Beta Was this translation helpful? Give feedback.
I think the error messages are pretty speaking: this is not valid C++ syntax!
Please check the Class documentation for the methods that are available.
In addition your logic is completely flawed: if you press the butten, you will call playAudio() servarl thousend times per second as long as it is pressed!
I suggest that you read the second chapter in the Wiki or you google the topc how to debouce the input...