Go Down

Topic: Arduino library for WTV020-SD-16P audio module (Read 119375 times) previous topic - next topic


purgedsoul


Why not use .stopVoice method?


Thank you for the reply.

I tried that too.

Even tried using pin change interrupts, thought maybe it just the delay in reading the digitalRead status for the pins.

Basically, what I wanted to achieve, is that whenever a button is pressed, it will interrupt the currently playing sound clip and play the sound clip associated with the button that was pressed (Even if it was the same button).

Here's the code I'm using:
I'm using the pinchangeint library.

Code: [Select]

/*
Example: Control a WTV020-SD-16P module to play voices from an Arduino board.
Created by Diego J. Arevalo, August 6th, 2012.
Released into the public domain.
*/

#include <Wtv020sd16p.h>
#include <PinChangeInt.h>

int resetPin = 2;  // The pin number of the reset pin.
int clockPin = 3;  // The pin number of the clock pin.
int dataPin = 4;  // The pin number of the data pin.
int busyPin = 5;  // The pin number of the busy pin.

#define BUTTON01  7
#define BUTTON02  8

/*
Create an instance of the Wtv020sd16p class.
1st parameter: Reset pin number.
2nd parameter: Clock pin number.
3rd parameter: Data pin number.
4th parameter: Busy pin number.
*/

Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);

void playSound01(){
  wtv020sd16p.stopVoice();
  wtv020sd16p.playVoice(0);
}

void playSound02(){
  wtv020sd16p.stopVoice();
  wtv020sd16p.playVoice(1);

void setup() {
  //Initializes the module.

  pinMode(BUTTON01, INPUT);
  digitalWrite(BUTTON01, HIGH);
  PCintPort::attachInterrupt(BUTTON01, &playSound01, RISING);
 
  pinMode(BUTTON02, INPUT);
  digitalWrite(BUTTON02, HIGH);
  PCintPort::attachInterrupt(BUTTON02, &playSound02, RISING);
 
  wtv020sd16p.reset();
}

void loop() {

}

the-rebel-agent


no need to change them? and they play same 'rate/speed'?   awesome!..

glad things finally came together..

good luck!.

There is no need cause the Arduino is not managing WTV clock. Only clock provided from Arduino is to control the commands you send to it.

the-rebel-agent



Why not use .stopVoice method?


Thank you for the reply.

I tried that too.

Even tried using pin change interrupts, thought maybe it just the delay in reading the digitalRead status for the pins.

Basically, what I wanted to achieve, is that whenever a button is pressed, it will interrupt the currently playing sound clip and play the sound clip associated with the button that was pressed (Even if it was the same button).

Here's the code I'm using:
I'm using the pinchangeint library.

Code: [Select]

/*
Example: Control a WTV020-SD-16P module to play voices from an Arduino board.
Created by Diego J. Arevalo, August 6th, 2012.
Released into the public domain.
*/

#include <Wtv020sd16p.h>
#include <PinChangeInt.h>

int resetPin = 2;  // The pin number of the reset pin.
int clockPin = 3;  // The pin number of the clock pin.
int dataPin = 4;  // The pin number of the data pin.
int busyPin = 5;  // The pin number of the busy pin.

#define BUTTON01  7
#define BUTTON02  8

/*
Create an instance of the Wtv020sd16p class.
1st parameter: Reset pin number.
2nd parameter: Clock pin number.
3rd parameter: Data pin number.
4th parameter: Busy pin number.
*/

Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);

void playSound01(){
  wtv020sd16p.stopVoice();
  wtv020sd16p.playVoice(0);
}

void playSound02(){
  wtv020sd16p.stopVoice();
  wtv020sd16p.playVoice(1);

void setup() {
  //Initializes the module.

  pinMode(BUTTON01, INPUT);
  digitalWrite(BUTTON01, HIGH);
  PCintPort::attachInterrupt(BUTTON01, &playSound01, RISING);
 
  pinMode(BUTTON02, INPUT);
  digitalWrite(BUTTON02, HIGH);
  PCintPort::attachInterrupt(BUTTON02, &playSound02, RISING);
 
  wtv020sd16p.reset();
}

void loop() {

}


Weird, cause If you check my previous video, that's what I am doing. Music is playing, I hit the trigger and plays a new sound. Even the fire selector plays it own sound. It should be there something wrong in the source code, not in the module.

purgedsoul

can you post the code you used on the previous video? So i can try it on my board. I don't want to rule out another SD-Card problem, cause I have already tried several cards, before I got it to make a sound.   :0 this thing is pesky with sd-cards. =(

Also, I tried playing a voice and have it loop, well, it can't do gapless loop.

@xl97: your board looks good, do you sell them cause I'm interested.

the-rebel-agent

Shared it on gallery section. Look for v laser gun.

purgedsoul

Thanks! Got it.  XD This should keep me busy.

purgedsoul

Well, it was definitely my code.

Anyone got ideas how to have this play a pseudo-gapless/seamless loop? Or this is just the limitation of this sound module.

the-rebel-agent


roan861

My module (v1.5) plays sounds only about 0.25sec from each file.
I have used library from this post (synch and asynch playing). SD card is 64MB FAT16.
I have downloaded ad4 and wav-files from this topic. http://arduino.cc/forum/index.php?topic=110924.0
Help me.

DerekD

I had a similar problem with it only playing the first blip of the file.  Here's what worked for me.
First, I had to use asyncPlayVoice, then add a delay equal or longer to the length of the file being played.  This keeps the busy led on while the file is playing.  I don't think I ever got PlayVoice to work, and it wouldn't play a file named 0000, the first one it would play was 0001.

My test program only played one file repeatedly, the delay just kept the loop from repeating and interrupting and restarting playing the file.  I think I'll add a millis reading like the blink without delay example so the delay does not stop the program from running anything else waiting for the file to finish playing.  This might get messy if there are a lot of files with different lengths.  Unfortunately, I just fried my module tonight by absentmindedly hooking it up to 5V!  Time to order a few more.

the-rebel-agent


My module (v1.5) plays sounds only about 0.25sec from each file.
I have used library from this post (synch and asynch playing). SD card is 64MB FAT16.
I have downloaded ad4 and wav-files from this topic. http://arduino.cc/forum/index.php?topic=110924.0
Help me.

It seems to me that your sd card is not supported

the-rebel-agent


I had a similar problem with it only playing the first blip of the file.  Here's what worked for me.
First, I had to use asyncPlayVoice, then add a delay equal or longer to the length of the file being played.  This keeps the busy led on while the file is playing.  I don't think I ever got PlayVoice to work, and it wouldn't play a file named 0000, the first one it would play was 0001.

My test program only played one file repeatedly, the delay just kept the loop from repeating and interrupting and restarting playing the file.  I think I'll add a millis reading like the blink without delay example so the delay does not stop the program from running anything else waiting for the file to finish playing.  This might get messy if there are a lot of files with different lengths.  Unfortunately, I just fried my module tonight by absentmindedly hooking it up to 5V!  Time to order a few more.

Syncplay usually works better with long audio files.

GaryY

For easy testing , load the microSD with sample .AD4 files provided in other links. Make sure to format the uSD to 16bit .  Power WTV020 pin 16 & 8.   I would just touch pin 9 or pin 13 to ground for playing the file. Touch pin 1 to reset the chip. The audio output is very low power. I used a speaker from a cell phone to pins 4 & 5 and held it really close to my ear to hear it. Once you get some confidence the sound files are working, you can add a LM386 amplifier, or I bought a 12V 15W amp module on ebay for $6.  After that can build on more controls functions. I also found the WTV020 cant really do MP3 mode unless you specifically buy it that way. Strangely I can force the WTV020 to operate like MP3 mode by interfacing with TTL gates or dry relay contact for a trigger. Using optocouplers or soliud state relays just didnt cut the cheese.
http://arduino.cc/forum/index.php/topic,115411.0.html  more info here

sopejonan

Hello:

I've been playing with rhe sound module i bouught in sparkfun. I've allready been able to make it work with a 2gb sd. As i use an arduino UNO i atached two serial diodes between the arduino and the module. I firstly conected the way i tough i was the correct one but it didn't work.
I made a test making it work as an mp3 and seen that it played sounds i conected the cables "upsidedown". the diagram i'm now using is the one seen in the image. I wanted to ask if this is normal as until what i know the diodes are not in the correct way like this...but is the way it works...if someone has an explanation...



thanks a lot!

Go Up