====== Désordre musigraphique ======
* Porteur du projet : Agathe Pastel
* Date : 11/01/2015
* Contexte : Macro projet DSAA
====== Description ======
Désordre Musigraphique est une installation visuelle et sonore qui propose une expérience de l'ordre et du désordre en musique et en graphisme.
====== Matériel ======
* Vidéoprojecteur
* enceintes
* processing
* arduino
* 2capteurs de flexions (ou 2 potentiomètres)
* 2 résistances 22Ω
====== Code ======
__Arduino (Exemple : SerialCallResponse)__
int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor
int thirdSensor = 0; // digital sensor
int inByte = 0; // incoming serial byte
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
pinMode(2, INPUT); // digital sensor is on digital pin 2
establishContact(); // send a byte to establish contact until receiver responds
}
void loop()
{
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
// read first analog input, divide by 4 to make the range 0-255:
firstSensor = analogRead(A0)/4;
// delay 10ms to let the ADC recover:
delay(10);
// read second analog input, divide by 4 to make the range 0-255:
secondSensor = analogRead(1)/4;
// read switch, map it to 0 or 255L
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
// send sensor values:
Serial.write(firstSensor);
Serial.write(secondSensor);
Serial.write(thirdSensor);
}
}
void establishContact() {
while (Serial.available() <= 0) {
Serial.print('A'); // send a capital A
delay(300);
}
}
__Processing__
//importer librairie
import processing.serial.*;
import arb.soundcipher.*;
//créer des instance de l'objet SoundCipher
SoundCipher sc = new SoundCipher(this);
SoundCipher sc2 = new SoundCipher(this);
SoundCipher sc3 = new SoundCipher(this);
//_______initialisation des variables
boolean crasse = false ;
boolean modu = false ;
//créer une liste qui correspond à une série de hauteur de note MIDI
float[] pitchSet = {57, 60, 60, 60, 62, 64, 67, 67, 69, 72, 72, 72, 74, 76, 79};
float setSize = pitchSet.length;
float keyRoot = 0;
float density = 0.8;
int bgcolor; // Background color
int fgcolor; // Fill color
Serial myPort; // serial port
int[] serialInArray = new int[3]; // cases dans lequelle on met ce qui est reçu
int serialCount = 0; // compte du nombre de byte reçu
int xpos, ypos; //coordonée de départ
boolean firstContact = false; // Whether we've heard from the microcontroller
//definition des variables
float x;
float y;
float a=0; //angle de départ
float b=0; //angle de départ
float l=10; //largeur elipse de départ
float h=10; //hauteur elipse depart
void setup() {
//fond
size(1080, 700);
background(250, 250, 250);
colorMode(HSB); // mode couleur TSL (teinte,saturation,brillance)
smooth();
noStroke(); //sans contour
frameRate(8);
sc.instrument(11); // l'objet sc doit jouer l'instrument 11 (vibraphone)
sc2.instrument(88);// l'objet sc1 doit jouer l'instrument 88 (fantasia)
sc3.instrument(98);//l'objet sc2 doit jouer l'instrument 98 (crystal)
// Print a list of the serial ports, for debugging purposes:
printArray(Serial.list());
// I know that the first port in the serial list on my mac
// is always my FTDI adaptor, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
}
void draw() {
if (keyPressed == true){ //si touche clavier pressé
crasse = true; //alors booléen crasse est vrai
}
if (mousePressed == true) { //si touche souris pressé
sc3.playNote(xpos/2, random(90)+30, random(20)/10 + 0.2);//alors sc3 joue des notes indépendentes du pitchSet
translate(width/2,height/2); //alors le centre du quadrilataire exécute
rotate(b); //une rotation qui augmente de 0.4 à chaque nouveau frame de draw
float r=ypos*5; //définir une variable r incluant le potentiomètreY
fill(r,random(210),255); //colorer le quadrilataire en gérant la teinte grâce à r(potentiomètreY)
float f= random(xpos/10); //définir une variable r incluant le potentiomètreX
quad(10,35,f,10*f,75,80,30*f,65);//forme du quadrilataire à 4 sommets dont certaine coordonnée son gérée par potentiomètreX
b+=0.4; // incrémentation de l'angle de rotation
}
//___________haronie________________
else {
if ((random(1) < density) && (crasse==true)) { // si le booléen crasse et en position vraie
float[] pitches = {pitchSet[(int)ypos/100]+keyRoot-12, pitchSet[(int)random(setSize)]-12}; //définition d'une liste faisant varier la hauteur de note
//sc joue un ensemble de note dont la hauteur est définie par la liste pitchSet et la valeur du potentiomètreX
sc.playNote(pitchSet[(int)xpos/100]+keyRoot, random(90)+30, random(20)/10 + 0.2); // la fonction playnote(double pitch, double dynamic, double duration)
sc2.playChord(pitches, random(50)+30, 4.0); // sc2 joue des accord en fonction de la liste pitches qui est dépendante de la liste pitchSet
}
//frameRate(50);//cadence du draw
if(crasse == true) { //si le booleen crasse est en position vraie
translate(width/2,height/2);//alors effectuer une traslation du centre du cercle
rotate(a);//effectuer une rotation don l'angle s'incrémentera de 0.1 à chaque rafraîchissement du draw
float r=ypos;
if (r<30){ //taille supèrieure limite
r = 50;
}
fill(r,random(210),random(200)); //colorer le cercle en fonction du potentiomètre ypos
float taille = xpos ; //définir une variable taille qui est commandé par le potentionmètre X
/*if (taille > 350){ //taille supèrieure limite
taille = 350;
}
if (taille < 50){ //taille infèrieure limite
taille = 50;
}*/
ellipse(300, 0, taille, taille);// définir la taille et la position du cercle
//incrémentation angle de rotation
a+=0.1;
}
}
}
void serialEvent(Serial myPort) {
// read a byte from the serial port:
int inByte = myPort.read();
// if this is the first byte received, and it's an A,
// clear the serial buffer and note that you've
// had first contact from the microcontroller.
// Otherwise, add the incoming byte to the array:
if (firstContact == false) {
if (inByte == 'A') {
myPort.clear(); // clear the serial port buffer
firstContact = true; // you've had first contact from the microcontroller
myPort.write('A'); // ask for more
}
}
else {
// Add the latest byte from the serial port to array:
serialInArray[serialCount] = inByte;
serialCount++;
// If we have 3 bytes:
if (serialCount > 2 ) {
xpos = serialInArray[0];
ypos = serialInArray[1];
fgcolor = serialInArray[2];
// print the values (for debugging purposes only):
println(xpos + "\t" + ypos + "\t" + fgcolor);
// Send a capital A to request new sensor readings:
myPort.write('A');
// Reset serialCount:
serialCount = 0;
}
}
}
====== présentation visuelle du code ======
{{:wiki:projets:desordre:presen_arduino2.pdf|slide présentation}}
====== problèmes rencontrés ======
* **librairie musicale** : réussir à comprendre la librairie SoundCipher
* - faire jouer 2 gammes à un moment différents : mettre en place un système de booléens
* - **capteurs flexions** : problème de communication entre la carte arduino et processing
====== Photos ======
(bientôt)
====== Schémas ======
{{:wiki:projets:desordre:untitled_sketch_bb.jpg?direct&300|montage arduino potentiomètres}}
{{:wiki:projets:desordre:untitled_sketch_bbdddd.jpg?direct&300|montage arduino capteurs flexions}}
====== Intention ======
{{:wiki:memoires:diy:plan_7.jpeg?direct&300|}}
**Recherches**
{{:wiki:projets:desordre:rempl2.jpeg?direct&300|}}
**Liens/Références**
http://www.nathangauthier.com/projets-typography/ornithologie
{{youtube>n1eQ6EwOMWc?medium}}
{{youtube>AjHW_2EXs28?medium}}
----
TR: des images, des images...