L2 – Dohan Yucht Cheong Saha

Team Members:

  • Andrew Cheong (acheong@)
  • David Dohan (ddohan@)
  • Shubhro Saha (saha@)
  • Miles Yucht (myucht@)

Group Number: 21

Description

For our project, we built an instrument that allows a person to conduct the tempo of a piece of music by walking. The primary components of the instrument are piezos attached to each foot and two buzzers. Taking a step moves the song along to the next note, and each song can have both a bass and treble part play simultaneously. We built this project because we like the idea of being able to control existing music through motion. We are pleased overall with the final product because it works as we envisioned it and is actually pretty fun to use. There are a number of possible improvements that we would like to add, including the ability to change to different songs and read music from arbitrary midi files. Additionally, the device is somewhat difficult to attach to your body: perhaps this could be made more portable by the use of a piezo sensor integrated into your shoes (along with a battery pack for the Arduino). We are also limited to songs which change on each tap of the foot, as opposed to songs that might have several pitches play per beat. Other possibilities would be to synthesize the sound using processing or use a similar interface to create music (e.g. a different drum for each foot) as opposed to controlling existing music.

Prototypes

Before building out final product, we built three separate prototypes, with the third leading to our final product.

Instrument 1 – Conducting a Choir

When building our first prototype, we set out to be able to control the volume and pitch of a song by raising and lowering our hands (as if conducting a musical group). While the final result worked, it did not perform as well as we had hoped. The main issue with the instrument is that it is difficult to properly estimate changes in position from the accelerometer (although it naturally works very well for detecting actual accelerations).

Instrument 2 – Anger Management

We liked the idea of using the force of a knock on a piezo to control sound. In this project, hitting your computer results in it playing sound back at you that corresponds to how hard you hit it.

Instrument 3 – Walking Conductor

This prototype is the core of our final instrument and is composed of piezos attached to each foot and a beeper. Knocks (e.g. steps) on the piezos trigger the next note in a melody to play.

 

Final Instrument

We decided to modify the walking conductor instrument to allow multiple parts to play at once. The control mechanism remained the same, but the addition of a second beeper allows us to play a bass part at the same time as the melody.

Parts list:

  • 2 piezo elements
  • 2 beepers
  • 2 rotary potentiometers
  • 2 1-megaohm resistors
  • 1 Arduino Uno
  • 4+ alligator clip cables
  • Electrical tape

Assembly Instructions:

  1. On a breadboard, connect one end of one resistor to analog pin A0 and the other end to ground. Connect one end of other resistor to analog pin A1 and the other end to ground.
  2. Connect one piezo element in parallel with each resistor, attaching it to the breadboard using the alligator clip cables.
  3. On a breadboard, connect pin 1 of one potentiometer to digital pin 3, pin 2 to one beeper, and pin 3 to ground. Connect pin 1 of the other potentiometer to digital pin 6, pin 2 to the other beeper, and pin 3 to ground.
  4. Connect the other pins on each beeper to ground.
  5. Attach the piezo elements to your shoes using electrical tape.
  6. Run around to your favorite song!

Source Code Instructions:

  1. This code makes use of the “Arduino Tone Library” which allows one to play multiple notes simultaneously using the arduino. It is required to run our code, so download it using the link above. The library comes from the Rogue Robotics project.
  2. Download our code below, and begin controlling Thus Spoke Zarathustra as you walk! Different music can be played by replacing the trebleNotes and bassNotes arrays with different note sequences.

Code:

/*
 * COS 436 Lab 2: Sensor Playground
 * Author: Miles Yucht, David Dohan
 * Plays "Thus Spoke Zarathustra" by Richard Strauss on beats measured by piezo elements.
 */
#include "pitches.h"
#include "Tone.h"
#ifdef REST
# undef REST
#endif
#define REST -1

Tone bassTone;
Tone trebleTone;

int treblePin = 3;
int bassPin = 6;
int piezoPin1 = A0;
int piezoPin2 = A1;

int threshold = 50;

int currentNote = 0;

int pauseTime = 100;

//melody to Thus Spoke Zarathustra
int trebleNotes[] = {NOTE_C4, NOTE_G4, NOTE_C5, REST, NOTE_E5, NOTE_DS5, REST, REST, REST, REST, REST, REST, REST, REST, REST, REST, REST, REST, 
    NOTE_C4, NOTE_G4, NOTE_C5, REST, NOTE_DS5, NOTE_E5, REST, REST, REST, REST, REST, REST, REST, REST, REST, REST, REST, REST, NOTE_C4, NOTE_G4,
    NOTE_C5, REST, NOTE_E4, NOTE_A4, NOTE_A4, NOTE_B4, NOTE_C5, NOTE_D5, NOTE_E5,
    NOTE_F5, NOTE_G5, NOTE_G5, NOTE_G5, NOTE_E5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_B5, NOTE_C6, REST};

//bassline to Thus Spoke Zarathustra
int bassNotes[] = {NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_C4, NOTE_G3, 
NOTE_C4, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_C4, NOTE_G3, 
NOTE_C4, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_C4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_C4, NOTE_C4, NOTE_G4, NOTE_E4,
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_E3, NOTE_A3, NOTE_G3, NOTE_C4, REST};

void waitForKnock() {
  int sense1, sense2;  
  while (true) {
      sense1 = analogRead(piezoPin1);
      sense2 = analogRead(piezoPin2);
      if (sense1 > threshold || sense2 > threshold)
        break;
      /*
      Serial.print(threshold - sense1);
      Serial.print(", ");
      Serial.println(threshold - sense2);
      */
    }
    /*
    Serial.println(sense1);
    Serial.println(sense2);
    */
}

void playTone(Tone tone, int notes[]) {
  if (notes[currentNote] == REST)
    tone.stop();
  else
    tone.play(notes[currentNote]);
}

void playNextNote() {
  if (currentNote <= 57) {
    playTone(trebleTone, trebleNotes);
    playTone(bassTone, bassNotes);
  } else
    currentNote = -1;
  currentNote++;
}

void setup() {
  bassTone.begin(3);
  trebleTone.begin(6);
  /*
  Serial.begin(9600);
  */
}

void loop() {
    waitForKnock();
    playNextNote();
    delay(pauseTime);
}