Shop OBEX P1 Docs P2 Docs Learn Events
"Wav Play File" Block Locking Up — Parallax Forums

"Wav Play File" Block Locking Up

ShawnaShawna Posts: 508
edited 2018-09-27 17:47 in Learn with BlocklyProp
So I have been messing around with the "Wav Play File" Blocklyprop block. The "Wav Play File" block is in a repeat loop. The code below is generated from Blocklyprop. The wav file should play over and over because of the repeat loop and the LED should flash continually. What happens is that the wav file will play x number of times and then just stop. When the wav file does stop the LED keeps flashing because it is running in its own processor "Cog". I can't figure out why the wav file freezes or stops. Pins 26 and 27 are lit through the entire process whether sound is coming out of the speaker or not. I am using the activity wx board with the veho360 speaker. The wav file is on a sandisk 32GB SD card formatted as fat32 I believe.

Below is part of the help file on the learn site about the "Wav Play File" block. I think I have met the requirements for this to work.
WAV blocks must be used with other types of blocks.

The WAV play block launches processors to manage the SD card and generate the audio oputput. However, once the first processor has launched the others, it will shut itself down if it does not have any other blocks to execute. This breaks the project, and instead of hearing your audio track, you will just hear a buzzing sound. To avoid this, the first processor must keep running.

If your project does other things, like blink lights or make a robot move, your WAV file will play as long as other code keeps running.

If your project does NOT do other things and all you want to do is play the WAV file, do one of these two things:

Follow the WAV play block with an empty repeat forever block to play just one file, if you don't know how long it lasts.
Follow the WAV play block with a pause block with a duration lasting longer than your audio track. You can alternate WAV play blocks and pause blocks to play a series of WAV files.

Any advice would be helpful. Thanks

I used a program called Ballabolka to create a wav file from text.
I then used Audacity and the guide from Parallax Learn Site to modify the wav file to the proper format.
learn.parallax.com/support/reference/sound-library/formatting-audio-files-wav-players

Temp.zip is the wav file.
The PNG is a screenshot from Audacity.
/* SERIAL_TERMINAL USED */


// ------ Libraries and Definitions ------
#include "simpletools.h"
#include "wavplayer.h"

// ------ Function Declarations ------
void my_function();

// ------ Main Program ------
int main() {
  wav_set_pins(26, 27);
  sd_mount(22, 23, 24, 25);
  cog_run(my_function, 128);
  wav_volume(10);
  while (1) {
    wav_play("v.wav");
    print("%d", (wav_playing()));
    while (((wav_playing()) == 1)) {}
    print("%d", (wav_playing()));
  }

}

// ------ Functions ------
void my_function() {
  while (1) {
    high(9);
    pause(100);
    low(9);
    pause(100);
  }
}

934 x 719 - 44K

Comments

  • Something I've been wanting to try, but have not had time - using the equalizer in Audacity to remove really high frequency stuff - like above 16kHz. You can't hear much of it anyway, and I think things at that freq. might be causing a timing loop that is too tight, and then a waitcnt in the WAV player library overruns and locks up for 53 seconds.
Sign In or Register to comment.