Ceci est une ancienne révision du document !
Pour faire un thérémine nous avons besoin de :
Branchement de la carte :
Nous allons utiliser Arduino et Processing afin de réaliser notre Thérémine.
Pour brancher la carte et commencer le programme, nous allons suivre ce tuto tuto capteur grove.
Faire un Thérémine avec le Leap Motion et Processing
// Programme 2021
import processing.sound.*; // librairie sound
import de.voidplus.leapmotion.*; // libraire leap motion
LeapMotion leap;
Theremin leapTheremin;
ArrayList<PVector> points;
PVector handPos; // objet position main
TriOsc tri;
void setup () {
size(640,800);
leap = new LeapMotion(this);
points = new ArrayList<PVector>();
tri = new TriOsc(this);
leapTheremin = new Theremin(tri);
}
void draw() {
leapTheremin.renderSound();
for (Hand hand : leap.getHands()) {
handPos = hand.getPosition();
boolean handIsLeft = hand.isLeft();
boolean handIsRight = hand.isRight();
if (handPos.z <= 75) {
points = new ArrayList<PVector>();
points.add(new PVector(handPos.x, handPos.y));
background((handPos.x)/2.5,(width-handPos.x)/3,handPos.y-(height/3.5));
}
if (hand.isRight()) { //position de la main droite
leapTheremin.setPitch(); // objet change la hauteur
}
if (hand.isLeft()) { // position de la main gauche
leapTheremin.setVolume(); //objet change le volume
}
}
}
class Theremin {
float freq;
float amp;
int sound;
Theremin (TriOsc tri_g) {
setPitch();
sound = 1;
tri = tri_g;
}
void setPitch () {
for (int i = points.size()-1; i >= 0; i--) {
PVector p = points.get(i);
freq = map((height-handPos.y)+10, 0, height, 40, 880); //"antenne verticale", main qui contrôle la hauteur de la note
// la couleur s'associe avec la hauteur de la note - créer un dégradé
}
}
void setVolume() {
for (int i = points.size()-1; i >= 0; i--) {
PVector p = points.get(i);
amp = map(width-p.x, 0, width, 1, .01); //"antenne boucle", la main qui contrôle le volume
}
}
void renderSound() {
tri.freq(freq);
tri.amp(amp);
tri.play();
}
}