Wave Too Easy - Serial Latency

Hello,
I am working on an Arduino project using the Wave Too Easy with UART commands. When sending the command to play a sound as in this example:
WaveTooEasy.playFile(“beep.wav”, 2, PLAY_MODE_NORMAL);
There is very noticeable latency created in the whole program, assuming that it is stalling out while the command is being sent by serial. Removing the command clears the latency and the code runs normally without interuptions.

Buad rate is 115200

My assumption is that calling the files by “name” (instead of by number like other boards), is creating the blocking in translating the file name/path to binary.

Do you have any tips to reduce latency? Or is there a way to call the files by number? I have more than 10 sound files, so mapping the files by channel in the configuration file is not an option.

Thanks,
T

Hello @T_F,

I don’t think the delay is due to translating names. As a matter of fact, the filesystem on the SD only accepts strings (there would be a translation/mapping if numbers were used instead).

Regarding the delay, there could be other factors at play:

  • When a command is sent, the library waits for an answer from the board so the developer knows that the file is correctly playing or if there was an error, thus providing a solid feedback. The drawback is that this approach would block the program (maybe a few milliseconds) while waiting for an answer. The library was done this way because it’s easier for the developer to integrate into sketches, but the library code is there so it could be modified by the user (or a new library can be created) to not block the program flow (the protocol is explained here).

  • Another thing you can check is that the SD card could be slow because of brand/quality/formatting/etc. This would delay both the playback and the answer sent back to the library. I would suggest to first format it with SD Formatter.

  • You can also try to increase the baudrate (you can do this modifying the configuration file) to shorten communication times.

I hope this helps.

Hi Ivan,

Thanks for your reply!

I tried increasing the buadrate to max and also reformatted my SD card. The delay has improved slightly, but is still noticeable.

I’m using a ScanDisk Ultra Plus 32GB v10 SD card, but I ordered a Samsung 128 Pro Plus v30 that has better read/write specs, so we’ll see how that works.

Do you have any particular SD card or read/write specs that you would recommend?

Thanks again!
T

A class 10, UHS 1 has pretty good results.

Hi Ivan,

I’m still having issues with blocking even after upgrading the SD card.

Would I need to create my own firmware for the W2E to deactivate the return messages? Or is this something I can configure in the h file?

Also, I thought that I had increased the baudrate from the standard 11520, but when I enter any other value for Serial.begin() and the config file, I get no sound at all.

In the library it also shows this command:
Artekit_WaveTooEasy WaveTooEasy(Serial, buadrate);
But adding any baudrate number here I get a compiling error.

Again, when commenting out the W2E commands in my code, I get no blocking. And testing with the Sparkfun WAV Trigger, I also have no blocking, but the WAV Trigger is too large for this project.

Any additional support would be greatly appreciated.

Thanks,
T

Hi @T_F,

Ok, let’s collect some basic info first.

  1. Can you measure this latency? Is it always the same? If it’s about 250 milliseconds this would mean that the Arduino is not receiving an answer back from WaveTooEasy. Read point 6) here below. In any case, I would definitely check if the Arduino is correctly receiving an answer.

  2. Is the latency about audio playback or your program blocking, or both?

  3. What Arduino are you using?

  4. Are you using a soft serial port, or a hardware serial port?

  5. “when I enter any other value for Serial.begin()”. What are these values?

  6. How are you connecting the board to the Arduino? Remember that WaveTooEasy is a 3.3V board and you may probably need a level translator between the two boards. I ask this because there might be transmissions errors: the 3.3V voltage level of the TX signal provided from WaveTooEasy to Arduino might not be high enough (because Arduino wants 5V) so there might be timeouts causing delays.

  7. What is the return value of the playFile function?

I don’t know how WAV Trigger works. Probably the provided library or protocol doesn’t need or doesn’t care about receiving answer, so it won’t block waiting for one.

To create your own firmare you can start by reading Firmare customization on the manual.

If you modify the firmware/protocol, you will also need to modify the Arduino library too.

But I guess if you are willing to modify code the easiest way would be to modify the library to not block the execution while waiting for an answer.

Just for a test, comment the lines 522 up to 527 from the WaveTooEasy_Protocol.c file. This will avoid waiting for an answer but it will probably work once, so you might need to reset the Arduino after sending a play command. This test would tell if the latency you experience is from waiting for an answer, or not receiving an answer at all.