Adafruit is open and shipping! Let's build back better, together!
0

Can FX Sound Board play more than one sound at a time?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Can FX Sound Board play more than one sound at a time?

by dannydacquisto on Thu Jan 09, 2020 4:45 pm

I recently bought the Adafruit Audio FX Sound Board + 2x2W Amp - WAV/OGG Trigger -16MB....

My goal is to build a Star Wars-like spaceship control panel for my son, with all the Star Wars-y sounds. For example, I'd like him to be able to push a trigger and play laser sounds. So far, I've found the right sounds, and I can now trigger them with a simple button. Perfect! However, every time I hit the button, the sound has to play all the way through before I can "re-fire" the trigger. I can also do the loop feature, which allows me to interrupt the first triggered sound, but then that first sound stops as soon as I hit the button again.

I'd like the WAV file to play all the way through each time the button is hit, BUT ALSO be able to trigger the sound again (or a different sound) before the first sound is done playing. Is that possible?

Thanks in advance for your guidance!

dannydacquisto
 
Posts: 8
Joined: Thu Jan 09, 2020 4:33 pm

Re: Can FX Sound Board play more than one sound at a time?

by adafruit_support_carter on Thu Jan 09, 2020 5:12 pm

Unfortunately that won't work due to the way the Sound FX Board scans for the buttons. For each trigger, the tracks are played completely. And then the buttons are checked again.

It's a little more complicated, but you could consider doing this using the UART control. That has the ability to stop playback:
https://learn.adafruit.com/adafruit-aud ... yback-8-31

adafruit_support_carter
 
Posts: 17686
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can FX Sound Board play more than one sound at a time?

by dannydacquisto on Mon Jan 13, 2020 4:19 pm

Is there a way to take advantage of the amp/speakers -- essentially just use this as a shield -- and then program buttons via Arduino?

dannydacquisto
 
Posts: 8
Joined: Thu Jan 09, 2020 4:33 pm

Re: Can FX Sound Board play more than one sound at a time?

by adafruit_support_carter on Mon Jan 13, 2020 5:39 pm

Yep, that's how it would work. The amp/speakers would still work as normal. All that's changing is how you are controlling the board. The built-in triggers are there to provide a simple way of using the board without needing to have a host controller like an Arduino. But you can also control playback via serial control from an Arduino. If you use the serial control, you would move your trigger buttons to the Arduino and then have code that reads those buttons and then sends serial commands to the Sound FX board.

adafruit_support_carter
 
Posts: 17686
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can FX Sound Board play more than one sound at a time?

by dannydacquisto on Mon Jan 13, 2020 9:43 pm

Okay great. Any chance you could point me to a tutorial that explains how to use this to like a shield? Or at least, how to connect it?

dannydacquisto
 
Posts: 8
Joined: Thu Jan 09, 2020 4:33 pm

Re: Can FX Sound Board play more than one sound at a time?

by adafruit_support_carter on Mon Jan 13, 2020 10:19 pm

What specific Arduino board are you using?

adafruit_support_carter
 
Posts: 17686
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can FX Sound Board play more than one sound at a time?

by dannydacquisto on Mon Jan 13, 2020 11:31 pm

Uno

dannydacquisto
 
Posts: 8
Joined: Thu Jan 09, 2020 4:33 pm

Re: Can FX Sound Board play more than one sound at a time?

by adafruit_support_carter on Tue Jan 14, 2020 1:20 pm

Cool, easy then. The guide shows an example that is based on the UNO. See guide for wiring:
https://learn.adafruit.com/adafruit-aud ... io-control
and the example shown is from the library:
https://github.com/adafruit/Adafruit_So ... mmands.ino

adafruit_support_carter
 
Posts: 17686
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can FX Sound Board play more than one sound at a time?

by dannydacquisto on Tue Jan 14, 2020 11:55 pm

You've been incredibly helpful. Thanks so much!

I have to admit, I'm impressed; I've never done this before but I figured it out. I've got it wired, I've got the library installed on the Arduino, and I'm interacting with it via Serial Command in 115200.

I have one problem. When I do the List files command, it says there aren't any files on the board. But when I plug the board into my computer, the files show up. When I run "track #2" in serial, I hear a pop in speaker, but not the file I have stored on the board.

Any idea where I can go from here?

I feel like I'm so close! :)

dannydacquisto
 
Posts: 8
Joined: Thu Jan 09, 2020 4:33 pm

Re: Can FX Sound Board play more than one sound at a time?

by dannydacquisto on Wed Jan 15, 2020 12:34 am

I got it!!! The UG pin wasn't tied to ground.

I think I only have 1-2 more questions...

First...it's telling me the Sketch's max space is 32256 bytes, so my files that are larger than this aren't playing -- even though they used to play just fine without the Arduino. Anything I can do to adjust the max?

Also...Now that the board is interacting with the Arduino, could you point me to a tutorial that will explain how to start writing a basic code to trigger sounds with physical buttons?

dannydacquisto
 
Posts: 8
Joined: Thu Jan 09, 2020 4:33 pm

Re: Can FX Sound Board play more than one sound at a time?

by adafruit_support_carter on Wed Jan 15, 2020 12:28 pm

Cool. Glad this is starting to work.

The sound files are stored on the sound board, they are not a part of your sketch. So you don't have to generally worry about your sound file size making your sketch too large.

For the button reading, ignore the sound board for now. In fact, just remove it entirely from your setup. Then, go through this guide to get the basics of how reading buttons works:
https://learn.adafruit.com/adafruit-ard ... s/overview
Expand that out to a program that roughs in what you want to happen, using Serial.println()'s in place of actual sound board actions. For example, have pressing one of the buttons print something like "begin playing" or "playing sound 3", or whatever you want to happen when that button is pressed. Add more buttons and reads as you need.

When you've got that code working like you want for all the buttons you want to use, reconnect the sound board, then start replacing the Serial.println()'s with actual sound board commands:
https://learn.adafruit.com/adafruit-aud ... mands-8-17

adafruit_support_carter
 
Posts: 17686
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can FX Sound Board play more than one sound at a time?

by dannydacquisto on Wed Jan 15, 2020 6:02 pm

Awesome. And just to be clear, by doing it this way, I'll be able to play more than one sound a time, correct?

Also, will I always be limited to just 11 sounds? Or could I bypass the board's triggers and add more sounds than that?

dannydacquisto
 
Posts: 8
Joined: Thu Jan 09, 2020 4:33 pm

Re: Can FX Sound Board play more than one sound at a time?

by adafruit_support_carter on Wed Jan 15, 2020 8:33 pm

I was curious about being able to play more than one sound at a time, so I tested it. Unfortunately, it doesn't look like that works. For example, you can't do this:
Code: Select all | TOGGLE FULL SIZE
  sfx.playTrack("T00     WAV");
  delay(200);
  sfx.playTrack("T01     WAV");

and have the T01.wav play 0.2 seconds after T00.wav. If you increase the delay so that it's longer than T00.wav, then T01.wav plays as expected.

But what you can do is stop playback. For example, this:
Code: Select all | TOGGLE FULL SIZE
  sfx.playTrack("T00     WAV");
  delay(200);
  sfx.stop();
  sfx.playTrack("T01     WAV");

plays T00.wav for 0.2 seconds, then abruptly stops, and then starts playing T01.wav.

That's the main advantage here. With the simple non-serial button read approach, it only reads the buttons after a track is done playing. But with serial control you can stop whenever. So the idea is to replace the delay() above with code that is reading your button(s). That way when you press a button it would stop any current playback and start whatever one you want next. Or if you don't press the button(s), the sound plays all the way through.

I *think* that is what you were after in your original post?
I'd like the WAV file to play all the way through each time the button is hit, BUT ALSO be able to trigger the sound again (or a different sound) before the first sound is done playing.

adafruit_support_carter
 
Posts: 17686
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can FX Sound Board play more than one sound at a time?

by dannydacquisto on Thu Jan 16, 2020 12:23 am

That would pretty much get me halfway there. Ideally, though, I would like to be able to flip a “fight” switch, which would trigger a 1 min wav with a bunch of space ships flying by, then be able to push a trigger of a joystick to “fire lasers” at them — without stopping the first sound.

Another example...I’d like to have 3 toggle switches next to each another that trigger 3 different gear- or air compressor sounds, so that you could flip all three in a row and the sounds would build into each other to create the effect of the ship’s systems powering up.

Does that make sense? And if so, even if it requires another purchase, what would you recommend for doing something like that?

dannydacquisto
 
Posts: 8
Joined: Thu Jan 09, 2020 4:33 pm

Re: Can FX Sound Board play more than one sound at a time?

by adafruit_support_carter on Thu Jan 16, 2020 1:59 pm

One idea, if you're Arduino savy, would be to do something like this:
https://learn.adafruit.com/trellis-m4-b ... -seqeuncer
Here's the code:
https://github.com/adafruit/Adafruit_Ne ... _sequencer

adafruit_support_carter
 
Posts: 17686
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.