Sie sind auf Seite 1von 15

#include <MIDI.

h>

MIDI_CREATE_DEFAULT_INSTANCE();

const int Pad0 = 0;

const int Pad1 = 1;

const int Pad2 = 2;

const int Pad3 = 3;

const int Pad4 = 4;

const int Pad5 = 5;

const int Pad6 = 6;

const int Pad7 = 7;

const int Pad8 = 8;

const int Pad9 = 9;

const int Pad10 = 10;

const int Pad11 = 11;

const int Pad12 = 12;

const int Pad13 = 13;

const int Pad14 = 14;

const int tcrt = 15;

const int volumekick = 10;

const int volumeThreshold = 75;

const int volumehat = 25;

const int volumehat2 = 10;

const int volumeSnare = 80;

const int volumeSaklar = 150;


int Drum0_val =0;

int Drum1_val = 0;

int Drum2_val = 0;

int Drum3_val = 0;

int Drum4_val = 0;

int Drum5_val = 0;

int Drum6_val = 0;

int Drum7_val = 0;

int Drum8_val = 0;

int Drum9_val = 0;

int Drum10_val = 0;

int Drum11_val = 0;

int Drum12_val = 0;

int Drum13_val = 0;

int Drum14_val = 0;

int PEDAL_val = 0;

int signalTest0 = 0;

int signalTest1 = 0;

int signalTest2 = 0;

int signalTest3 = 0;

int signalTest4 = 0;

int signalTest5 = 0;

int signalTest6 = 0;

int signalTest7 = 0;

int signalTest8 = 0;

int signalTest9 = 0;
int signalTest10 = 0;

int signalTest11 = 0;

int signalTest12 = 0;

int signalTest13 = 0;

int signalTest14 = 0;

int signalTestHAT = 0;

byte ride2 = 91; // Pad 0

byte snare = 40; // Pad 1

byte kick = 36; // Pad 2

byte ride1 = 89; // Pad 3

byte tom1 = 50; // Pad 4

byte tom2 = 77; // Pad 5

byte floretom = 43; // Pad 6

byte HAT_OPEN = 46; // Pad 7

byte PEDAL = 44;

byte HAT_CLOSE = 42;

byte splash1 = 28; // Pad 8

byte rimeshot = 37; // Pad 9

byte splash2 = 32; // Pad 10

byte ride_belt = 53; // Pad 11

byte kosong1 = 89; // Pad 12

byte kosong2 = 52; // Pad 13

byte kosong3 =91; // Pad 14

void setup()
{

MIDI.begin(4);

Serial.begin(115200);

void loop()

/*===================================/0/========================================*/

/*Piezo Sensor Pad0(Analog In 0*/

if(analogRead(Pad0) >= volumeThreshold)

signalTest0 = 1;

if(signalTest0 == 1 && analogRead(Pad0) >= (volumeThreshold))

Drum0_val= analogRead(Pad0);

int velocity = Drum0_val/3 + 50;

if(velocity >= 90)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(ride2, velocity, 1);

MIDI.sendNoteOff(ride2, 0, 1);

signalTest0 = 0;

/*===================================/1/========================================*/
/*Piezo Sensor Pad1(Analog In 1*/

if(analogRead(Pad1) >= volumeSnare)

signalTest1 = 1;

if(signalTest1 == 1)

Drum1_val= analogRead(Pad1);

int velocity = Drum1_val/3 + 45;

if(velocity >= 90)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(snare, velocity, 1);

MIDI.sendNoteOff(snare, 0, 1);

signalTest1 = 0;

/*====================================/2/========================================*/

/*Piezo Sensor Pad2(Analog In 2)*/

if(analogRead(Pad2) >= volumekick)

signalTest2 = 1;

if(signalTest2 == 1)

Drum2_val= analogRead(Pad2);
int velocity = Drum2_val/3 + 30;

if(velocity >= 95)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(kick, velocity, 1);

MIDI.sendNoteOff(kick, 0, 1);

signalTest2 = 0;

/*====================================/3/========================================*/

/*Piezo Sensor Pad3(Analog In 3*/

if(analogRead(Pad3) >= volumehat)

signalTest3 = 1;

if(signalTest3 == 1 && analogRead(Pad3) >= (volumehat))

Drum3_val= analogRead(Pad3);

int velocity = Drum3_val/3 + 45;

if(velocity >= 90)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(ride1, velocity, 1);

MIDI.sendNoteOff(ride1, 0, 1);
signalTest3 = 0;

/*====================================/4/========================================*/

/*Piezo Sensor Pad4(Analog In 4)*/

if(analogRead(Pad4) >= volumeThreshold)

signalTest4 = 1;

if(signalTest4 == 1 && analogRead(Pad4) >= (volumeThreshold))

Drum4_val= analogRead(Pad4);

int velocity = Drum4_val/3 + 50;

if(velocity >= 90)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(tom1, velocity, 1);

MIDI.sendNoteOff(tom1, 0, 1);

signalTest4 = 0;

/*====================================/5/========================================*/

/*Piezo Sensor Pad5(Analog In 5*/

if(analogRead(Pad5) >= volumeThreshold)

signalTest5 = 1;
}

if(signalTest5 == 1 && analogRead(Pad5) >= (volumeThreshold))

Drum5_val= analogRead(Pad5);

int velocity = Drum5_val/3 + 50;

if(velocity >= 90)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(tom2, velocity, 1);

MIDI.sendNoteOff(tom2, 0, 1);

signalTest5 = 0;

/*====================================/6/========================================*/

/*Piezo Sensor Pad6(Analog In 6)*/

if(analogRead(Pad6) >= volumeThreshold)

signalTest6 = 1;

if(signalTest6 == 1 && analogRead(Pad6) >= (volumeThreshold))

Drum6_val= analogRead(Pad6);

int velocity = Drum6_val/3 + 50;

if(velocity >= 125)

velocity = 135;

else if(velocity < 0)


velocity = 0;

MIDI.sendNoteOn(floretom, velocity, 1);

MIDI.sendNoteOff(floretom, 0, 1);

signalTest6 = 0;

/*====================================/7/========================================*/

/*Piezo Sensor Pad7(Analog In 7*/

if(analogRead(tcrt) >= volumeSaklar)

signalTest7 = 1;

if(signalTest7 == 1 && analogRead(Pad7) >= (volumehat2))

Drum7_val= analogRead(Pad7);

int velocity = Drum7_val/3 + 60;

if(velocity >= 120)

velocity = 125;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(HAT_OPEN, velocity, 1);

MIDI.sendNoteOff(HAT_OPEN, 0, 1);

signalTest7 = 0;

}
else

if(analogRead(tcrt) < volumeSaklar)

signalTest7 = 2;

if(signalTest7 == 2 && analogRead(Pad7) >= (volumehat2))

Drum7_val= analogRead(Pad7);

int velocity = Drum7_val/3 + 40;

if(velocity >= 60)

velocity = 70;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(HAT_CLOSE, velocity, 1);

MIDI.sendNoteOff(HAT_CLOSE, 0, 1);

signalTest7 = 0;

/*===================================/8/========================================*/

/*Piezo Sensor Pad8(Analog In 8)*/

if(analogRead(Pad8) >= volumeThreshold)

signalTest8 = 1;

if(signalTest8 == 1 && analogRead(Pad8) >= (volumeThreshold))

Drum8_val= analogRead(Pad8);
int velocity = Drum8_val/3 + 60;

if(velocity >= 90)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(splash1, velocity, 1);

MIDI.sendNoteOff(splash1, 0, 1);

signalTest8 = 0;

/*===================================/9/========================================*/

/*Piezo Sensor Pad9(Analog In 9)*/

if(analogRead(Pad9) >= volumeThreshold)

signalTest9 = 1;

if(signalTest9 == 1 && analogRead(Pad9) >= (volumeThreshold))

Drum9_val= analogRead(Pad9);

int velocity = Drum9_val/3 + 60;

if(velocity >= 50)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(rimeshot, velocity, 1);

MIDI.sendNoteOff(rimeshot, 0, 1);
signalTest9 = 0;

/*===================================/10/========================================*/

/*Piezo Sensor Pad10(Analog In 10)*/

if(analogRead(Pad10) >= volumehat)

signalTest10 = 1;

if(signalTest10 == 1 && analogRead(Pad10) >= (volumehat))

Drum10_val= analogRead(Pad10);

int velocity = Drum10_val/3 + 50;

if(velocity >= 100)

velocity = 110;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(splash2, velocity, 1);

MIDI.sendNoteOff(splash2, 0, 1);

signalTest10 = 0;

/*===================================/11/========================================*/

/*Piezo Sensor Pad11(Analog In 11)*/

if(analogRead(Pad11) >= volumehat)


{

signalTest11 = 1;

if(signalTest11 == 1 && analogRead(Pad11) >= (volumehat))

Drum11_val= analogRead(Pad11);

int velocity = Drum11_val/3 + 60;

if(velocity >= 50)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(ride_belt, velocity, 1);

MIDI.sendNoteOff(ride_belt, 0, 1);

signalTest11 = 0;

/*===================================/12/========================================*/

/*Piezo Sensor Pad12(Analog In 12)*/

if(analogRead(Pad12) >= volumeThreshold)

signalTest12 = 1;

if(signalTest12 == 1 && analogRead(Pad12) >= (volumeThreshold))

Drum12_val= analogRead(Pad12);

int velocity = Drum12_val/3 + 60;


if(velocity >= 100)

velocity = 125;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(kosong1, velocity, 1);

MIDI.sendNoteOff(kosong1, 0, 1);

signalTest12 = 0;

/*===================================/13/========================================*/

/*Piezo Sensor Pad13(Analog In 13)*/

if(analogRead(Pad13) >= volumeThreshold)

signalTest13 = 1;

if(signalTest13 == 1 && analogRead(Pad13) >= (volumeThreshold))

Drum13_val= analogRead(Pad13);

int velocity = Drum13_val/3 + 60;

if(velocity >= 90)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(kosong2, velocity, 1);

MIDI.sendNoteOff(kosong2, 0, 1);
signalTest13 = 0;

/*===================================/14/========================================*/

/*Piezo Sensor Pad14(Analog In 14)*/

if(analogRead(Pad14) >= volumeThreshold)

signalTest14 = 1;

if(signalTest14 == 1 && analogRead(Pad14) >= (volumeThreshold))

Drum14_val= analogRead(Pad14);

int velocity = Drum14_val/3 + 60;

if(velocity >= 90)

velocity = 100;

else if(velocity < 0)

velocity = 0;

MIDI.sendNoteOn(kosong3, velocity, 1);

MIDI.sendNoteOff(kosong3, 0, 1);

signalTest14 = 0;

Das könnte Ihnen auch gefallen