Introduction: BUGGO Arpeggio Synth

I have been working with Arduino for around a year.  I am very interested in synthesizers (both analog and digital) and various other musical instruments.  I had been fooling around with the code to Auduino--a basic “direct digital synthesis” grain synthesizer for some time.  I had a few half-finished projects where I modified acoustic and electric guitar bodies with softpots and capacitive sensing metal buttons to control notes.  I felt limited by the monophony of Auduino, so I started to work on ways I could do polyphony or expand the sound.  Arpeggiating notes turned out to sound very good, and the idea grew from there.






Step 1: The Idea

For a while I have wanted to design and build a synthesizer for my 2 year old daughter (aka BUGGO).  She has quite a few store bought instruments, pianos and musical toys, that she really likes.  I had a few design requirements.  It had to have lots of LEDs that responded to the music.  It had to have a mechanical/animatronic component.  The keyboard would be an array of capacitive sensing metal that would be easy for her to activate by touch.  It would also be easy to play, sounding good and “on key” with minimal effort.  Simple controls but also a lot of depth.  It would have a music box mode that would play automatically, which could also be modified manually.  I didn’t originally plan to make this project an Instructable, so while I didn’t have pictures of all of the steps and many failures along the way, I did have enough pictures to document most of the process and successes.  I will go into detail about some of the failures along the way and how they shaped the design.

Step 2: Collecting the Components

Probably the most difficult part of getting started was finding all of the components that would fit together in the proper way.  I knew the first step was to find some kind of wooden case, a jewelry or cigar box - and that every piece of the design would be dependent on the size, material and shape of that box.  I lurked thrift and craft stores several weekends in a row and finally found what I thought would be the perfect box.  It was a basic rectangular jewelry box with a hinged lid, and several felt compartments inside.  I believe I paid $2.95 for it.  The lid of the box had an inset piece of decorative “wood” that was ⅛” thick, which seemed to be the perfect thickness for a control panel.  At the same time I also purchased a motion-activated animatronic monkey ($1.99) from the Pirates of the Caribbean movies.  When a motion detector was activated, it would wave its arms wildly and say a quote from the movie.  I didn’t realize it at the time, but it would also become a key piece in the synth.

I had a couple Arduino Mega 2560's that I had been working with and I decided to use one for this project.  I needed a lot of PWM pins for the LEDs, the motor control, the sound, and many other pins for the touch buttons and all of the other controls I wanted to use.  I also had a shield kit for the Mega which I thought would be handy to solder everything to.

I also had a pretty sweet golden door handle that I found.  I thought it would make a great carrying handle.  I attached it to a volume pedal and told my friend that it was my steampunk volume pedal. 

In addition to that, I had a slew of switches, buttons and knobs.  

Step 3: Getting Started

I was eager to get started.  Gutting the box of all of the internal compartments was easy enough. I used pliers and a flathead screwdriver.  The box wasn’t in perfect shape anyway, and I assumed this project was going to be a bit rough looking.  “Embrace Mediocrity” became my mantra for the rest of the project.  It is also my mantra for this particular Instructable, since I had been planning to make one for a while, but just found out yesterday that the Musical Instruments contest ended today at midnight. 

So using some ½” metal caps which were to be the keys, I laid out enough to fit across the length of the top comfortably.  It ended up being 12, which is a perfect number, matching the Chromatic scale of a piano.  Using graph paper, I found equal spacing, taped my template in place and punched 12 pilot holes with an awl.  I then used a ½” drill bit and drilled the 12 holes out.
That’s when I realized that the ⅛” inset board, which I thought was wood, was actually some kind of paper board.  Every hole was very rough, with a lot of loose paper coming off it.  I popped in one of the metal caps, each of which had 6 “legs” to hold it in place.  It was loose.  It basically fell right out.  So I had to find another real piece of wood to be the top lid/control panel. 

After searching various hardware and hobby stores, and apparently it is very difficult to find an ⅛” piece of “real” wood, I found one right where I wasn’t looking.  I work at an architecture office and we often have a lot of sample materials laying around.  Many of them are wood.  I found a perfect stack of several different types of wood, all 12” square and ⅛” thick. 

I sawed one down to the dimensions of the box, attached it using wood glue, clamped it and let it cure for 24 hours.  It worked out very well.  Solid and sturdy.  I sanded down the sharp and rough edges.  Found a good color, a pearlescent blue Martha Stewart craft paint and applied 3 coats with a brush, letting it dry in between.  Now, having the box I would move forward with, it was really time to get down to business.

Step 4: Amp and Speakers

I had purchased the Sparkfun Mono Audio Breakout board because I didn’t have any experience yet building my own amplifier.  I had no reason not to use it.  It was cheap enough, easy to use, sounded good and familiar to me.  It requires an 8 ohm speaker.  I decided I wanted 2 speakers for balance.  So I needed two 8 ohm speakers in parallel or two 4 ohm speakers in series.  Which was another quest in itself.  After a lot of testing, I finally decided on some Altec Lansing computer speakers I had laying around.  Apparently I didn’t have a long/skinny enough screwdriver to get the speakers open cleanly, so I had to Embrace Mediocrity with a hacksaw:

These speakers have some really nice bass, and they get LOUD with the Sparkfun amp.  Almost too loud, and I worried about my 2 year old’s discretion with the volume knob.  I needed 3” holes for the speakers.  At this point the basic layout of the top of the box was becoming apparent.  The speakers would go on either side, as far into the back corners as possible.  The controls and keys would be towards the front.  That left the back middle for the animatronic element.

Step 5: The Layout

By this time I had already done surgery on the animatronic monkey to see how it worked (quite fascinating) and had the internal motorized “body” of it with the waving arms left over. 

It was a good size to fit in between the speakers and seemed like a good form to build on.  I had experimented with powering the motor using an H-Bridge and felt that I could make it work.  So that was decided.

I used ⅛” graph paper to roughly lay out my 3” holes for the speakers, the rectangular hole that the animatronic would mount in, and the 12 keys.  Everything fit well.  Rather than go buy a $17 3” hole saw, I decided to use a jigsaw.  I poked some pilot holes through the graph paper with the awl, removed the graph paper, drilled pilot holes and began sawing.  It was a fairly easy saw job, except when the 3” holes overlapped the edges of the box and the saw had to do a bit more work.  But I finally had my first holes cut. 

Step 6: Cat, Birds and Monkeys

At some point after the speaker holes were cut out and I was trying to figure out some kind of “grill” to cover them, my wife Michele had a great idea.  What if I used bird cages over the speakers?  I thought that would look cool, and it fit right into the design with the cat waving his arms up and down.  It would wave them up and down inside the bird cages.  And what else would be reaching into a bird cage than a cat?  My daughter loves kitties, so I believe these 2 pieces were chosen at the same time.  The quest began to find not only the right bird cages, but also the right stuffed cat that would fit over the body and arms of the “monkey”.  This took another week of searching.  Finally I found the 2 bird cages at Hobby Lobby, in fun mismatched colors to go along with the design, and the cat was found at Joanne Fabrics.  I found a coupon for both places, so it was a steal.  If you ever need to buy something at either, use your phone to check for a coupon.  They almost always have a 50% off e-coupon.

The bird cages needed minimal prepping to make them work.  There was a flat metal bottom that was welded/soldered on.  I pried it until I could get my wire cutters at the connection points, snipped them and worked it off.  Some of the paint came off the bottom, but that’s OK.  I did a test fit and they fit well over the top of the speakers.

The cat was also fairly easy to prep.  There was a seam down the middle of the belly.  I cut along that with a razor knife and removed most of the padding inside the torso.  I removed enough of the padding from the arms to be able to fit the monkey arms inside.  The feet and hands were full of little plastic beads, so I tried not to spill any of them. 

I slipped the cat suit over the monkey body and did a test fit.  I found that the arms went inside the cages at a good height, with no snagging.  The feet were sticking out a bit further than I would have liked, but I would deal with that later.

Step 7: Buttons and Wires

The next step was to decide what I wanted to use for the keys.  The ½” metal caps I had been trying to use before now seemed too big and a bit plain.  I thought some kind of decorative nail with a large head would work well and I could just tap them in.  I found what I was looking for with some upholstery nails, the kind that you use to pin down the cushion on a chair or sofa.  There were 3 different finishes, and they were only a dollar a piece, so I bought all 3 and consulted Michele.  We decided on the silver, which matched the blue paint well.  Using my graph paper layout, I punched 12 equally spaced holes with the awl.  I tapped them all in and started thinking about the placement of the LEDs above each key.

Step 8: LEDs

I had originally envisioned using white or blue LEDs above each key.  I went to the local electronics surplus, Skycraft.  There in a jar I found something I had never seen before, pink LEDs.  I was a little skeptical that they would actually be pink.  Often with LEDs what color they say they are isn’t quite accurate.  But I got them home and sure enough, they were very pink. 



Because of having the key nails tapped in, my graph paper was now useless.  So I just eyed the spacing and alignment (EM) and punched 2 little holes vertically about ¼” above each key.  I used a 1/16” drill bit to drill them out.  These would be the holes that the cathode/anode of each LED would go through.  I put a dab of general purpose adhesive on the bottom of each one and fitted them, then let it dry overnight.  Once the glue was dry, I bent each cathode (-) over in the same direction so that they were touching each other and soldered them.  At the end I attached a ground wire.  I attached another wire to each anode, soldered them and cleaned it up.  Then I started putting together the main project board that everything would be connected to.


I originally used pins 2-13 for the LEDs (as shown in the pic of the underside of the lid), which are all PWM on the Mega.  After I did that lack of planning (EM), I realized that pin 3 is required for the audio.  Something that is not extremely easy to switch having to do with timers.  I had to disconnect and find another set of PWMs on the Mega, the obscure and unlabeled as such pins 44-46.  There is still some debate over whether 46 is actually a PWM pin.  I wanted to also use a PWM for analog control of the motors so I could adjust the speed of the cat arms based on tempo.  I had just enough.


I found a little project board at Radio Shack that seemed like it would fit everything well.  I had an H-Bridge IC, 12 LEDs, 12 capacitive touch buttons, 12 of everything it felt like.  It gave me just about enough room for all of it.   

I used 220ohm resistors for the LEDs.  I didn’t do any calculations, I just used them.  (EM)

Step 9: The First Sounds

Now that I had the LEDs, keys, and speakers in place, it was time to start making some noise.  I started out with the code for Auduino.  I was glad that it was actually making noise by touching the keys, but it admittedly sounded bad.


This was mostly due to my laziness.  I probably could've dialed in a good sound if I hooked up some pots and tweaked around trying to find a good combo.  Instead I assigned some arbitrary values to the parameters.  It wasn't all bad, I got it to be a little melodic.  Here I am butchering the theme from TRON:


I was looking for a different sound anyway, something more instrumental or shaped.  I was still wondering if I could find some code to do polyphony.  After Googling for a bit, I found it in a very nice project called Pisanomatic.  Pisanomatic is a wheel that when pushed along generates musical sequences called Pisanos.  It was derived from a couple other projects, including Auduino.  The great part is that it not only did polyphony, but also had different voices and envelopes which could be selected.  I started to hack it into place with my code and made some progress, and finally had a decent arpeggiated sound to build on.  The voices of the Pisanomatic had a very 8 bit feel to them, which went well with the arpeggios that were so common in Nintendo music.  

I was only able to make my Pisanomatic-derived code do 2 note polyphony.  If I turned on 3 voices, I got zero output.  Still not sure why that is.  But two was enough for a bass and melody track.  I started experimenting with playing different bass notes derived from the keys that were held down.  It sounded good!

Now to build a control panel and really start controlling the sound.  

Step 10: Control Panel

I needed to get a few things in place to see how much room I was working with on the control panel.  I glued the motor body down first.  I needed to get the cat in place and see how much the feet blocked.  Unfortunately, it blocked a lot.  Between the volume knob in the middle, and the cat's paws, there wasn't much room left on either side for many other controls.  

I had some arcade style buttons, and I installed them one on each side of the box, pinball style.  Installing the first one was a struggle, as I drilled the hole with a 1" drill bit, and it turns out the button was 1 1/8".  I had some difficulty scraping the hole until I found an old steak knife I had laying around for opening boxes.  That gouged it right out and it was in.  I added a black one on the other side.  The green one would become a toggle that allows you to select voices and envelopes from the 12 cap keys.  The black one is a toggle that allows you to select what scale you're mapped to.  (6 voices, 6 envelopes,12 scales)  Holding both buttons at once allows you to modify the scale that is currently selected by toggling LEDs on and off.  

I still had the problem of those cat's paws.  Especially with the cages in place, they were huge.  Looking at the placement of the cat's feet, I started to picture knobs on top of them.  A tempo knob was a given, and I figured if I had another identical knob I could find a function for it.  You can never have too many knobs.  All I would need are a couple of long shafted pots that could go through the cat's feet and come out on top.  I got them at Radio Shack and installed them, cutting a hole in the cat's feet with a razor knife.  They popped through and I used the hacksaw to lob them off.  Then I popped some red control knobs on top.  

I tweaked the upper and lower range of tempo in the code and found a good balance.  The second knob I assigned to shift the "base note" that your keys would start at.  At this point, the synth could only play a straight 12 notes, there was no scale mapping or selection.

Also on the left of the control panel is a red 3-way toggle switch.  This changes the arpeggio that the keys play to go up (12345), down (54321) or random (34251, etc) - the random toggle is almost like instant improvisation, and the transition between up or down to random and back flows really well and almost creates a song in itself.

It was starting to sound very good, but something was still missing...





Step 11: Drums

The decision was made very late to add a drum machine that played along with your arpeggios.  I had two options - something that played straight ahead drum beats, or something else.  I thought it would be interesting if there was a drum beat that was 4 steps, and you were holding down 3 or 5 keys for your arpeggio.  Eventually if you held down the arpeggio long enough, you would line up with the beat again.  I never got around to trying it.  

I found a piece of Arduino code called BeatVox, which played PCM drum sounds using a similar sound generation method to Auduino.  I tried pretty hard to get it working on the same Arduino Mega that I was already using.  That would have been great.  But ultimately I just couldn't do it, there was too much going on already, or I wasn't good enough.  I started to consider alternatives.  Enter: The Arduino Pro Mini.  

The Pro Mini is an amazing piece of technology.  I ordered a quantity from Sparkfun during their 4th of July sale, so I had several to experiment with.  I got the BeatVox code working on one and started figuring out how it worked.  I was able to make it listen on the serial line to trigger the different drum sounds.  I was also able to power it via the 5V from the Mega.  It was very simple to wire in to the mix.  I did a bit of research on passive mixers using resistors and was able to mix the sound from the Pro Mini with the Mega going into the amp.  

Mixing the drum and synth sounds, it really started to shine.  Instead of making it produce a straight ahead drum beat as discussed earlier, I decided to make it play drums algorithmically based on what beat you were currently on.  So the way it works is, if you are holding down:

0 keys: a hi-hat plays randomly on every beat (50%) 
1 keys: a bass drum is played on the 1st beat randomly (50%) thumpthumpthumpthumpthump
2 keys: the second beat is left silent. thump-rest-thump-rest
3 keys: a snare starts to come in on the 3rd beat.  holding 3 keys does a rolling triad beat of bass-hihat-snare-bass-hihat-snare.
4 keys: follows the same pattern as before, but a rest on the 4th beat.  this creates the typical 4/4 beat.  

This makes a very interesting time signature result when you alternate between 3 and 4 keys being held down.  (or any combination of keys really)  The effect is that when you "play" the keys you are also "playing" the drums automatically.  And they are synced perfectly with every note.

There are some other accent notes thrown in at various points.  hand claps, etc.  I added in a second toggle switch on the left of the control panel to turn the drums off by cutting the PWM line coming from the Mini.  This allows you to play just the notes by themselves if you don't want a drum sound.  It does result in a shift in volume because of the voltage drop, so I will eventually rewire it so that the toggle switch is cutting the serial line rather than the PWM/PCM signal.  That should even it out.

The control panel was complete except for one item.  A large LED tipped toggle switch that I found on Skycraft's Facebook, which would trigger a mode known as.... 

Step 12: Song Mode (The Music Box)

I started working on the mode that would play songs, activated by the big (or as BUGGO would say, "Big, BIG, BIG!!!") lighted toggle switch on the right.  This took a significant amount of time.  I chose songs that had some significance to her and us.  Each song is defined by an array of offset numbers that are notes off the base note.  Each song can also have a different base note to start on.  A 9 is considered a rest.  I started off using a resolution of 48 items in the array.  As I went through the tedious process of transcribing different songs from sheet music or Ask.Yahoo.Com posts about how to play certain songs on piano, I was finding that 48 "steps" wasn't quite enough resolution for certain songs to sound the way I thought they should.  Certain accent notes were being lost and some of the songs just didn't have the feel.  Oddly enough, almost every song fit perfectly within the same amount of time.  

Since I already had about 6 songs defined, I decided to up the array resolution to 96 steps, which allowed me to "double" the current songs by putting rests in between each note, and then replacing the rests with other accent notes as needed.  This worked out well, but I don't think was worth the effort in sound.  Each song also had separate bass and drum tracks, so that was 36 long arrays (melody, bass, drums).  At some point I ran out of memory, which just caused the box to do weird things.  I dropped the bass track and made the bass play algorithmically.  A bass note equivalent to the melody note will play any time there's a kick drum sound.  It works good enough.  The melodies were pulled from many different places as I said (sometimes figured out on a piano keyboard by hand), but the drum tracks were all created from scratch.  I got to the point where I could follow the numbers of each melody and put together a kick/snare/clap pattern that served the song.  Maybe. 

What I found interesting is that almost every kids song seems to be played on whole notes (the white keys).  One exception to this was on Three Little Kittens (known as DEM KITTENS in my code) - I had to put a little kludge code in the song routine that said "if it's this song, and this note, play this note instead" to play a sharp note.  

In song mode, pressing any of the 12 keys selects one of the 12 songs.  It doesn't start over at the beginning of the song either.  It picks up at the point where the previous song was.  This allows you to create some interesting mixes and "play" song mode by choosing different songs in real time.  

There is also a random "light show" of LEDs that goes along with the beat and changes as you go to a different song.  Currently there are 5 different shows.  I will expand it at a later time to include more.  

Step 13: A Quick Walk Through the Code

After an enormous declaration of variables, the setup and loop routines begin.  

In the setup routine, the 12 capacitive keys are read as a baseline.  For some reason 1 of the capacitive pins always reads a little higher than others, so I had to create a baseline to start with, which is likely the proper thing to do anyway.  

The 12 cap keys are read and compared to the baseline.  If they exceed the baseline (which means they are being touched) their states are stored in an array.  This array is then copied to another, which is compared the next time through the loop to determine if the pattern has changed.  

Each of the 12 keys has a note value that can be updated any time.  It is updated at various points like when you turn the knob controlling the base note or when you select a different scale.  It is filled from arrays of scales which are 1's (whole tone) and 0's (semi tone).  

From the number of keys held down, a number of beats is assigned.  The tempo is derived from a formula using the tempo knob.  The tempo ranges from 60bpm up to 180bpm.  A millisecond timer is compared to see if we've passed the "interval", the amount of time a beat takes.  If it has, the interval is reset and we run through triggering the appropriate drum sounds based on what beat we are on, and play the appropriate note and bass note that is being held down.  LEDs are updated.  The loop constantly fades the LEDs by a certain amount every run through.  This allows you to increase their brightness by small amounts as their key is being touched and the loop takes care of fading them back out in the background.  

Inside of the beat loop is also the conditional which says that if we're in song mode, play the right note from the array of the current song we are on.  The cat's arms are triggered to go back and forth in the beat loop as well.  

Step 14: Things That Didn't Work

I really wanted to do a servo which would make the cat look left and right.  Because the servo library uses the timers that were already in use, I ruled it out.  I could possibly run it off of the Pro Mini, but I've also read that servos are battery hogs.  So I think it is fine without it.  I did do some tests though:





Other things that didn't make it in.. some custom drum sounds of either cats meowing or ducks quacking.  Real polyphony.  This will not be my last synth project.  I am hoping to make something special with the next big one.  

Step 15: Longer Demonstrations

Here is just a little playing around on it:



And here is a bit of song mode: 


Step 16: Conclusion

Thanks for reading.  Special thanks to the people behind Pisanomatic, BeatVox, Arduino, Auduino, and everybody on Instructables.  

Comments

author
stringstretcher (author)2014-10-14

I have been in experimental music making for a long time, and can tell you this is a very comprehensive mashup. I enjoyed how you squeeze in a lot of different ideas, and orient it to the child's level (: ... in all of us! Nice instrument. Have you made that follow up?

author
z0rb (author)2013-08-06

heh awesome job. Keep them projects coming and documented ;)

About This Instructable

6,401views

44favorites

License:

Bio: "A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet ... More »
More by rczarnik:Arduino MIDI Bass PedalsArduino Flute SynthBUGGO Arpeggio Synth
Add instructable to: