Zheremino

Zheremino it’s a Optical Midi Theremin. In this project I wanted to control synthesizers from a sensor with a Theremin-like method. That is, playing the instrument without touching it. Despite the Theremin, this project don’t play continous notes, without space between B3 and C4, for instance. I rather play with the natural keyboard transitions between notes. Due that, playing a scale sounds easy and you don’t have to worry too much about the pitch, if the synth is rigth tunned, of course.

The following two videos show how it works, connected to a Roland Juno-106.

The Arduino code I build for this project is this one:

#define Nmedidas 38 //Define el número de medidas del sensor que utiliza para realizar la media de la medida

#define notaBaja 59 //Define la nota mas grave que debe ser tocada

#define notaAlta 72 //Define la nota mas aguda que debe ser tocada

int value;

int avg;

int Navg;

int sum;

int i;

int nota;

void setup(){

Serial.begin(31250); //31250 velocidad para MIDI

}

void loop(){

// Lee el sensor y hace la media (avg) de Nmedidas

sum=0;

for (i=1; i<=Nmedidas; i++){

value=analogRead(0);

sum = sum + value;

}

avg =map( sum / Nmedidas,40,400,notaBaja,notaAlta);

//Supuesto 1: Si no hay cambios de nota (o sigue sin haber nota)

//salta a fin, sin hacer nada.

if((avg==Navg)||((avg<notaBaja)&&(Navg<notaBaja)))

{

goto fin;

}

//Supuesto 2: Habia una nota sonando y ya no hay

//debe enviar el “note off”

if((avg<=notaBaja)&&(Navg>=notaBaja)){

Navg=avg;

noteOn(0x80,nota,0);

delay(30);

goto fin;

}

//Supuesto 3: Existe una nota diferente a la anterior

//Envia “note Off” a la anterior y toca la actual

if((avg>=notaBaja)&&(avg<=notaAlta)){

//avg=map(avg,40,400,80,64);

Navg=avg;

noteOn(0x80,nota,00);

nota=avg;

noteOn(0x90,nota,90);

delay(100);

}

//Etiqueta de fin

fin:
;

}

// plays a MIDI note. Doesn’t check to see that

// cmd is greater than 127, or that data values are less
than 127:

void noteOn(char cmd, char data1, char data2) {

Serial.print(cmd,BYTE);

Serial.print(data1,BYTE);

Serial.print(data2,BYTE);

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.

%d bloggers like this: