teaching machines

Clickaphone

December 26, 2017 by . Filed under music, public.

This summer I’ll be helping high schoolers make musical instruments in a three-week long summer camp. This is how we’re describing the camp:

Randomly pick a technology. Chances are that technology is either used to automate or to entertain. But computers are not just appliances for making our lives easier. Because they are programmable, we can turn them into instruments of creative expression.

In this course, we will turn computers into instruments—musical ones—with some help from Arduinos and electronic components like switches, potentiometers, and other sensors. We’ll investigate how to turn a musician’s interactions with our custom hardware into sound effects and music. Building off of a foundation of physical laws, mathematics, and music theory, we’ll mimic existing instruments and generate new ones that no ear has ever heard before.

I’ve always liked music more than it has liked me. Maintaining a rhythm is an awkward exercise for self-conscious me, and I often joke that I can’t even chew bubble gum properly. In school band, I struggled with my embouchure on the trumpet. Any note above a C lived in a celestial plane that I could never hope to attain. However, I’ve had reasonable success doing in the digital world what I haven’t done well in the analog world. So here goes. Let’s make some instruments.

Ultimately, our instruments need to sense the musician and react by synthesizing sound. The very simplest place to start is with a button that the musician can press. We’ll use several tools for reading the input and synthesizing the sound. One of them will be Pure Data. This minimal setup leads us to our first instrument, which I call the clickaphone:

Here’s the Arduino sketch:

#include <Arduino.h>

const int BUTTON = 7;
int old_value = 0;

void setup() {
  pinMode(BUTTON, INPUT);
  Serial.begin(9600);
}

void loop() {
  int new_value = digitalRead(BUTTON);
  
  if (old_value != new_value) {
    if (new_value) {
      Serial.write(10);
    } else {
      Serial.write(0);
    }
    old_value = new_value;
    delay(10);
  }
}