Outils pour utilisateurs

Outils du site


wiki:flossmanuals:controleur-midi-pour-image:accueil

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
wiki:flossmanuals:controleur-midi-pour-image:accueil [2021/04/29 13:50]
127.0.0.1 modification externe
wiki:flossmanuals:controleur-midi-pour-image:accueil [2021/06/01 17:23] (Version actuelle)
damien.muti
Ligne 9: Ligne 9:
     * carte Arduino Uno / Seeduino     * carte Arduino Uno / Seeduino
     * bouton poussoir     * bouton poussoir
-    * +    * 2 potentiomètres rotatifs  
 +    * 2 potentiomètres slider
  
 ---- ----
Ligne 18: Ligne 19:
  
 L’idée est de pouvoir gérer du visuel en interaction avec la musique, grâce à un contrôleur midi constitué de deux slider, deux potentiomètres, et un bouton poussoir. Ce mini boitier sera relié à un programme processing de visualisation sonore et permettra ainsi à l’usager de modifier le visuel selon sa propre interprétation de la musique. Il pourra ainsi accentuer une forme à un moment modifier les couleurs à un autre.. tout cela grâce au contrôleur. Mon but est de transposer un outil largement utilisé dans le domaine de la musique électronique dans le domaine du graphisme, tout en gardant sa forme. Le graphiste peut ainsi apporter son propre « mix » visuel à partir de la musique qu’il écoute. L’idée est de pouvoir gérer du visuel en interaction avec la musique, grâce à un contrôleur midi constitué de deux slider, deux potentiomètres, et un bouton poussoir. Ce mini boitier sera relié à un programme processing de visualisation sonore et permettra ainsi à l’usager de modifier le visuel selon sa propre interprétation de la musique. Il pourra ainsi accentuer une forme à un moment modifier les couleurs à un autre.. tout cela grâce au contrôleur. Mon but est de transposer un outil largement utilisé dans le domaine de la musique électronique dans le domaine du graphisme, tout en gardant sa forme. Le graphiste peut ainsi apporter son propre « mix » visuel à partir de la musique qu’il écoute.
 +
 +{{:wiki:flossmanuals:controleur-midi-pour-image:schema.jpg|}}
  
 ===== Plans et schémas de fonctionnement ===== ===== Plans et schémas de fonctionnement =====
 +
 +{{:wiki:flossmanuals:controleur-midi-pour-image:flossmanual_bb.jpg|}}
  
  
Ligne 25: Ligne 30:
  
 ==== Arduino ==== ==== Arduino ====
-=== essai 1 === +=== essai 1 / SerialCallResponse === 
- +<code> 
-const int potentiometer = A0; +int potentiometre1 = A0;    // first analog sensor 
-const int potentiometer2 = A1; +int potentiometre2 = A1; 
-const int bouton 8+int potentiometre3 A2
-const int slider A2+int potentiometre4 A3
- +int bouton = 8;          // digital sensor 
 +int inByte = 0;         // incoming serial byte
  
 void setup() { void setup() {
 +  // start serial port at 9600 bps:
   Serial.begin(9600);   Serial.begin(9600);
-  pinMode(8, INPUT);+  while (!Serial
 +    // wait for serial port to connect. Needed for native USB port only 
 +  }
  
 +  pinMode(8, INPUT);   // digital sensor is on digital pin 8
 +  establishContact();  // send a byte to establish contact until receiver responds
 } }
  
 void loop() { void loop() {
- Serial.println( analogRead(potentiometer)); +  // if we get a valid byte, read analog ins: 
- delay(500); +  if (Serial.available() > 0) { 
- Serial.println(analogRead(potentiometer2)); +    // get incoming byte: 
- delay(500); +    inByte = Serial.read(); 
- Serial.println(digitalRead(bouton)); +    // read first analog input, divide by 4 to make the range 0-255: 
- delay(500); +    potentiometre1 = analogRead(A0/ 4
- Serial.println(analogRead(slider)); +    // delay 10ms to let the ADC recover: 
- +    delay(10); 
 +    // read second analog input, divide by 4 to make the range 0-255: 
 +    potentiometre2 = analogRead(A1/ 4; 
 +    delay(10); 
 +    potentiometre3 = analogRead(A2) / 4; 
 +    // delay 10ms to let the ADC recover: 
 +    delay(10); 
 +    // read second analog input, divide by 4 to make the range 0-255: 
 +    potentiometre4 = analogRead(A3) / 4; 
 +    // read switch, map it to 0 or 255L 
 +    bouton = map(digitalRead(8), 0, 1, 0, 255); 
 +    // send sensor values: 
 +    Serial.write(potentiometre1); 
 +    Serial.write(potentiometre2); 
 +    Serial.write(potentiometre3)
 +    Serial.write(potentiometre4); 
 +    Serial.write(bouton); 
 +  }
 } }
  
 +void establishContact() {
 +  while (Serial.available() <= 0) {
 +    Serial.print('A');   // send a capital A
 +    delay(300);
 +  }
 +}
 +</code>
 ==== Processing ==== ==== Processing ====
  
 J'ai trouvé ce programme [[https://github.com/amygoodchild/spinningtriangles_midicontroller/blob/master/Triangle.pde]] qui fonctionne avec les touches du clavier que je souhaiterai adapté pour mon contrôleur. J'ai trouvé ce programme [[https://github.com/amygoodchild/spinningtriangles_midicontroller/blob/master/Triangle.pde]] qui fonctionne avec les touches du clavier que je souhaiterai adapté pour mon contrôleur.
 +<code>
 import processing.serial.*; import processing.serial.*;
-Serial myPort; +// variables pour stoquer les données arduino (au nombre de 5)
- +
-import themidibus.*; +
-import javax.sound.midi.MidiMessage;  +
-import javax.sound.midi.SysexMessage; +
-import javax.sound.midi.ShortMessage; +
-MidiBus myBus; +
  
-// Setting up the triangles+// variables triangles
 float widthgap; float widthgap;
 float heightgap; float heightgap;
Ligne 70: Ligne 98:
 int rows = 11; int rows = 11;
 int numOfTriangles; int numOfTriangles;
-Triangle[] triangles; +Triangle[] triangles;  
-// How many frames from old variable to the next, higher is smoother but less responsive.  +float animationSpeed = 50;
-int animationSpeed = 50; +
-// Lowering this leads to fadeytrails.+
 float backgroundOpacity = 100; float backgroundOpacity = 100;
-//Serial myPort; 
  
  
-void setup() { +Serial myPort // The serial port 
-printArray(Serial.list())+int Narduino = 5; // nombre de données envoyées par la carte Arduino 
-myPort = new Serial( this, Serial.list()[4], 9600);+int[] serialInArray = new int[5];    // Where we'll put what we receive 
 +int serialCount = 0;  
 +int xposypos// A count of how many bytes we receive
  
 +boolean firstContact = false;        // Whether we've heard from the microcontroller
 +
 +void setup() {
   size(1920, 1080, P3D);   size(1920, 1080, P3D);
   //fullScreen(P3D);   //fullScreen(P3D);
Ligne 87: Ligne 117:
   background(0);   background(0);
   smooth();   smooth();
 +  
  
-  // Set up gap to lay out spacing between the triangles+  serialInArray= new int[Narduino]; 
 + 
 +  // initialisation des variables arduino
   widthgap = 100;   widthgap = 100;
   heightgap = 100;   heightgap = 100;
   numOfTriangles = cols*rows;   numOfTriangles = cols*rows;
 + ;
  
 +  // Print a list of the serial ports, for debugging purposes:
 +  printArray(Serial.list());
  
-  //MidiBus.list(); // List all available Midi devices on STDOUT. This will show each device's index and name. +  // I know that the first port in the serial list on my mac 
-  //myBus = new MidiBus(this0, 0)// Create a new MidiBus object +  // is always my  FTDI adaptorso I open Serial.list()[0]. 
- // String portName = Serial.list()[4]; +  // On Windows machines, this generally opens COM1. 
- // myPort = new Serial(this, portName, 9600); +  // Open whatever port is the one you're using. 
 +  String portName = Serial.list()[4]; 
 +  myPort = new Serial(this, portName, 9600); 
 +  
  
-  // Create an array of all the triangles 
   triangles = new Triangle[numOfTriangles];    triangles = new Triangle[numOfTriangles]; 
   for (int i=0; i<numOfTriangles; i++) {   for (int i=0; i<numOfTriangles; i++) {
     int row = i/cols;     int row = i/cols;
-    int col = i%cols;        +    int col = i%cols; 
     triangles[i] = new Triangle(col, row, i);          triangles[i] = new Triangle(col, row, i);     
     triangles[i] = new Triangle(col, row, i);     triangles[i] = new Triangle(col, row, i);
   }   }
 } }
-void draw() { 
  
-  // draw the background huge and far away - if it's at the regular position in the z axis, it cuts into the triangles as they rotate+void draw() { 
 +  // dessin d'un cecle coloré avec les valeurs de la carte Arduino
   fill(0, 0, 0, backgroundOpacity);   fill(0, 0, 0, backgroundOpacity);
   translate(-width*2, -height*2, -500);    translate(-width*2, -height*2, -500); 
   rect(0, 0, width*5, height*5);   rect(0, 0, width*5, height*5);
-  translate(width*2, height*2, 500);   +  translate(width*2, height*2, 500); 
  
-  // Update and draw all the triangles 
   for (int i=0; i<numOfTriangles; i++) {   for (int i=0; i<numOfTriangles; i++) {
     triangles[i].update();     triangles[i].update();
Ligne 126: Ligne 162:
 } }
  
-void keyPressed() { +void serialEvent(Serial myPort) { 
- +  // read a byte from the serial port: 
-  if (keyCode == UP) { +  int inByte = myPort.read(); 
-    for (int i=0; i<numOfTriangles; i++) { +  // if this is the first byte received, and it's an A, 
-      triangles[i].newSize+=10;+  // 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 (keyCode == DOWN) { +    // If we have 3 bytes: 
-    for (int i=0; i<numOfTriangles; i++) { +    if (serialCount > Narduino-1 ) { 
-      triangles[i].newSize-=10+      for (int i=0; i<numOfTriangles; i++) { 
-    } +      triangles[i].newSize = serialInArray[0];  
-  }+      triangles[i].innerOpacity = serialInArray[1]; 
 +      backgroundOpacity = serialInArray[2]; 
 +      triangles[i].newHueOffset  = serialInArray[3]; 
 +      ypos = serialInArray[4];
  
-  if (keyCode == LEFT{ +      // print the values (for debugging purposes only): 
-    backgroundOpacity-=10; +      println(triangles[i].newSize + "\t" + triangles[i].innerOpacity + "\t"backgroundOpacity + "\t" + triangles[i].newHueOffset);
-  }+
  
-  if (keyCode == RIGHT{ +      // Send a capital A to request new sensor readings: 
-    backgroundOpacity+=10;+      myPort.write('A'); 
 +      // Reset serialCount: 
 +      serialCount 0; 
 +    }
   }   }
 } }
 +}
 +</code>
 +===== Améliorations =====
 +
 +Le problème que j'ai rencontré c'est un manque de réactivité entre mon geste et le résultat obtenu sur processing, le but étant justement de pouvoir créer et modifier du visuel en live il vaudrait peut-être mieux envoyer directement des valeurs plutôt que des A.
 +
 +
  
 ==== Références : DIY midi controller ==== ==== Références : DIY midi controller ====
wiki/flossmanuals/controleur-midi-pour-image/accueil.1619697014.txt.gz · Dernière modification: 2021/04/29 13:50 de 127.0.0.1