SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By JonBDavidson
#199341
Hi,

I'm having a frustrating time finding documentation on the WAV Trigger trigger pin functions that allow users to play one sound file at a time to the end, before moving on to the next one. I know the INIT filemaker allows the user to choose polyphonic or monophonic. The problem I have is that I want to control the WAV Trigger trigger pins with a Mega, and have each sound file play to the end before moving on to the next one, so I assume I need to edit the INIT file to monophonic. However, I'm afraid that each new digitalWrite instruction to each pin will cause the new file to interrupt the previous one, and not allow it to play out. For instance, if I write

digitalWrite(Soundfile_1, LOW); // (using the Mega to ground Trigger pin one)
digitalWrite(Sounffile_2, LOW); // (using the Mega to ground Trigger pin two, etc.)

I'm afraid that file 2 will immediately interrupt file 1 and not let it play out.
I don't want to use delays between each digitalWrite function, as I am also using proximity sensors to tell if someone is approaching the object playing the sound file, and using delays keeps the proximity sensor from updating and returning a value until the delay is over. For instance, if i write:
digitalWrite(Soundfile_1, LOW); // (using the Mega to ground Trigger pin one)
delay (5000);
digitalWrite(Sounffile_2, LOW); // (using the Mega to ground Trigger pin two, etc.)
delay (5000);

The delay functions allow the sound file to play out, But it takes ten full seconds for the proximity sensor to update between each loop (as both delays total ten seconds).

Does anyone know how to get each sound file to play out completely without having to resort to using delay commands?
Any input is appreciated; I'm running out of time to finalize my project for my Arduino class. Thanks!
#199343
There are a couple of ways to do this, but they require that you implement the "wait" in your Arduino code.

The first way is to connect the "PLO" (Play Out) signal of the WAV Trigger to a digital input. This output goes low while any sound is playing and is high when no sounds are playing. It's the same logic as the WAV Trigger's status LED. If you start a track and monitor this output with a digital input, you'll know when the track finishes.

The second way is to use the serial port to control the WAV Trigger rather than the trigger inputs. The WAV Trigger Arduino Library has functions that will tell you when specific tracks are finished, allowing you much more control of when and how tracks are started and stopped. The library includes an example sketch that shows how to do this.

Hope this helps.
#199347
Thank you for replying! When you say that I need to implement the "wait" code in my Arduino programming, do you mean the delay () function?
I tried using delays in my original code, but they caused the proximity sensors to delay for the total period of time for all the delays.

Also, you state I need to connect the play-out signal of the WAV Trigger to a digital input. Do you mean the output pins that connect to the speaker? If I connect those to digital inputs, isn't that connecting an analog signal to a digital input? And if I do that, how do I then connect the speaker to the speaker pins, since those are being used to connect to the a digital input? Thanks for any clarification you can give me on that.
#199348
PS: Per Sparkfun's recommendation, I used the INIT filemaker to turn off Polyphonic and Retrigger functions. If I use digitalWrite commands without adding a delay, should they play one at a time now, instead of all at once? I also noticed under the Function tab of the INIT filemaker, options included "Next" and "Random". Will choosing "Next" cause the next pin to trigger after the first sound file plays out, and if so, how do I set it up if I'm using a Mega to control the WAV Trigger? Likewise, will choosing "Random" cause each of the 16 trigger pins to be randomly triggered, once the initial pin is triggered? That would be ideal, actually. Again, thanks for any input you may have on this.
#199353
UPDATE:

I used the INIT filemaker to turn off Polyphonic and Retrigger functions, and replaced the original file on my micro SD card with the updated file, and it makes no difference: I still get polyphonic sound files playing, whether it's three files at a time or retriggering the same sound file eight times. Can anyone tell me why the WAV Trigger is ignoring the INIT file changes? I have a project coming due in a week, and thought I'd have this resolved before now. Thanks for any input you might have!
#199356
By "wait", I don't mean the delay() function. I mean that you need to write code that monitors the state of the PLO output of the WAV Trigger using a digital input, and don't start the next sound until this signal indicates that the previous track is finished. While I can't help with basic programming issues, there are certainly folks in the Arduino forum that can provide some guidance.

Not sure why your init file changes aren't taking affect. Are you cycling the power to the WAV Trigger after making changes to the file?
#199362
Thanks for the reply! A friend of mine noticed that the INIT filemaker was set at Track 1, and deduced that I needed to add each and every track that I wanted to edit, from 1 to 16. I did so, turning off the retrigger and polyphonic functions on each track, and I got the monophonic effect I wanted.
I did cycle the power to the WAV Trigger after each edit, in that I turned off the WAV Trigger, removed the micro SD card, edited the INIT file with the INIT filemaker, put the micro card back into my WAV Trigger and turned it back on it. I believe the issue was that I didn't know that each track had to be edited individually.

I am currently trying to write code to utilize the P.L.O. pin's state (High or Low) to control which track plays. My teacher advised me I should put the output of the P.L.O. pin into a Mega pin designated as an Input. Since this is an analog output, should I plug it into an Analog pin, or a PWM pin? Does it matter if it's a digital pin or not? As always, thanks for any input on that.
#199364
robertsonics wrote: Fri Jun 01, 2018 8:42 am There are a couple of ways to do this, but they require that you implement the "wait" in your Arduino code.

The first way is to connect the "PLO" (Play Out) signal of the WAV Trigger to a digital input. This output goes low while any sound is playing and is high when no sounds are playing. It's the same logic as the WAV Trigger's status LED. If you start a track and monitor this output with a digital input, you'll know when the track finishes.

The second way is to use the serial port to control the WAV Trigger rather than the trigger inputs. The WAV Trigger Arduino Library has functions that will tell you when specific tracks are finished, allowing you much more control of when and how tracks are started and stopped. The library includes an example sketch that shows how to do this.

Hope this helps.
Thanks for all the input! I really appreciate it. Do I need to insert a resistor between the PLO output and the digital pin input, or can I directly connect the PLO pin with a jumper to a digital input pin? Also, if I configure a pen (such as pin 50 on a Mega) as an INPUT, do I then need to a assign it a HIGH or LOW value with digitalWrite, or is that relevant in this case? Sorry to ask so many questions, but I'm not finding a lot of documentation for this online. Thanks.
#199365
robertsonics wrote: Fri Jun 01, 2018 8:42 am There are a couple of ways to do this, but they require that you implement the "wait" in your Arduino code.

The first way is to connect the "PLO" (Play Out) signal of the WAV Trigger to a digital input. This output goes low while any sound is playing and is high when no sounds are playing. It's the same logic as the WAV Trigger's status LED. If you start a track and monitor this output with a digital input, you'll know when the track finishes.

The second way is to use the serial port to control the WAV Trigger rather than the trigger inputs. The WAV Trigger Arduino Library has functions that will tell you when specific tracks are finished, allowing you much more control of when and how tracks are started and stopped. The library includes an example sketch that shows how to do this.

Hope this helps.
jamie, just a quick update, I have linked the PLO output from my WAV Trigger to a digital pin input on my Mega board. I solved the Init file problem I had when a colleague pointed out that I needed to go through each track in the iNIT filemaker and uncheck the retrigger and polyphonic feature for each and every track, one at a time. It worked, and I am using a combination of randomSeed functions and Switch Case functions to randomly choose from eight different tracks on the WAV Trigger. However, as others have discovered, the PLO signal appears to be on all the time. Is there any code that might find a way around this? I want each track to play out completely, before moving on to another random track. I think other users have raised the same questions on other forums, but I haven't found a clear solution to that using Arduino code. I appreciate any advice you might have on that.
#199368
"However, as others have discovered, the PLO signal appears to be on all the time."

I'm not aware of any issue with the PLO output. Please point me to these posts. How are you determining that it is "on all the time"? Have you examined the voltage output with a meter or scope, or are you relying on your Ardiuno code to read the state as an input?

I can certainly confirm that the PLO output works as intended but it won't be for a day or so. In the meantime, please check by measuring the actual voltage of the output. It should mirror the state of the Status LED.