@Shuai_nyu @Tim Chen @Beatrice Mai

Complete Works: Table Top Shakespeare - Forced Entertainment

image.png

image.png

image.png

Currently Piano

Delay——

Tinking

how to catch the reaction of audience?

Camera? face catch

Some little experiments

using press sensor to control the speaker play music or specific melody

IMG_0030.jpeg

IMG_0033.mov

IMG_0032.mov

// 定义扬声器引脚
int speakerPin = 9;
int pressPin = A0;
int value = 0;
bool whetherPlay = false;

int melody[] = {
  131, 131, 196, 196, 220, 220, 196,  // C2 C2 G2 G2 A2 A2 G2
  175, 175, 165, 165, 147, 147, 131   // F2 F2 E2 E2 D2 D2 C2
};

// 定义音符的时长(节拍)
int noteDurations[] = {
   392, 440, 494, 392, 494, 440, 392,      // G A B G B A G
  523, 494, 440, 494, 523, 587, 523,      // C5 B A B C5 D C5
  440, 392, 349, 392, 440, 523, 494,      // A G F G A C5 B
  392, 440, 494, 392, 440, 523, 494       // G A B G A C5 B
};

// Happy Song
int melody2[] = {
   392, 392, 440, 494, 523, 494, 440, 392, 440, 494, 523, 587, 523, 494,   // G G A B C B A G A B C D C B
  440, 523, 494, 440, 392, 349, 392, 349, 330, 349, 392, 440, 392, 349,   // A C B A G F G F E F G A G F
  392, 440, 494, 523, 587, 523, 494, 440, 494, 523, 587, 523, 494, 440,   // G A B C D C B A B C D C B A
  392, 440, 494, 523, 587, 523, 494, 440, 392    
};

// 音符的时长(节拍)
int noteDuration2[] = {
   250, 250, 250, 250, 500, 250, 250, 500, 250, 250, 250, 500, 250, 500,  // G G A B C B A G A B C D C B
  250, 250, 250, 250, 500, 250, 250, 500, 250, 250, 250, 500, 250, 500,  // A C B A G F G F E F G A G F
  250, 250, 250, 250, 500, 250, 250, 500, 250, 250, 250, 500, 250, 500,  // G A B C D C B A B C D C B A
  250, 250, 250, 250, 500, 250, 250, 500, 1000                      
};

//China
int melody3[] = {
   330, 392, 440, 494, 440, 392, 330, 294,  // E G A B A G E D
  330, 392, 440, 494, 440, 392, 330, 294,  // E G A B A G E D
  494, 523, 587, 659, 587, 523, 494, 440,  // B C D E D C B A
  392, 440, 494, 440, 392, 370, 330        // G A B A G F# E
};

// 音符的时长(节拍)
int noteDuration3[] = {
 500, 500, 500, 500, 500, 500, 500, 500,  // E G A B A G E D
  500, 500, 500, 500, 500, 500, 500, 500,  // E G A B A G E D
  500, 500, 500, 500, 500, 500, 500, 500,  // B C D E D C B A
  500, 500, 500, 500, 500, 500, 1000       // G A B A G F# E
};

// 初始化节奏数组,单位为毫秒
int rhythm[] = { 500, 300, 800, 400, 600, 200 };     // 每个元素代表音符的持续时间
int frequency[] = { 440, 494, 523, 587, 659, 698 };  // 不同频率的音调

// 节奏数组的长度
int rhythmLength = sizeof(rhythm) / sizeof(rhythm[0]);

void setup() {

  Serial.begin(9600);
}

void loop() {
  value = analogRead(pressPin);
  if(value > 3)
  {
    whetherPlay = true;
  }
  else
  {
    whetherPlay = false;
  }
  Serial.println(value);
  delay(50);
  //tone(speakerPin, value * 50, 50);

  //little star
  if (whetherPlay) {
    for (int i = 0; i < 14; i++) {
      int noteDuration = noteDurations[i];
      tone(speakerPin, melody2[i], noteDuration2);
      delay(noteDuration * 1.3);  // 间隔时间
    }
  }
  // for (int i = 0; i < rhythmLength; i++) {
  //   // 发出频率为frequency[i] Hz的音调,持续时间为rhythm[i]毫秒
  //   tone(speakerPin, frequency[i], rhythm[i]);

  //   // 等待当前音符结束,并加上少许间隔
  //   delay(rhythm[i] + 100); // 100 毫秒的间隔
  // }
}

Zombie vs. Plants Theme Song (植物大战僵尸主题曲) Source: https://www.tiktok.com/@elictri1/video/7270311361287081222

Manually written notes + rhythm:

#include "pitches.h"

int speakerPin = 8;
int pressPin1 = A0;  // FSR1 Pin
int pressPin2 = A1;  // FSR2 Pin
int value1 = 0;      // FSR1 Value
int value2 = 0;      // FSR2 Value
bool whetherPlay = false;
float s;             // Speed factor

int melodyZ[] = {
  554, 587, 554, 587, 466, 392, 466, 392, 587, 392,
  554, 587, 554, 587, 466, 392, 466, 392, 587, 392,
  554, 587, 554, 587, 466, 392, 466, 392, 587, 392,
  440, 466, 440, 466, 392, 294, 277, 294, 392, 466, 554, 587, 784, 932, 622 
};

int noteDurationZ[] = {
  500, 500, 500, 500, 500, 1000, 500, 1000, 500, 1000,
  500, 500, 500, 500, 500, 1000, 500, 1000, 500, 1000,
  500, 500, 500, 500, 500, 1000, 500, 1000, 500, 1000,
  500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000
};

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

void loop() {
  // Read the FSR values
  value1 = analogRead(pressPin1);  // Speed control (FSR1)
  value2 = analogRead(pressPin2);  // Pitch/volume control (FSR2)
  
  if (value1 > 200) {
    whetherPlay = true;
  } else {
    whetherPlay = false;
  }

  Serial.print("FSR1 (Speed): ");
  Serial.print(value1);
  Serial.print(" | FSR2 (Pitch): ");
  Serial.println(value2);
  
  delay(50);

  // Adjust playback if FSR1 is pressed
  if (whetherPlay) {
    for (int i = 0; i < sizeof(melodyZ) / sizeof(melodyZ[0]); i++) {
      // Adjust the speed of note duration based on FSR1 (mapped to slow down or speed up)
      s = map(value1, 0, 900, 1, 5);  // Adjust note duration scaling factor
      int noteDuration = noteDurationZ[i] * s;  // Scaled note duration

      // Adjust the pitch based on FSR2 (scaled up or down slightly)
      float pitchFactor = map(value2, 0, 1023, 90, 110) / 100.0;  // Small pitch variation (90% to 110%)
      int adjustedPitch = melodyZ[i] * pitchFactor;  // Adjusted frequency

      // Play the tone with adjusted pitch and duration
      tone(speakerPin, adjustedPitch, noteDuration);
      delay(noteDuration * 1.3);  // Small gap between notes
    } s
  }

  // Small pause between melody loops
  delay(1000);
}

<aside> ➡️

554 C5 Sharp 500

587 D5 500

554 C5 Sharp 500

587 D5 500

466 A4 Sharp 500

392 G4 1000

466 A4 Sharp 500

392 G4 1000

587 D5 500

392 G4  1000

440 A4

466 A4 S

440 A4

466 A4 S

392 G4

294 D4

277 C4 S

294 D4

392 G4

466 A4 S

554 C5 S

587 D5

784 G5

932 A5S

</aside>

frankenstein

image.png