Randomland - The Forum

Technology => Hardware and Software => Topic started by: Brad on Jun 13, 2013, 09:12 PM

Title: Audio Playback Circuit Board
Post by: Brad on Jun 13, 2013, 09:12 PM
So my father-in-law is building basically a near-life-size pirate ship in his backyard as a play structure for the grandkids. It is going to be amazingly cool. He has asked me if it is possible to wire up a "sound effect" system connected to a couple button "control panels" which would play sounds like a cannon blast, or sailors saying "Land Ho!" or whatever. I told him yes this is possible... so now I have to figure out how to do it so it will be reliable and not crazy expensive.

Been doing a lot of research on sound playing integrated circuits. I would MUCH prefer to buy a completed PCB as opposed to creating my own. Especially as there is the possibility of needing more of these in the future.

So far after an hour of so of googling I haven't been able to find exactly what I am looking for. I've found a couple relatively cheap PCBs which can play back a single 25 second sound either from flash or EPROM. They only are only capable of playing a single sound each though. I did find one PCB which played multiple MP3s. The board only cost like a $1 each too... of course they ship from China and the minimum order is 500 units.

Got any recommendations or suggestions for me?

Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 14, 2013, 09:20 AM
Raspberry pi? Arduino? PIC chips? For the versatility offered a pi with a cheap touch screen or a panel of buttons might be a good bet. Runs linux and has gpio connectors.

People have made mp3 players with the atmega chips, so an arduino could work too. Slightly cheaper then the pi unless you just get the atmega chips bare.

We just sold a 15 button panel at the garage sale too.

Edit:
They finally seem to have then instock
http://www.newark.com/raspberry-pi/raspbrry-modb-512m/model-b-assembled-board-only/dp/43W5302
I got mine with free shipping from there a little while back. I would be happy to loan it to you if you want to see if it would work for your purposes. I would also love to help with the project. I have all these toys and no  idea what to do with them :)

Ooo, got another idea. An old or cheap android tablet/phone with a soundboard app hooked to the speaker system (either wired directly or wireless with a Bluetooth audio adapter ($12)) Use your old droid 2?
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 14, 2013, 09:57 PM
Isn't a Rasberry Pi a little over kill to play a couple sound effects? I mean you can buy like $8 toys that can play 10 - 15 sound effects. Of course they are probably stored in some crazy format at some abysmal sampling rate.

It would be a lot of fun to play with though. You could do a lot of cool stuff. Seriously cool stuff for about the same price as a single purpose breakout board.

The thing with with the buttons is they can't be on any sort of a fragile control panel (like a touch screen) they need to be sturdy because they have to be able to be activated by kids.

I would definitely welcome any help. I don't have a lot of experience dealing with complicated stuff like microprocessors.

The pirate ship is going to be finishing being put together next week so they'd like to get stuff as soon as they can.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 14, 2013, 10:25 PM
Alright the more I read about Raspberry Pi the more I think I need one. The possibilities man... the possibilities...
Title: Re: Audio Playback Circuit Board
Post by: zourtney on Jun 15, 2013, 08:00 AM
Quote from: Brad on Jun 14, 2013, 09:57 PM
Isn't a Rasberry Pi a little over kill to play a couple sound effects?

Is there anything about the whole idea of building a pirate ship in one's backyard that isn't overkill? :)

I'd love to play with this stuff too. I heard of some people around here salvaging an old Roomba to become an internet-enabled, drivable home surveillance toy :) Fun stuff
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 15, 2013, 08:22 AM
Processing wise, yeah a pi is overkill. But for the cost it's not that bad. I will look into the atmega option a little more. Those don't gave the power to play multiple sounds, and no having the pirates of the carabian theme playing in the background constantly :-)
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 15, 2013, 09:05 AM
Don't research too hard cause I am getting the Rpi. It can do everything and more. Sheez we can set it up to make it do all kinds of crazy stuff. I'd like to get two of them so I can keep one for myself.

I was up till 1am last night looking at other peoples Raspberry Pi projects.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 15, 2013, 09:15 AM
So that's what you were up to. We finally had DC up and running. But it's Ok, the hour we played was mostly star customizing her character :-)

Cool on the Pi. You should order a bluetooth dingle or a use hub too,  helps with the severe lack of usb ports available.
Title: Re: Audio Playback Circuit Board
Post by: zourtney on Jun 15, 2013, 10:11 AM
You should make it control some lighting, too. That would be awesome.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 15, 2013, 10:39 AM
Haha you could do enough stuff to practically make an amusement park ride. I am thinking sounds, lights, fog machine, and the camera that takes your photo as the pirates jump out at you or something.
Title: Re: Audio Playback Circuit Board
Post by: zourtney on Jun 15, 2013, 12:00 PM
Holy cow, that would be awesome!
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 16, 2013, 04:02 PM
Raspberry Pi has been ordered.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 16, 2013, 07:15 PM
Just one?
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 16, 2013, 07:20 PM
Yep since it was on my father-in-law's credit card. Will probably order more later. If this works out well I think he is going to want one in the tiki room.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 17, 2013, 07:49 AM
What is the tiki room?
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 17, 2013, 09:02 AM
Never been to Disneyland eh?

http://en.m.wikipedia.org/wiki/Walt_Disney's_Enchanted_Tiki_Room

Just a smaller version for kids to play in. I am not actually going to create animatronic birds though, that would be crazy. This one is more of a playhouse with a slide and everything.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 21, 2013, 08:22 AM
The pi arrived and Nick and I got Linux (raspbian) setup on it successfully. We are off to Norvac today to look for additional parts.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 21, 2013, 08:25 AM
What all do we need?
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 21, 2013, 02:58 PM
Back from Norvac. Got a couple resistors and the little connector deals to connect the wires to the rpi's pins. Still need amp, speakers, buttons, and I think the female cat5 jacks to put on the outside of the case.

I plan on working on the python mp3 playing script this weekend.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 21, 2013, 05:23 PM
This was posted from my Pi....

Currently working on getting MP3 playback to work. Just need to find some MP3 to test with....

Edit: MP3s playback now working. Note: do not use Midori to download MP3s... it doesn't work correctly. I had to use the command line wget.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 22, 2013, 08:08 AM
Awesome and good to know! 
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 23, 2013, 09:52 PM
Print 1 instead of 0 has never been so exciting!

I've successfully set up GPIO input to read a button press. Not yet using all "don't fry your pi by accident" safety circuit stuff.

I really need to brush up on my python. Doing this from an interactive command line is great for simple stuff like this... but not really want I to be doing for more complicated stuff.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 24, 2013, 09:27 AM
Awesome! Now hook an LED to another GPIO header and turn it on and off based on conditions :) Just as easy.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 27, 2013, 07:03 AM
OK. Python basics mostly mastered.

I now have a script which can detect button presses and play a sound. Also it uses interrupts unlike a lot of the basic Raspberry Pi tutorials which resort to polling so it uses way less CPU power to sit around and do nothing.

Up next is getting a directory listing and being able to play through them either sequentially or randomly.

Also - the Raspberry Pi has built in Pull Up/Down resistors so adding hardware ones (like I've seen in ~4 examples) is not necessary.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 27, 2013, 08:02 AM
Awesome!
Title: Re: Audio Playback Circuit Board
Post by: zourtney on Jun 27, 2013, 05:55 PM
I don't understand. Which makes me all the more curious :) Are you keeping track of the good tutorials you've come across?
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 27, 2013, 06:22 PM
Yep, I have been bookmarking the good tutorials. So if anybody else needs some resources I can send them your way.

I will post some pictures we I actually get to the setup and installation point.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 28, 2013, 09:15 AM
Since I am rather bored I thought I would attempt to explain what I'm talking about. That way I hopefully improve my own understanding and Nick can correct me if I'm wrong on anything...

Firstly... I am connecting to the Raspberry Pi (hereafter referred to as 'Pi') using it's built in GPIO (General Purpose Input/Output) pins. These pins are basically the same things as what you use to connect the front control panel of a PC case to the motherboard, in fact I am using the exact same time of slide on connectors.

Using a Python script I check for a button press and then execute a command to play a specific MP3 file. The way you check for a button press is to detect when the voltage over a specific pin is falling or rising.

This works by connecting the desired GPIO pin in a circuit along with the button (switch) connected to either Ground or the 3V pin on the Pi. The button/switch is normally in the open position so when you press the button it closes completing the circuit. Which causes the circuit to be connected to either ground or 3V. Resulting in a change of voltage, which is what we detect.

The Pull Up/Down resistors are resistors in the circuit which make sure the circuit is either going all the way up to 3V (or pretty close) or all the way down to 0V (or pretty close) rather than just somewhere randomly in the middle. Being in the middle is not good as it's difficult to accurately detect changes. The Pi has built in Pull Up/Down resistors so you don't have to put in hardware ones if you don't want to.

The Python RPi.GPIO library uses interrupts to execute a callback function when a rising/falling voltage is detected on a specific pin. The callback function is where I perform whatever action it is I want to occur on button press. The interrupts are much better than polling the pins to check for voltage changes as it much less resource intensive.

OK.... Hopefully that made sense to somebody other than me if anybody actually made it all the way through my drivel haha.
Title: Re: Audio Playback Circuit Board
Post by: zourtney on Jun 28, 2013, 01:52 PM
Yes! I did, and that does help a lot. Now I can at least follow all the jargon in the previous posts. And now I want to play with one! How much money have you spent on the hardware?
Title: Re: Audio Playback Circuit Board
Post by: Nick on Jun 28, 2013, 02:22 PM
They are $35 plus shipping (Mine was free shipping!). They use a micro USB charger (at least 750MA, more is better for USB devices) Plugs are accessories vary. Cables are cheap, especially online.

Brad can give more details on where his case and what not came from. 
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jun 30, 2013, 05:59 PM
Here is the python script which does the sound effects and music playing. The music is the most complicated part. The same button starts and stops the music and it plays in a playlist which loops forever.

To be able to stop the music I needed to use the subprocess module which allows you to keep a reference to the process so you can kill it. The os.system runs every process in a new terminal so you can't easily find the right PID to kill. Using subprocess is really easy (just look at my script.)

Posted from my Pi.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jul 04, 2013, 08:23 AM
So I need to find a really small amp to use for the speakers. It has to be small so it can fit up inside the top part of the pirate ship cabin.

I've been looking at something like this http://www.amazon.com/LP-2020A-Lepai-Tripath-Class-T-Amplifier/dp/B0049P6OTI/ref=sr_1_1?ie=UTF8&qid=1372951111&sr=8-1&keywords=mini+amplifier (http://www.amazon.com/LP-2020A-Lepai-Tripath-Class-T-Amplifier/dp/B0049P6OTI/ref=sr_1_1?ie=UTF8&qid=1372951111&sr=8-1&keywords=mini+amplifier). It takes the pc audio in and has decent output. Probably good enough to run a few speakers.

I'd love to have something with a ton of watts, but they don't really seem to come in a small size and without a receiver. Everything is built for a home audio which means they are all large flat rectangular things.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Jul 08, 2013, 03:37 PM
Buttons have arrived speakers and amp are in the mail.

We have settled on 5 buttons total. With 3 different functions. One plays a cannon firing sound with occasional after sounds (water splashing, cannonball crashing, "stop blowing holes in my ship!"). Another plays misc sound effects. The last controls the music.

Up top there will be two buttons (cannon and sounds). On the mast near the second steering wheel is another sound effect button. The canon itself has a cannon sound button on it. Finally the music start/stop button is in the cabin out of reach of small children.

I am guessing this thing will be completed in about a week.
Title: Re: Audio Playback Circuit Board
Post by: Brad on Aug 25, 2013, 09:58 PM
I setup the Pirate Pi version 1.2 prototype yesterday. This version removes the sound effects button and uses a USB stick for the sound effect/music storage.



Here is a really crappy phone video of the pirate ship in action. The panels still have two buttons from previous setup which had a second button specifically for sound effects. The blue button inside the cabin is for turning on/off the music. You can also see the rats nest of wires we've got setup. The speakers outside are all weather proof. I soldered a little circuit together which connects the pi to the button wiring and has the protection resistors on it.

The next boat is actually a bit larger and the final version of the sound effect system is going to be inside of a small box with power, two wire connectors, 3.5mm audio, and a usb port for outside connections. All the other stuff like the protection circuit will be contained in the box.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Aug 26, 2013, 01:11 PM
Wow. That is massively impressive. The detail on that ship is awesome, I can hardly imagine the amount of work that took. Does it have lights for at night? 

How did you end up running all the wiring? Standard conduit?
Title: Re: Audio Playback Circuit Board
Post by: Brad on Aug 26, 2013, 03:06 PM
Yeah it does have lights. Two on the top outside and one in the cabin.

The conduit is some flexible PVC type stuff with cat 5 cable in it. We are changing the wiring around for next time as we don't need as many buttons. Also the next version won't have anything run under the boat.

I have ordered enough parts to do the sound system for 3 more ships. The next one they make is going on a trailer to take to shows and stuff.
Title: Re: Audio Playback Circuit Board
Post by: Nick on Aug 26, 2013, 03:15 PM
Cool and more cool. I need to make something. It is 1/100 as awesome I will be happy.

Are they becoming shipwrights? :)
Title: Re: Audio Playback Circuit Board
Post by: Brad on Aug 26, 2013, 04:06 PM
They've got some marketing people coming on Friday to look at the ship. I guess the marketing guys were pretty excited about it. Not much out there with this level of detail apparently.

They definitely would like to just keep on making ships yeah, if they can sell them.
Title: Re: Audio Playback Circuit Board
Post by: zourtney on Aug 27, 2013, 07:48 AM
That ship is ridiculously awesome. And the buttons and sound effects looked like they turned out really well. Makes me want to do more Pi and wood projects...I've been trying a few but nothing impressive  :P