Showing posts with label nime. Show all posts
Showing posts with label nime. Show all posts

20 March 2022

Project: NIME, Team 11

 NIME TEAM 11


For this project, I wanted to create something akin to a piano keyboard. The goal was to play a range of notes with the button and use the instruments attached to the fan on the servo to produce background noise in addition to the notes being played.




So for the notes I chose the main ones from the song Runaway by Kanye West. It features a multitude of E sharps, C sharps, etc. I put those frequencies into an array in the IDE and allowed it to be played in full at the press of a button. I wanted to be able to cycle through them somehow but couldn't exactly figure out the code for that in time so I just settled for the whole range at one click of a button. The servo moves when turning the knob on the potentiometer. As it moves, the bells stringed to it jingle off the board and each other to produce a jingling sound in the background of the notes.



//NIME Project by Justice Anderson & Jared Toavs
//DIG3602C Professor Mosher
#include <Servo.h>
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

//servo 
Servo myServo;
int timer = 0;
int inc = 1;

//potentiometer variables
int potpin = A1;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

//array of notes in the song Runaway by Kanye West
float notes[] = {261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 
261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 261.63, 311.127, 311.127, 311.127,
277.18, 277.18, 466.164, 466.164, 261.63};

void setup() {
  // put your setup code here, to run once:
  CircuitPlayground.begin();
  Serial.begin(9600);
  delay(1000);

  //servo code
  myServo.attach(10); //A3
  pinMode(4, INPUT_PULLDOWN); //left button
  pinMode(5, INPUT_PULLDOWN); //right button
}

void loop() {
  val = analogRead(potpin); // gets the value of the potentiometer 
  val = map(val, 0, 1023, 0, 180); // converts it ton a number usable by the servo
  if(millis() > timer + 15) {
    if(val == 0) inc = 1;
    if(val == 180) inc = -1;
    myServo.write(val); // the servo is set to the stored value from the potentiometer
    val += inc;
    timer = millis();
  }

  
  if(digitalRead(5)) { // checks if button is clicked
  for(int i = 0; i < 23; i++) { // when button is clicked it loops through until it hits 23    CircuitPlayground.playTone(notes[i], 500); // plays the notes in the notes array
    }
  }
}

Do you think the enclosure being better crafted would enhance the experience and would there be a better way of stringing the bells onto the servo fan?


NIME Team 1


 NIME TEAM 1


For the NIME assignment, we wanted to create an instrument that would draw inspiration from the Otamatone, allowing the user to adjust the pitch of the notes and the speed of the server using two separate potentiometers.



Once the right button is pressed, the instrument will begin to play the notes A, G, D, and E repeatedly, and the player will be able to use the first potentiometer to adjust the pitch of the notes to be lower or higher. 

Pressing the left button will turn on the servo, which we used to create an acoustic sound inside of the instrument.

The interior of the NIME

There is a dowel attached to the servo, so the servo will make the dowel tap against the cookie sheet much like a drumstick. We used a cookie sheet in order to produce a metallic sound to match the digital tones produced by the CPB. 

The speed of the dowel is also adjustable based on the second potentiometer. This is possible because of the mapping we used when setting up the potentiometer, using a 1:1 pairing where the potentiometer can affect the digital and analog outputs.

NIME Schematic

The wiring, CPB, and two knobs serve to signify the use of the music box. Feedback is especially noticeable when it comes to the use of the servo, as the dowel will immediately hit the cookie sheet to create the acoustics.

The supports of the NIME interior, allowing for the removal of the
cookie sheet and allowing space for the sheet to reverberate.


//NIME Team 1: Jacqueline Pavlat & Jeffrey Jourdan

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

//Servo-related variables
Servo serv;
int servOn = 0;
int servSpeed = 5;
int pos = 0;
int inc = 1;
int timer = 0;
int sCurrent = 0;
int sPrev = 0;

//Tone-related variables
int playNote = 0;
int pitch = 1;
int bCurrent = 0;
int bPrevious = 0;
float notes[] = {440, 587.33, 659.25, 782.99};


void setup() 
{
  Serial.begin(9600);
  delay(1000);
  CircuitPlayground.begin();

  //PinOuts
  serv.attach(6); //Servo: A1
  pinMode(4, INPUT_PULLDOWN); //Left/A Button
  pinMode(5, INPUT_PULLDOWN); //Right/B Button
  
}

void loop() 
{
  //TONE-RELATED CODE

  
  //Turns on tones on pressing Right/B
  bCurrent = digitalRead(CPLAY_RIGHTBUTTON);
  if(bCurrent == 1 && bPrevious == 0)
   {
      playNote = 1;
   }
   
  //Plays tones
  if(playNote == 1)
  {
    for(int i =0; i < 4; i++)
    {
    CircuitPlayground.playTone(notes[i] + pitch, 250);
    }
  }
  bPrevious = bCurrent; //Updates Check
  //Stops tones
  if(digitalRead(CPLAY_RIGHTBUTTON) && playNote == 1)
  {
    playNote = 0;
  }
  
  //SERVO-RELATED CODE

  
  //Turns on servo on pressing Left/A
  sCurrent = digitalRead(CPLAY_LEFTBUTTON);
  if(sCurrent == 1 && sPrev == 0)
  {
    servOn = 1;
  }
  
  // Makes servo hit cookie sheet and top of box
  if(servOn == 1)
  {
    if(millis() > timer + servSpeed)
    {
      if(pos == 35) inc = 1;
      if(pos == 90) inc = -1;
      serv.write(pos);
      pos += inc;
      timer = millis();
    }
    
  }

  //POTENTIOMETER-RELATED CODE


  //Pitch Potentiometer (Blue/Right)
  pitch = analogRead(A2);
  pitch = map(pitch,1,1023, 1, 260); //Maps pitch to blue potentiometer with high of 1023 & low of 260
  //Tempo Potentiometer (Red/Left)
  servSpeed = analogRead(A3);
  servSpeed = map(servSpeed, 5, 1023, 5, 25); //Maps speed to potentiometer with high of 1023 & low of 25
}


How could we improve the UI or visual signifiers for the music box without the use of labels?





16 March 2021

Scaffolding: Concept Review

ShellShock Live

For the second game, I chose ShellShock Live. A turn based tank, deathmatch game where players or teams of players shoot different special rounds from their tanks to try to destroy the enemy team first. The game uses a mixture of mouse movement and key presses to try and line up shots to try and destroy enemy tanks. It can get difficult to accurately land hits due to limits with mouse and key sensitivity so I'd like to create a new controller specifically for the game that would make it easier to aim and control power. The controllers I want to make would simplify gameplay with more adaptive controls.

https://store.steampowered.com/app/326460/ShellShock_Live/









15 March 2021

Project NIME: GURVIN BOX

 


Hello, my name is Christopher Flango, and this is my son, Gurvin, a music box. as you can see from the labels, this top button controls a servo, which is good for backing beats in your most recent SoundCloud mixtape. This effect is created by attached a quarter of a roll of scotch tape to the servo motor and a ball, which when activated causes the ball to repeatedly bash against the cardboard walls in a rhythmic fashion. This other button, labelled music, controls the song, an original piece I call "Wings Upon the Precipice of Dawn Mark 2". Originally this was to be a meme song, in the vein of "Chug Jug With You" but after an hour of struggling to get it working, I accidentally created the song you hear instead and thought that it sounded pretty good. You'll notice that there's no potentiometer, due to technical difficulties in getting it to run properly without messing up the functions of the other settings. Originally, I wanted to include it as a means to control an LED on the box, but after failing to get it working, I scrapped that and covered up the hole where the LED was supposed to go. I thought the music would be the hardest part of this, as I have no background in making it, but honestly that was easiest part of this. In the future, I’ll have to allow myself more time to create the code to get everything functioning properly. How should I have gone about implementing the potentiometer?

 

#include <Servo.h>

#include <Adafruit_CircuitPlayground.h>

#include <Adafruit_Circuit_Playground.h>



//Created bt Christopher Flango

 //Servo variables
Servo GurvinWeapon;
int pol = 0;



void setup() {

  // put your setup code here, to run once:

  GurvinWeapon.attach(A3);


  pinMode(A4, INPUT);

  delay(1000);

}

 

void loop()

{
  //this controls the button for the music
if (digitalRead(CPLAY_RIGHTBUTTON))

  {

    CircuitPlayground.playTone(200, 300);

    CircuitPlayground.playTone(600, 200);

    CircuitPlayground.playTone(600, 100);

    CircuitPlayground.playTone(400, 400);

    CircuitPlayground.playTone(600, 300);

    CircuitPlayground.playTone(600, 200);

    CircuitPlayground.playTone(400, 100);

    CircuitPlayground.playTone(300, 400);

  }

//this controls the button for the servo
if (digitalRead(CPLAY_LEFTBUTTON))
  {
//these control the propellor blades on the server
    GurvinWeapon.write(95);

    delay(100);

    GurvinWeapon.write(10);

    delay(100);

  }

}




 

Project: NIME







For this project, I was inspired by the movie, The Little Prince and thought of an idea to implement some of the key features to this music box/ instrument for the overall theme for this project. 

I wanted to have a centerpiece, much like a traditional music box, so I created the rose from the film and attached it to the servo and have it spin back and forth. I also attached a male connection wire to the servo in order to create audio from the metal tips scratching on the cardboard box as it spins.  


I wanted the user to control the pitch coming from the CPE, so I attached the potentiometer to the LED in order for the user to dim and raise the brightness. In turn, the light sensor detects the brightness and changes the pitch accordingly. The brighter the light, the higher the pitch and vice versa. This is activated when the switch on the CPE is turned on. To achieve this I used the map function for the light and audio values.

I also programmed the right button to play the theme song from The Little Prince and it turns off once the melody is completed.


Question: I would like feedback on my code. Am I missing anything or is there any feedback in regards to that.



CODE:

//NIME:music box/instrument code by Nadia Al-Ghamdi

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

    Servo myServo; //Controls servo

//variables
    int pos = 0;
    int inc = 1;
    int timer = 0;


void setup(){
   Serial.begin(9600);
   delay(1000);
   CircuitPlayground.begin();   
   myServo.attach(10); //A3
   pinMode(13, OUTPUT);
   pinMode(4,INPUT_PULLDOWN);  
   }
 
void loop(){
 
   if(millis() > timer + 15){
   if(pos == 0) inc = 1;
   if(pos == 180) inc = -1;
     myServo.write(pos);
     pos += inc;
     timer = millis();
   }
   digitalWrite(13,digitalRead(4));

  //adjust sound pitch depending on light brightness
   uint16_t value, sound;
   if(CircuitPlayground.slideSwitch()) {      //   switch on
     value = CircuitPlayground.lightSensor(); //   light sensor
     sound = map(value, 5, 100, 500, 5000);  //    light and audio values
     CircuitPlayground.playTone(sound, 250);  
   }

//Theme song for The Little Prince if right button is pressed
   if (CircuitPlayground.rightButton()) {
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(330, 300);
  CircuitPlayground.playTone(350, 300); 
  CircuitPlayground.playTone(390, 300); 
  CircuitPlayground.playTone(440, 300);
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(490, 300);
  CircuitPlayground.playTone(525, 400);
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(290, 200);
  CircuitPlayground.playTone(292, 200);
  CircuitPlayground.playTone(440, 300);
  CircuitPlayground.playTone(390, 300); 
  CircuitPlayground.playTone(350, 300); 
  CircuitPlayground.playTone(330, 300);
  }
   
   
   
}







NIME Box

 

    The design of this project was based around the idea of creating interesting tones and contrasting them with noises made by some bells moved by the servo. The circuit is activated by a switch and the servo moves back and forth, swinging two bells and hitting them against a ceramic plate. There is a physical switch tied to a light sensor that activates a tone. The user can then use a potentiometer to change the pitch of that tone.

    When mapping the inputs, I took the full range of values of the potentiometer and mapped them onto the range of 440 to 1760. This created a nice range of sounds that the speaker could create, without going too high pitched or too low pitched. I think the interactive elements in this instrument are very noticeable to the user and encourage experimentation. The physical bar that activates the light sensor is only interactable in one way, so the user is only given one option for using it, making it simple to understand. The feedback is instantaneous and clear. You can see that the instrument is active by the movement of the servo and bells. And the tone coming from the speakers and the pitch changing are very responsive.

    Do you think there is too much discord between the sound of the bells and the speaker’s tone?





//Chris Tillis

//Project NIME

//libraries

#include <Servo.h>

#include <Adafruit_CircuitPlayground.h>

#include <Adafruit_Circuit_Playground.h>

#include <math.h>


  //Global Variables (Servo is here)

Servo myServo;

int thresh = 5;

int pos = 0;

int inc = 1;

int pitch;


void setup() {

      // put your setup code here, to run once:

    Serial.begin(9600);

    delay(1000);

    CircuitPlayground.begin();

    myServo.attach(10);

    pinMode(13, OUTPUT);

    pinMode(4, INPUT_PULLDOWN);

}

void loop() {


    //Loop only runs while the switch is active

  if(CircuitPlayground.slideSwitch()){


      //The servo moves to its first position

    myServo.write(0);

      //The potentiator is read to get the pitch value. Note is only played under a certain light level

    pitch = map(analogRead(A6), 1, 1023, 440, 1760);

      if(CircuitPlayground.lightSensor()<thresh)

        CircuitPlayground.playTone(pitch, 400);

      else

        delay(800);


      //The servo moves to its second position  

    myServo.write(180);

      //Second potentiator check just to make the notes play in both servo states

    pitch = map(analogRead(A6), 1, 1023, 440, 1760);

      if(CircuitPlayground.lightSensor()<thresh)

        CircuitPlayground.playTone(pitch, 400);

      else

        delay(800);

  }  

}


NIME Music Box



 




My Music box uses a white cardboard box with the Circuit Playground Express located on the top as well as a single potentiometer. The potentiometer is used to control the pitch of the two buttons on the CPE labelled D4 and D4. Audio is played through the speaker on the CPE. Inside the box is a 5v battery connected to a JBtek Breadboard Power Supply Module (3.3V/5V) which is nested in the breadboard. There is also torn pieces of thin paper surrounding and above a Servo motor with arm attachment for the purpose of generating more sound as the Servo's arm turns the snippets of paper. Unfortunately this sound isn't easily heard in the video. 
The rest of the components are wires, alligator clips, and a mix of duct and scotch tape. The idea for the conceptual model was creating a music box similar to Otamatone (オタマトーン) which is an electronic synthesizer with limited sound. This music box, while not as simple as the Otamatone, has a wider range of sounds available and has the inclusion of additional sound provided by the servo arms and paper. The input and output mapping are simple. The user presses one of the two labeled buttons on the CPE and twists the labeled pitch adjustment (the potentiometer). The output is sounds of varying pitches depending on the button pressed and the degree the dial on the potentiometer is turned to. While not captured in the video recording, the words "Sound Buttons" and "[Pitch] Twist, as well as arrows pointing to their respective control methods, serve as readable signifiers to the user. The feedback comes in the form of sound and changing pitch from the speaker.
Question for peer review feedback: Do you think it would have been possible to generate more noise from the paper and servo? I felt that this was the area that could use the most improvement.


// NIME 
// DIG 3602

#include <Servo.h>
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
Servo myServo;
int pos = 0;
int inc = 1;
int timer = 0;
int potenNum = 0;
int potenMap = 0;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  delay(1000);
  CircuitPlayground.begin();
  myServo.attach(10);
  pinMode(13, OUTPUT);
  pinMode(4, INPUT_PULLDOWN); // sets left button
  pinMode(5, INPUT_PULLDOWN); // sets right button
}
void loop() {
  //put your main code here, to run repeatedly:
  if (millis() > timer + 15) {
    if (pos == 0) inc = 1;
    if (pos == 180) inc = -1;
    myServo.write(pos);
    pos += inc;
    timer = millis();
  }
  potenNum = analogRead(A1);
  Serial.print(potenNum);
  // The position of the potentiometer is mapped to a value to alter the tone
  potenMap = map(potenNum, 0, 1023, 0, 200);
  // Left button pressed play beat 1
  if (digitalRead(4)) {
    left(potenMap);
  }
  // Right Button pressed play beat 2
  if (digitalRead(5)) {
    right(potenMap);
  }
}
// Play tone when left button is pressed
// Custom sound tone based off the position of the potentiometer
void left(int potenMap) {
CircuitPlayground.playTone(700-potenMap,200);
}
// Play tone when right button is pressed
// Custom sound tone based off the position of the potentiometer
void right(int potenMap) {
  CircuitPlayground.playTone(400-potenMap,200);
}

 


14 March 2021

LoZ Music Empanada Box

 



My music box currently plays Minuet of Forest from The Legend of Zelda: Ocarina of Time. I really struggled in this project with the coding aspect, learning a lot of new methods. I ended up using a simple song I enjoyed and employed it through tones basically overwriting the previous tone in the playground express. For the box, I actually had trouble finding a box that wasn't being used in my household so I went out and bought some empanadas and emptied the box out.



CODE:


 //* Nicholas Suarez
 //* NIME Music Box Project


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

//variables 
//Servo
Servo myServo;
int pos = 0; 
int inc = 1; 

//potentiometer
const int potent = A1; //Potentiometer connected
const int valueThreshold = 500;
int sensorValue = 0; //Value from potentiometer
int mappedPotent = 0;

//Check to see if song is playing
bool playSong = false; 

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  CircuitPlayground.begin();
  
  //Servo Stuff
  delay (1000);
  myServo.attach(10); //10 = A3
  pinMode(13, OUTPUT);
  pinMode(4, INPUT_PULLDOWN);
            }

void loop() {
    
  // put your main code here yadda yadda

  //press left button to start song
  if(CircuitPlayground.leftButton()) {   // checking if left button is true blue
    playSong = true;
    PlaySong();
  }
  //Hold right button down to stop Servo's off-tempo precussion
  else if(CircuitPlayground.rightButton()) { // checking if right button is true blue
    if (pos == 0) inc = 1;
    if (pos == 180) inc = -1;
    myServo.write (pos);
    pos += inc;
    delay(sensorValue);
    //delay(15);
    digitalWrite(13, digitalRead(4)); 
  } 

//control which direction of Servo based on what Potentiometer does
  sensorValue = analogRead(potent);
  if (sensorValue > valueThreshold)
  {
    myServo.write(90); }
    else
    {myServo.write(0);}

}  

void PlaySong()
{
  if (playSong == true)
  {
  CircuitPlayground.playTone(500,150);
    CircuitPlayground.playTone(1200,150);
    CircuitPlayground.playTone(1000,500);
    delay(200);
    CircuitPlayground.playTone(900,150);
    CircuitPlayground.playTone(1000,150);
    CircuitPlayground.playTone(900,600);
  }

  playSong = false;
}


NIME: The Potato Instrument

A little naked but that's okay
 

The Potato Instrument functions very similarly to how a piano(?) would function. Tap a key (which in this case was a potato) and it would play a note that was coded in. The original intention for this was to play a note based on a button press using the pins that were being touched as a note adjuster, very similarly to a guitar or violin. Unfortunately, this was a little out of my element, and I decided with simple keys and did out with the button. The enclosure was going to be a box that had holes for each specific potato, but due to some issues the box was scrapped unfortunately. So essentially, when a potato is touched, a key plays. That is really as simple as it gets. The current potatos are attached to A3, A4, and A5 and play G, A, and B respectively on the 4th octave. To assure that the user would be exerting enough pressure to actually trigger a sound, a neopixel would turn on. Although the feedback itself should just be the sound coming out of the CPE, I found having a light turn on also told the user which specific key they were playing. If they somehow accidentally triggered another potato, we would know. The servo is playing all the time, it was originally intended to be a beat counter but I felt that the noise it made helped out as shown in the video below. Please excuse the cat.

Video Demonstration


 

Schematic (as shown)

Code

 #include <Servo.h>
#include <Adafruit_CircuitPlayground.h>
#include "pitches.h" //borrows a library of pitches from an adafruit tutorial
     
int thresh =900; //pressure needed to activate keys

Servo myServo;

uint8_t keys[]={A2,A3,A4,A5,A6,A7}; //setting up the keys

int noteToPlay = NOTE_D4;//default note to play
int noteDuration=250; //note length

void setup() {
  Serial.begin(9600);
  delay(1000);
  CircuitPlayground.begin();
  myServo.attach(6); //A1 -- attaches servo
 
}


boolean touched (int t){ //boolean to check if pins have met the threshhold or not
  if (t<thresh){
    return true;
  } else{
    return false;
  }
}

void loop(){
  for (int p=A2; p<=A7; p++) {
Serial.println(CircuitPlayground.readCap(A4));
if(touched(CircuitPlayground.readCap(p)))
{  
  CircuitPlayground.setPixelColor(p-14,0,0,0);
}
else{
  CircuitPlayground.setPixelColor(p-14,0,0,30); //neopixel feedback/decides which sound is played based on which pin is touched
      switch(p){
    //case A1:noteToPlay=NOTE_E4;
   // break;
    case A2:noteToPlay=NOTE_FS4;
    break;
    case A3:noteToPlay=NOTE_G4;
    break;
    case A4:noteToPlay=NOTE_A4;
    break;
    case A5:noteToPlay=NOTE_B4;
    break;
    case A6:noteToPlay=NOTE_C5;
    break;
    case A7:noteToPlay=NOTE_D5;
    break;

    default:noteToPlay=NOTE_D4;    
  }
  CircuitPlayground.playTone(noteToPlay,noteDuration);
}

}
  noteToPlay=NOTE_D4; //at the end of every loop, the note returns to the default note


}