Drum Set

Project

Breadboard final.jpg

The concept of this project is to create a digital drum set. The idea will be conceived using four major components: an Arduino, Max/MSP, Piezo sensors and drum samples. The scope of this project is scalable depending on the amount of analog inputs in the Arduino, Piezo sensors, and drum samples, but for my project the goal is to create a standard drum set, which is five pieces. By writing the proper code for Arduino and Max/MSP to interpret the data from the sensors, it should be possible to use the values to output the chosen drum samples in Max/MSP when the sensors are struck.

Preliminary Tests

Arduino Knock Test

For the beginning test of my project I followed the knock tutorial found on Arduino [1]. The hardware setup for the example was simple enough. Unlike the example, I used a breadboard and taped my Piezo sensor to the bottom of a lid from a plastic container. I will use plastic containers to house the Piezo sensors. With this test, when I tap on the lid of the container, Arduino would output knock! and the LEDLight-emitting diode light would toggle on/off.

Creating First Drum Piece

Setting Up Arduino Hardware

This is how I set up my sensor to the Arduino Uno.

Setting Up Arduino Software to Output Sensor Data

Although the knock test worked, I realized that I need to output the numerical data that the Piezo sensor detects. Here is the coding and output:

Creating Max Patch

For the Max patch, I needed to translate the data read from the sensor into one value. By using the message box, I was able to see the values that were output when I tapped the sensor. I created a range 0 to 300 and have it bang if the value is higher than 300, because the value when tapped is usually higher than 300. The bang triggers the on/off switch for the kick bass drum. I added a 300 millisecond delay to the bang to act as an off button so once the drum is turned on and produces a sound, it will then turn off.

/First Drum Kit Patch

Adding Second Drum Piece

Setting Up Arduino Hardware

Although, my drum piece was working, I found out when attaching the second sensor that my hardware setup was wrong. I had the circuit connect only through the analog input and ground, so I needed to connect to the 5V to create a true circuit. I did that and then I added the second sensor data to Arduino code and cleaned up the code. The only issue that I'm still dealing with is the values given from the sonsors. For some reason, when I add a second sensor to Arduino, one of the sensors always outputs variable data above 0 when it has not been triggered.

Adding Second Drum Piece to Max/MSP

The most difficult part of this was trying to separate the data from each of the sensors. Initially, I tried an unpack, but that was unsuccessful. Luckily, with the help from class, I rewrote the Arduino code, as shown above, and was able to separate the sensors. Once, that was done, it was not difficult to add the next drum piece.


Here is the coding for Arduino and Max/MSP:

/Arduino 2 Drum Piece

/Max 2 Drum Piece

Adding Third Drum Piece

Setting Up Arduino Hardware

For this step, I just used the same Arduino code as before, but added the extra data for reading the third sensor. I added another analogPin, another val, and another Serial.print. I also added a threshold of 900 to the Arduino code so that the sensor wouldn't bang when I wasn't trying to make it bang.

Adding Third Drum Piece to Max/MSP

For this step, I added another element to unpack and then copied everything from below from one of the other drum pieces and connected it to unpack. I changed the drum audio that it would play for the new sensor. I also raised the split to 900, but this may be redundant since I added a threshold to the Arduino code as well.


Here is the coding for Arduino and Max/MSP:

/Arduino 3 Drum Piece

/Max 3 Drum Piece

Adding Fourth Drum Piece

Setting Up Arduino Hardware

Adding the fourth was the procedure as before. I added in another analogPin, another val, and another Serial.print.

Adding Fourth Drum Piece to Max/MSP

This time adding the fourth instrument was not the same procedure as before. I realized that the audio files provided by Max/MSP did not have enough drum sounds to complete the 5 pieces that I desired. Because of this I added sound files that I had of different drum pieces. I was able to link them with open and sfplay~. I added live gain to each piece so you can adjust them separately to the appropriate volume.


Here is the coding for Arduino and Max/MSP:

/Arduino 4 Drum Piece

/Max 4 Drum Piece

Adding Fifth Drum Piece

Setting Up Arduino Hardware

The setup was the same as before. I added in another analogPin, another val, and another Serial.print to accomadate the fifth and final peice.

Adding Fifth Drum Piece to Max/MSP

Since I had already setup using my own sound files for the drums when I added the fourth piece, this step was simple enough. Added another element to unpack and then copied the everything below from a another drum piece and connected it to unpack, changed the audio file, and connect it to the output.


Here is the coding for Arduino and Max/MSP:

/Arduino 5 Drum Piece

/Max 5 Drum Piece

Final Result


As you can see, I was able to hook up 5 Piezo sensors to the Arduino by using a breadboard, alligator clips, jumper cables, and 1M resistors.


See /Arduino 5 Drum Piece and /Max 5 Drum Piece for final coding.

Conclusions

One problem I encountered was that when I hooked up more than one sensor, there would be some noise, some of the sensors would constantly output a low signal when other sensors were struck, but the number is usually very low and I negated it because of the threshold that I put in the Arduino and Max/MSP code. When each sensor is struck it outputs the assigned drum noise, thus successfully creating a digital drum set using Arduino and Max/MSP.

Future Improvements

Although I was able to create a digital drum set, it isn't very practical. The way the project is setup, one cannot simply play it like it were a real drum set. Future improvements would be to create better constructed drum heads, which would pick up the vibrations more clearly and would be able to handle being struck by a drum stick.

First Assignment

I made a simple little drum beat for my first Max patch.

/First Max Patch