// 60s DDR Begleitautomat Rhythmen
// bass drum
const static unsigned long bd[78] PROGMEM={0,
81,25,257,20820,8513,1041,4097,4353,4353,257,
257,4369,289472833,257,33153,16847105,4161,20753,257,257,
4260097,257,4369,257,257,257,65,4161,4353,257,
257,257,69889,4369,4369,286282001,16843009,4161,257,257,
4369,4369,16843009,1118481,5185,16843009,1118481,17043713,273,4369,
17,65,17,4369,17473,16843009,4161,16843009,321,4369,
4369,257,321,20545,17733,289493313,0,321,4097,4369,
1025,257,85,17,1438991685,4353,1};
// snare drum
const static unsigned long sd[78] PROGMEM={0,
76,17,20817,17476,0,2576,1114384,17476,4417,32784,
23901,0,68161601,4112,0,1427181889,17684,4112,4112,4369,
272699733,4112,4369,4112,4369,1028,1105,21780,0,0,
23644,4369,1066000,4112,4369,286282001,0,0,257,4112,4112,
17476,273698896,0,0,1431655765,0,1157697857,1373,17501,68,
1361,68,4112,17424,0,21585,0,4433,4369,4112,
4112,4112,21597,18373,68158480,17476,4112,65924,4112,16,
0,213,91,1438991685,4176,272};
// low tom
const static unsigned long lt[78] PROGMEM={0,
0,204,0,0,37008,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,1281,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,16384,0,0,0,0,0,
0,0,0,0,0,67437632,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0};
// high tom
const static unsigned long ht[78] PROGMEM={0,
0,0,0,0,25925,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,20544,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,1109,0,0,0,0,0,
0,0,0,0,0,1374744861,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0};
// cymbal
const static unsigned long cy[78] PROGMEM={0,
76,0,257,21845,4369,3925,10066329,0,0,37265,
257,39321,1431655765,257,39321,0,0,20817,0,4369,
0,37265,0,0,0,1028,0,0,0,20817,
0,257,0,4369,17476,1064960,1364283729,21589,20817,0,
21845,4369,286331153,1381445,0,269488144,5510213,0,0,0,
0,0,0,4369,21845,0,0,289685777,4369,4369,
39321,257,21845,0,4112,1431655765,4369,0,69905,37265,
2448,2449,0,0,1438991685,21845,0};
// maracas
const static unsigned long mc[78] PROGMEM={0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,1431655765,0,0,0,0,
1431655765,0,0,0,0,0,0,21845,21845,0,
0,0,0,0,0,0,1431655765,0,0,0,
0,0,0,0,0,0,5592405,1431655765,0,0,
0,0,0,0,0,1431655765,0,1431655765,21845,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0};
// claves
const static unsigned long cl[78] PROGMEM={0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,17829953,0,0,0,0,
272695568,0,0,0,0,0,0,4161,4161,0,
0,0,0,0,0,0,17829953,0,0,0,
0,0,0,0,0,0,4477265,17829953,0,0,
0,0,0,0,0,17829953,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0};
// cow bell
const static unsigned long cb[78] PROGMEM={0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,289685777,0,0,0,
0,0,0,0,0,1363431697,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0};
// bass trigger
const static unsigned long bass[78] PROGMEM={0,
81,17,257,21589,17473,1345,4097,4353,4417,4369,
20801,4369,289472833,257,33153,16843009,4161,16705,257,4353,
272695553,257,4369,257,257,33153,65,20561,4353,257,
257,257,69889,4369,21845,286282001,1347506257,4161,5441,257,
4369,4369,4260097,1118481,17477,289472833,1118481,285282561,273,4369,
17,65,17,4369,16705,285282561,4161,16843009,321,4369,
4369,4433,16705,20545,17733,289493313,4369,321,69697,4369,
1025,257,213,89,1438991685,4353,1};
// chords trigger
const static unsigned long chord[78] PROGMEM={0,
76,95,4112,4369,27861,1040,1151377,17476,4417,4369,
20560,34952,356778257,20817,1028,269488196,17684,5140,4112,4369,
272699472,4369,4369,4112,4369,1028,1105,16,4161,20560,
21588,4112,1066000,56797,43690,269504528,67372036,21589,4112,4112,
21844,17476,340873553,282689,17493,1431655765,282689,1141130244,1092,17476,
68,1361,68,4112,1104,273682512,21585,289685777,4112,4369,
34952,4112,1040,21584,4112,1141903376,17476,1040,65796,4369,
2448,276,85,91,1438991685,21845,272};
// bar length, called reset value
const static byte res[78]={0,
8,8,16,16,16,12,12,16,16,16,
16,16,16,16,16,32,16,16,16,16,
32,16,16,16,16,16,12,16,16,16,
16,16,24,16,16,32,32,16,16,16,
16,16,32,24,16,32,24,32,12,16,
8,12,8,16,16,32,16,32,16,16,
16,16,16,16,16,32,16,16,20,16,
12,12,8,8,32,16,12};
byte x=0; // rhythm step
byte volatile e=0; // rhythm select
const byte i=77; // rhythm count
bool enc=LOW; // enc A merker
unsigned long buff[10]; // rhythm buffer
byte y=0;
int a=0;
void setup()
{
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(2),pulse,RISING); // clock
pinMode(3,OUTPUT); // BD
pinMode(4,OUTPUT); // SD
pinMode(5,OUTPUT); // LT
pinMode(10,OUTPUT); // HT
pinMode(9,OUTPUT); // CY
pinMode(8,OUTPUT); // MC
pinMode(7,OUTPUT); // CL
pinMode(6,OUTPUT); // CB
pinMode(12,OUTPUT); // bass
pinMode(11,OUTPUT); // chords
pinMode(A0,INPUT); // s/s
pinMode(A2,INPUT_PULLUP); // enc B
pinMode(A3,INPUT_PULLUP); // enc A
pinMode(13,OUTPUT); // view IRQ
delay(2000); // wait for LCD
Serial.write(0); // send zero LCD value
}
void pulse()
{
if (digitalRead(A0) == HIGH) // S/S active
{
digitalWrite(13,HIGH); // show IRQ time
buff[0]=pgm_read_dword_near(&bd[e]); // read all drums
buff[1]=pgm_read_dword_near(&sd[e]);
buff[2]=pgm_read_dword_near(<[e]);
buff[3]=pgm_read_dword_near(&ht[e]);
buff[4]=pgm_read_dword_near(&cy[e]);
buff[5]=pgm_read_dword_near(&mc[e]);
buff[6]=pgm_read_dword_near(&cl[e]);
buff[7]=pgm_read_dword_near(&cb[e]);
buff[8]=pgm_read_dword_near(&bass[e]);
buff[9]=pgm_read_dword_near(&chord[e]);
digitalWrite(3,bitRead(buff[0],x)); // put out steps
digitalWrite(4,bitRead(buff[1],x));
digitalWrite(5,bitRead(buff[2],x));
digitalWrite(10,bitRead(buff[3],x));
digitalWrite(9,bitRead(buff[4],x));
digitalWrite(8,bitRead(buff[5],x));
digitalWrite(7,bitRead(buff[6],x));
digitalWrite(6,bitRead(buff[7],x));
digitalWrite(12,bitRead(buff[8],x));
digitalWrite(11,bitRead(buff[9],x));
delay(5); // trigger pulse length
digitalWrite(3,LOW); // trigger pulse low
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
x++; // increase step
if (x >= res[e])
{
x = 0;
}
digitalWrite(13,LOW);
}
else // stop mode
{
x=0;
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
}
}
void loop()
{
if (digitalRead(A2) == HIGH && enc == LOW) // enc B
{
delay(5);
if (digitalRead(A3) == HIGH) // enc A
{
e++;
if (e > i)
{
e = 1;
}
}
else
{
e--;
if (e == 0)
{
e = i;
}
}
enc = HIGH;
Serial.write(e);
}
delay(5);
if (digitalRead(A2) == LOW && enc == HIGH) // enc B
{
enc = LOW;
delay(5);
}
}
Comments