GMU:My Computer, Max, and I/Kaël Skyhawk Hauptmann

From Medien Wiki

First Assignment

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

First Max Patch

Main Project

Project Idea

For my main project I am creating drum set. The drum setup would be to have a kick drum, a snare, a clap, a tom, and a hi-hat. The idea is to install Piezo sensors into different plastic cylinders. When each cylinder is struck it would produce the specific sound that I assigned to that Piezo sensor.

Piezo kael.jpg Cylinder kael.jpg

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. With this test, when I tap on the lid of the container, Arduino would output knock! and the LED light would toggle on/off.

Knock sensor.jpg Knock setup.jpg Knock output.png Knock light.jpg

Creating First Drum Piece

Setting Up Arduino Hardware

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

Kael arduino setup1 1.jpg Kael arduino setup1 2.jpg

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:

Kael arduino piezo.jpg Kael arduino output.jpg

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

Max 1.jpg Max 2.jpg

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.

Kael arduino 2 sensor 1.jpeg Kael arduino 2 sensor 2.jpeg Arduino 2 kit.png Arduino output 2.png

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.

Max 2 drum.png

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.

Arduino 3 drum 1.png Arduino 3 drum 2.png

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.

Max 3 drum.png


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.

Arduino 4 drum 1.png Arduino 4 drum 2.png Arduino 4 drum 3.png

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.

Max 4 drum.png


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.

Arduino 5 drum 1.png Arduino 5 drum 2.png Arduino 5 drum 3.png Arduino 5 drum 3.png

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.

Max 5 drum.png


Here is the coding for Arduino and Max/MSP:

Arduino 5 Drum Piece

Max 5 Drum Piece

Final Result

Arduino final.jpg Breadboard final.jpg

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. 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 negated 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.

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