Go Down

### Topic: Euclidean Sequencer Tap Tempo (Read 585 times)previous topic - next topic

#### Giò LFZ

##### Jan 23, 2015, 02:47 pm
Hi guys

sorry for cross posting

I've read some post on how to build a tap tempo, but I guess my case is a bit different...

A friend of mine give me this code
Code: [Select]
`#include <MIDI.h>  MIDI_CREATE_DEFAULT_INSTANCE();const int lunghezza = 32;char pattern1[lunghezza];char pattern2[lunghezza];char pattern3[lunghezza];char pattern4[lunghezza];const int ledPin = 13;unsigned char pos = 0;void setup() {  pinMode(ledPin, OUTPUT);  MIDI.begin(3);                         // Lancia il MIDI (su DIN) con input su canale 3  randomSeed(analogRead(0));  Ritmo();}void Ritmo(){  Euclide((char *)&pattern1, (map(analogRead(0),0,1023,0,lunghezza)), lunghezza);  Euclide((char *)&pattern2, (map(analogRead(1),0,1023,0,lunghezza)), lunghezza);  Euclide((char *)&pattern3, (map(analogRead(2),0,1023,0,lunghezza)), lunghezza);  Euclide((char *)&pattern4, (map(analogRead(3),0,1023,0,lunghezza)), lunghezza);  // Euclide((char *)&pattern3, (int)random(5), lunghezza);} void Euclide(char *beat, int colpi, int steps) {  int cur = steps;  for (int i=0; i<steps; i++) {    if (cur >= steps) {      cur -= steps;      *beat = 'x';    }     else {      *beat = '.';    }    if (colpi==0) *beat = '.';    beat++;    cur += colpi;  }}void on_beat() {  int velocity= map (analogRead (4),0,1024,0,127);  MIDI.sendNoteOn(36,0,10);  MIDI.sendNoteOn(42,0,10);  MIDI.sendNoteOn(38,0,10);  MIDI.sendNoteOn(40,0,10);  digitalWrite(ledPin, LOW);  if (pattern1[pos] == 'x') {    MIDI.sendNoteOn(36, velocity, 10);    digitalWrite(ledPin, HIGH);  }  if (pattern2[pos] == 'x') {    MIDI.sendNoteOn(42, velocity, 10);    }  if (pattern3[pos] == 'x') {    MIDI.sendNoteOn (38, velocity, 10);  }  if (pattern4[pos] == 'x') {    MIDI.sendNoteOn (40, velocity, 10);  }  if (++pos == lunghezza) {    pos = 0;  }}void loop() {    for (int i = 1; i < lunghezza; i++)  {    Ritmo();    on_beat();    delay (map(analogRead(5),0,1024,1000,10));  }}`

lunghezza is for lenght...

It generates four different patterns for four different midi notes, then I got one pot for velocity and one for the tempo, I would like to insert a sort of tap tempo/looping and activate it with an arcade button. Like an hold and release, if I press it for 4 bars it synchronized the pattern according to the right bpm...

am I clear?

maybe not...

something like that... http://umlautllama.com/projects/arduino/s/TapTempo_WithPressAndHold.pde

Go Up