Music Machine
I was tasked with designing a music machine using Processing and an ESP32 board. A part of the brief was also designing a casing for the machine.
I decided to create a drum pad that would create sound by the press of a button. Unfortunately, this was much harder than expected. After multiple bugs in my code and problems with the board its self I wasn't able to make the machine work.
This doesn't mean time was wasted though. From this I have discovered how drum pads are designed and grew a better understanding of Processing.
Processing Code:
import processing.serial.*;
import processing.sound.*;
SoundFile[] myDrums = new SoundFile[4];
Serial myConnection;
String serialValues = "''';
float bassBtnStateCurrent;
float bassBtnStatePrev;
float symbolßtnStateCurrent;
float symbolBtnStatePrev;
float float
hatBtnStateCurrent;
hatBtnStatePrev;
float leftdrumkBtnStateCurrent;
float leftdrumkBtnStatePrev;
void setup) {
size (660, 200);
myDrums [0] = new SoundFile(this, "BTOAODO.WAV");
myDrums [1] = new SoundFile(this, "CLOP4.WAV"') ;
myDrums [2] = new SoundFile(this, "HTODO.WAV") ;
myDrums [3] = new SoundFile(this, "LT7DA.WAV") ;
printArray (Serial.list());
myConnection = new Serial(this, Serial.listO (21, 9600);
myConnection.bufferUntil('\n');
// the loop function runs over and over again forever
Arduino Code:
#define BUTTON1 12
#define BUTTON2 13
#define BUTTON3 14
#define BUTTON4 15
void setup() ‹
// put your setup code here, to run once:
pinMode (BUTTON1, INPUT); pinMode (BUTTON2, INPUT); pinMode (BUTTON3, INPUT); pinMode (BUTTON4, INPUT);
Serial. begin (9600);
}
void loop() {
// put your main code here, to run repeatedly:
// Send a value depending on the button being pressed
if (digitalRead (BUTTON1) > 0) {
Serial println("1,");
delay (200);
} else if (digitalRead (BUTTON2) > 0) {
Serial.println("2,");
de lay (200);
} else if (digitalRead (BUTTON3) > 0) {
Serial.println("3,");
delay (200);
} else if (digitalRead (BUTTON4) > 0) 1
Serial-println("4,"); delay (200);
}
}