20 March 2022

NIME Project Ian Smith



 

This project is a musical instrument that can play a 5-note scale over four different octaves. It also has a percussive element to it in the form of a servo. The goal of this project was to create something that could feasibly be used as an outright instrument. The main thing that I took inspiration from was the release of a new flavor of Coca-Cola called Starlight. I thought it would be an interesting concept to try and create a sound that could mirror the idea of communicating beyond the stars. For that reason, I thought that both housing the project inside of a box of this product and using the potentiometer to change the tempo would be fitting.

The original concept included using tinfoil to convey that space-age theming, however, I found that utilizing the tinfoil on all of the pads was a lot more unmanageable than I had anticipated, for this reason it now relies on direct contact with the pads. The servo is positioned on the top of the enclosure with attached tinfoil, so that I could still keep that bit in, in order to replicate something akin to an antenna moving around.

Finally, the actual audio output of the project provides for a few unique setups. My personal favorite is setting the tempo to high and activating multiple notes. This creates an arpeggiator-like sound.



#include <Adafruit_Circuit_Playground.h>
#include <Servo.h>
#include <Adafruit_CircuitPlayground.h>

//Ian Smith NIME Project

//Here I am creating integers to house position and increment for the Servo.
Servo myServo;
int pos = 0;
int inc = 1;

//This creates an array of notes in our 5-note scale and also creates an array to house our Octave modiffiers.
float notes[] = {65.41, 73.42, 82.41, 87.31, 98.00};
float octaveModifiers[] = {1.0, 2.0, 4.0, 6.0};


int i = 0;;
int octaveTier = 0;
int tempo = 0;

void setup()
{
  CircuitPlayground.begin();
  Serial.begin(9600);
  delay(5000);
  //Attaching the servo to D0.
  myServo.attach(0);

  pinMode(4, INPUT_PULLDOWN);
  pinMode(5, INPUT_PULLDOWN);

}

void loop()
{
  //Reading the potentiometer into the variable potRead.
  int potRead  = analogRead(7);

  //These integers get the analog value of their respective capacitive touch pads.
  int c = CircuitPlayground.readCap(A1);
  int d = CircuitPlayground.readCap(A2);
  int e = CircuitPlayground.readCap(A3);
  int f = CircuitPlayground.readCap(A4);
  int g = CircuitPlayground.readCap(A5);

  if (pos == 0) inc = 90;
  if (pos == 180) inc = -90;
  myServo.write(pos);
  pos += inc;

//Increments the octave modifier if it has not reached it's max value.
  if (digitalRead(4) && octaveTier < 3)
  {
    octaveTier++;
    delay(300);
  }

//Decrements the octave modifier if it has not reached it's min value.
  if (digitalRead(5) && octaveTier > 0)
  {
    octaveTier--;
    delay(300);
  }

//These are check the touch pads and playing their respective letter note in turn.
  if (c > 600)
  {
    i = 0;
    CircuitPlayground.playTone(notes[i]*octaveModifiers[octaveTier], tempo, false);
  }

  if (d > 600)
  {
    i = 1;
    CircuitPlayground.playTone(notes[i]*octaveModifiers[octaveTier], tempo, false);
  }

  if (e > 600)
  {
    i = 2;
    CircuitPlayground.playTone(notes[i]*octaveModifiers[octaveTier], tempo, false);
  }

  if (f > 600)
  {
    i = 3;
    CircuitPlayground.playTone(notes[i]*octaveModifiers[octaveTier], tempo, false);
  }

  if (g > 600)
  {
    i = 4;
    CircuitPlayground.playTone(notes[i]*octaveModifiers[octaveTier], tempo, false);
  }

//This takes the potRead from above and checks it in order to set the tempos from a low of 100 to a max of 1000.
  if (potRead >= 0 && potRead <= 100)
  {
    tempo = 100;
  }

  if (potRead >= 101 && potRead <= 200)
  {
    tempo = 200;
  }

  if (potRead >= 201 && potRead <= 300)
  {
    tempo = 300;
  }

  if (potRead >= 301 && potRead <= 400)
  {
    tempo = 400;
  }

  if (potRead >= 401 && potRead <= 500)
  {
    tempo = 500;
  }

  if (potRead >= 501 && potRead <= 600)
  {
    tempo = 600;
  }

  if (potRead >= 601 && potRead <= 700)
  {
    tempo = 700;
  }

  if (potRead >= 701 && potRead <= 800)
  {
    tempo = 800;
  }

  if (potRead >= 801 && potRead <= 900)
  {
    tempo = 900;
  }

  if (potRead >= 901 && potRead <= 1023)
  {
    tempo = 1000;
  }
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.