Waveshield slow playing

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
beaubeau
 
Posts: 32
Joined: Sun Sep 11, 2011 8:44 am

Waveshield slow playing

Post by beaubeau »

I just built my first wave shield and it's great and it works perfectly.
However, for my application, the code is a bit slow.
My application is simply to play a short, single-word, which is the only file on the SD card.
I want to play this word when a sensor is triggered.

And it actually all works! But the delay from the time the sensor fires
until the file plays is far too long for my application.
If I skip the wave shield altogether and just sound a buzzer right
off the arduino, the timing is perfect -- but I really want to play the .WAV
file instead of using a buzzer.

So, is there a way to make this .WAV start playing faster than this.....

My loop() is:

Code: Select all

void loop() {
  int sensorValue = 0;
  
  sensorValue = analogRead(sensorPin);
  if (sensorValue > sensorThreshold)
  {
    playcomplete("myfile.WAV");
  }
}
I'm using all the play-type code from http://www.ladyada.net/make/waveshield/ ... play6.html

User avatar
xl97
 
Posts: 201
Joined: Mon Jul 27, 2009 12:51 pm

Re: Waveshield slow playing

Post by xl97 »

hi.

was this ever solved?

what is the delay/latency form button press to audio being played?

Can using a different wave type library fix this?


Im curious because Im about to start playing with .wav files playing from uSD card soon.. and am trying to get familiar with what to expect and what problems others have ran into in the past.


thanks

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Waveshield slow playing

Post by adafruit_support_bill »

The "playcomplete()" function in the sample code reads the file in, then plays it. Reading the file likely accounts for most of the delay. For faster response, you could pre-load the file and use the trigger to start the playback.

User avatar
xl97
 
Posts: 201
Joined: Mon Jul 27, 2009 12:51 pm

Re: Waveshield slow playing

Post by xl97 »

how does one go about 'pre-loading'?

is there a pre-load function?

or can you like create/instantiate some sort of .wav object/instance of the lib and you can then just use a play() type command? (instead of play complete?)

I guess Im not clear on the looping aspect still?


also does a sound loop seamlessly? if you choose to play 1 file in a loop...but allow for another button to interrupt that initial lop sound playing... when the interrupt button sound is done playing.. does the initial loop sound resume?

thanks

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Waveshield slow playing

Post by adafruit_support_bill »

how does one go about 'pre-loading'?
is there a pre-load function?
We provide a "playcomplete" function in the example code. If you want to optimize it for your specific needs, you will need to look at the code and understand it well enough to modify it.
also does a sound loop seamlessly? if you choose to play 1 file in a loop...but allow for another button to interrupt that initial lop sound playing... when the interrupt button sound is done playing.. does the initial loop sound resume?
There are many example sketches with various modes of operation (including looping) here:
http://www.ladyada.net/make/waveshield/examples.html

User avatar
xl97
 
Posts: 201
Joined: Mon Jul 27, 2009 12:51 pm

Re: Waveshield slow playing

Post by xl97 »

thanks..

I have seen the examples.. (hence where I got the questions on the examples provided) :D

I dont have my wave shield yet.... so I was asking for how it works. (so to speak....feedback..not code per se`) I cant actually load/test any of the sketches atm.

when you choose to loop the .wav file.. does it loop seamlessly? or is there a gap at the end of each 'cycle'?..etc.


I mean if Im just going off reading the sketch.

Code: Select all

// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  while (wave.isplaying) {
  // do nothing while its playing
  }
  // now its done playing
}
this would lead me to believe yes..seamless looping.

but I wanted to ask about how it performs in 'real life' I guess... since there was mention of long/noticeable delay in button press to sound play. (which isnt optimal) =(

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Waveshield slow playing

Post by adafruit_support_bill »

There is a noticeable lag. As mentioned before, the playcomplete function loads the file every time. It should not be too hard to separate the load and play parts of the function to allow seamless looping.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”