14 March 2021

Scaffolding: NIME - Da Funk Box

 

 For my NIME, I decided to create a tribute to one of my all-time favorite musical acts, Daft Punk, who sadly broke up earlier this year. As a tribute, the purpose of the box is to play one of their old classics, Da Funk.

My conceptual model for the NIME was to have different parts of the song playing so that users can either recreate the song in it's entirety, or remix it to their liking. Their are three different inputs: the left button plays the main melody of the song, the right button plays the secondary melody that plays in the middle of the song, and the potentiometer controls the position of the lit neopixel on the CPE, so that users can emulate the same kind of light shows that can be seen from Daft Punk concerts. How it does this is that the potentiometer is mapped nearly 1:1 to the number of neopixels on the board. When the user moves the potentiometer, they change which neopixel is lit. A servo inside the box acts as an acoustic backing beat to the song that stops moving when either of the buttons are pressed.

To signify what each of the inputs do, I added a description of their inputs on the box, stating that the left button will play the main melody and the right button will play the secondary melody. The potentiometer was simple labled as "Light Show" to show that it can be used to make the neopixels on the CPE dance.

I believe this to be a quality tribute, but do you know of a better way that this song, or any song, can be emulated better with a NIME?

// Scaffolding - NIME
// Da Funk Box
// By Austin Acosta
// For DIG 3602

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

// These variables are used to control the servo
Servo myServo;
int pos = 0;
unsigned long previousMillis = 0;
const long interval = 750;

// This is used to store the position of the pontetiometer
int potenNum = 0;

void setup() {
  CircuitPlayground.begin();

  myServo.attach(A3); // Attaches the servo to pin A3 to the servo object

  intro(); // Plays the intro sequence
}

void loop() {
  // Both buttons are used to play different melodies from 'Da Funk' by Daft Punk
  // firstPart is the main melody, secondPart is the secondary melody
  if (CircuitPlayground.leftButton()) {
    firstPart();  
  }
 
  if (CircuitPlayground.rightButton()) {
    secondPart();  
  }

//===============================================================//
  // This is for the servo to provide a backing beat. It changes positions every 3/4 of a second.
  // I am using millis for the servo so it does not conflict with the potentiometer 'light show'.
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    if(pos == 0) {
      pos += 180;
      myServo.write(pos);
    }
    else if(pos == 180) {
      pos -= 180;
      myServo.write(pos);
    }
  }

//===============================================================//
  // The potentiometer is attahced to pin A1
  potenNum = analogRead(A1);

  // The position of the potentiometer is mapped to the positon of the neopixel.
  // It goes to 10 to ensure that the 9th neopixel is lit up as much as it can.
  potenNum = map(potenNum, 0, 1023, 0, 10);

  // If the potenNum is less than or equal to 4, activate that specific neopixel and turn it silver, than clear it
  if (potenNum <= 4) {
    CircuitPlayground.setPixelColor(potenNum, 0xC0C0C0);
    CircuitPlayground.clearPixels();
  }
  // If the potenNum is greater than or equal to 5, activate that specific neopixel and turn it gold, than clear it
  else if (potenNum >= 5) {
    CircuitPlayground.setPixelColor(potenNum, 0xFFD700);
    CircuitPlayground.clearPixels();
  }
}

//===============================================================//
// The intro sequence; plays the main melody while all the neopixels turn silver and gold, then clears it
void intro() {
  CircuitPlayground.setPixelColor(0, 0xC0C0C0);
  CircuitPlayground.setPixelColor(1, 0xC0C0C0);
  CircuitPlayground.setPixelColor(2, 0xC0C0C0);
  CircuitPlayground.setPixelColor(3, 0xC0C0C0);
  CircuitPlayground.setPixelColor(4, 0xC0C0C0);

  CircuitPlayground.setPixelColor(5, 0xFFD700);
  CircuitPlayground.setPixelColor(6, 0xFFD700);
  CircuitPlayground.setPixelColor(7, 0xFFD700);
  CircuitPlayground.setPixelColor(8, 0xFFD700);
  CircuitPlayground.setPixelColor(9, 0xFFD700);
 
  CircuitPlayground.playTone(784, 1000, false);
  CircuitPlayground.playTone(698, 250, false);
  CircuitPlayground.playTone(784, 250, false);
  CircuitPlayground.playTone(932, 250, false);
  CircuitPlayground.playTone(294, 1000, false);
  CircuitPlayground.playTone(262, 250, false);
  CircuitPlayground.playTone(294, 250, false);
  CircuitPlayground.playTone(698, 250, false);
  CircuitPlayground.playTone(233, 1000, false);
  CircuitPlayground.playTone(220, 250, false);
  CircuitPlayground.playTone(233, 250, false);
  CircuitPlayground.playTone(294, 250, false);
  CircuitPlayground.playTone(196, 1000, false);
  CircuitPlayground.playTone(220, 500, false);
  CircuitPlayground.playTone(233, 500, false);

  CircuitPlayground.clearPixels();
}

//===============================================================//
// The main melody; plays the main melody while all the neopixels turn silver and gold, then clears it
void firstPart() {
  CircuitPlayground.setPixelColor(0, 0xC0C0C0);
  CircuitPlayground.setPixelColor(1, 0xC0C0C0);
  CircuitPlayground.setPixelColor(2, 0xC0C0C0);
  CircuitPlayground.setPixelColor(3, 0xC0C0C0);
  CircuitPlayground.setPixelColor(4, 0xC0C0C0);

  CircuitPlayground.setPixelColor(5, 0xFFD700);
  CircuitPlayground.setPixelColor(6, 0xFFD700);
  CircuitPlayground.setPixelColor(7, 0xFFD700);
  CircuitPlayground.setPixelColor(8, 0xFFD700);
  CircuitPlayground.setPixelColor(9, 0xFFD700);
 
  CircuitPlayground.playTone(784, 1000, false);
  CircuitPlayground.playTone(698, 250, false);
  CircuitPlayground.playTone(784, 250, false);
  CircuitPlayground.playTone(932, 250, false);
  CircuitPlayground.playTone(294, 1000, false);
  CircuitPlayground.playTone(262, 250, false);
  CircuitPlayground.playTone(294, 250, false);
  CircuitPlayground.playTone(698, 250, false);
  CircuitPlayground.playTone(233, 1000, false);
  CircuitPlayground.playTone(220, 250, false);
  CircuitPlayground.playTone(233, 250, false);
  CircuitPlayground.playTone(294, 250, false);
  CircuitPlayground.playTone(196, 1000, false);
  CircuitPlayground.playTone(220, 500, false);
  CircuitPlayground.playTone(233, 500, false);

  CircuitPlayground.clearPixels();
}

//===============================================================//
// The secondary melody; plays the secondary melody while all the neopixels turn silver and gold, then clears it
void secondPart() {
  CircuitPlayground.setPixelColor(0, 0xC0C0C0);
  CircuitPlayground.setPixelColor(1, 0xC0C0C0);
  CircuitPlayground.setPixelColor(2, 0xC0C0C0);
  CircuitPlayground.setPixelColor(3, 0xC0C0C0);
  CircuitPlayground.setPixelColor(4, 0xC0C0C0);

  CircuitPlayground.setPixelColor(5, 0xFFD700);
  CircuitPlayground.setPixelColor(6, 0xFFD700);
  CircuitPlayground.setPixelColor(7, 0xFFD700);
  CircuitPlayground.setPixelColor(8, 0xFFD700);
  CircuitPlayground.setPixelColor(9, 0xFFD700);
 
  CircuitPlayground.playTone(196, 250, false);
  CircuitPlayground.playTone(440, 250, false);
  CircuitPlayground.playTone(196, 250, false);
  CircuitPlayground.playTone(175, 250, false);
  CircuitPlayground.playTone(294, 250, false);
  CircuitPlayground.playTone(147, 500, false);
  CircuitPlayground.playTone(196, 250, false);
  CircuitPlayground.playTone(440, 250, false);
  CircuitPlayground.playTone(196, 250, false);
  CircuitPlayground.playTone(175, 250, false);
  CircuitPlayground.playTone(294, 250, false);
  CircuitPlayground.playTone(147, 500, false);

  CircuitPlayground.clearPixels();
}



No comments:

Post a Comment

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