Catégories
Liens
Ceci est une ancienne révision du document !
contributeurs: BrutPop, Reso-nance
description : Pratiques musicales collectives
date: 2014-… (en développement)
techniques: électronique magnétisme
tags: ateliers
fichiers:
licence: GNUGPL
liens: http://brutpop.blogspot.fr
}}}
Outils pour favoriser la pratique musicale collective, la BrutBox permet une approche intuitive et expérimentale du geste et de sa restitution musicale. Le projet est à destination de tous publics, d'encadrement pédagogique ou social. Basée sur le framework développé pour la Malinette, la Brutbox associe du logiciel et une interface permettant la connexion avec une collection non-exhaustive de capteurs.
Janvier 2015 : cahierdescharges-2015-01.pdf
juin 2015 au LFO : http://piratepad.net/brutbox
To do, questions : https://semestriel.framapad.org/p/malinette0.90
Basé sur la Malinette et Pure Data Extended : malinette_v0.90.zip
Réception des données MIDI à partir de Pure Data
teensy_brutbox.ino (sans on off pour MAC)
/* * TEENSY 2 for BRUTBOX * Analog sensors + encoder + touch * * Licence : GNU/GPL3 * Date : 12/06/2015 * Website : http://reso-nance.org/wiki/projets/malinette-brutbox * * Hardware add-on : the MPR121 module for touch sensors * * Midi mapping : * 12 analog sensors (midi controller from 0 to 11) * 1 encoder (midi controller 12) * 12 touch sensors (midi note from 60 to 71) */ // Include libraries #include <Wire.h> #include "Adafruit_MPR121.h" #include <Encoder.h> // Midi channel const int channel = 1; // Analog setup int anaPins[] = {22,11,12,13,14,15,16,17,18,19,20,21}; // analog pins const int anaNb = 12; // number of inputs int anaCtl[] = {11,10,9,8,7,6,5,4,3,2,1,0}; // controller in int anaValues[anaNb]; // current analog values int anaLastValues[anaNb]; // previous analog values // Encoder setup Encoder encoderSensor (7, 8); long encoderOldPosition = -999; long encoderNewPosition; long encoderLastPosition; // Capacitive Touch MPR121 module // Connection Teensy2 // USB wiring : d+ : SDA, d- : SCL, SCL = DO, SDA = D1 Adafruit_MPR121 cap = Adafruit_MPR121(); uint16_t lasttouched = 0; uint16_t currtouched = 0; const int touchNb = 12; // number of touch inputs int touchCtl[] = {60,61,62,63,64,65,66,67,68,69,70,71}; // note in // Sampling rate elapsedMillis msec = 0; void setup() { // Trying to connect to the capacitive module if (!cap.begin(0x5A)) { while (1); } delay(1000); } void loop() { if (msec >= 20) { msec = 0; // Analog sensors loop for (int i = 0; i < anaNb; i++) { anaValues[i] = (int) analogRead(anaPins[i]) / 8 ; if (anaValues[i] != anaLastValues[i]) { usbMIDI.sendControlChange(anaCtl[i], anaValues[i], channel); anaLastValues[i] = anaValues[i]; } } // Encoder encoderNewPosition = encoderSensor.read(); if (encoderNewPosition != encoderOldPosition) { if (encoderNewPosition > encoderOldPosition) {usbMIDI.sendControlChange(12, 0, channel);} else if (encoderNewPosition < encoderOldPosition) {usbMIDI.sendControlChange(12, 127, channel);} encoderOldPosition = encoderNewPosition; } // Capacitive loop currtouched = cap.touched(); for (uint8_t i=0; i < touchNb; i++) { if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {usbMIDI.sendNoteOn(touchCtl[i], 127, channel);} if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {usbMIDI.sendNoteOn(touchCtl[i], 0, channel);} } lasttouched = currtouched; // reset our state } while (usbMIDI.read()) { // Discard incoming MIDI messages. } }
teensy_brutbox.ino (avec on off)
/* * TEENSY 2 for BRUTBOX * Control inputs (sensors) with MIDI messages * * Licence : GNU/GPL3 * Date : 11/06/2015 * Website : http://reso-nance.org/wiki/projets/malinette-brutbox * * Hardware add-on : the MPR121 module for touch sensors * * Midi mapping : * 12 analog sensors (midi controller from 0 to 11) * 1 encoder (midi controller 12) * 12 touch sensors (midi note from 60 to 71) */ // Include libraries #include <Wire.h> #include "Adafruit_MPR121.h" #include <Encoder.h> // Midi channel const int channel = 1; // Capacitive Touch MPR121 module // Connection Teensy2 // USB wiring : d+ : SDA, d- : SCL, SCL = DO, SDA = D1 Adafruit_MPR121 cap = Adafruit_MPR121(); uint16_t lasttouched = 0; uint16_t currtouched = 0; const int touchNb = 12; // number of touch inputs const int touchThreshold = 60; int touchStateCtl[] = {40, 41, 42} ; // touch on/off int touchState[touchNb]; // state : on/off //int currentTouchValues[touchNb]; //int lastTouchValues[touchNb]; int touchCtl[] = {60,61,62,63,64,65,66,67,68,69,70,71}; // note in int touchOn = 0; // Analog setup int anaPins[] = {22,11,12,13,14,15,16,17,18,19,20,21}; // analog pins const int anaNb = 12; // number of inputs int anaCtl[] = {11,10,9,8,7,6,5,4,3,2,1,0}; // controller in int anaStateCtl[] = {20, 21} ; // sensor on (20), sensor off (21) int anaState[anaNb]; // state : on/off int anaValues[anaNb]; // current analog values int anaLastValues[anaNb]; // previous analog values // Encoder setup Encoder encoderSensor (7, 8); long encoderOldPosition = -999; long encoderNewPosition; long encoderLastPosition; int encoderStateCtl = 13; // receive ctlout 13 int encoderOn = 0; // Sampling rate elapsedMillis msec = 0; int rate = 20; void setup() { // Midi receive : on/off sensors usbMIDI.setHandleControlChange(OnControlChange); } void loop() { if (msec >= rate) { msec = 0; // Analog sensors loop for (int i = 0; i < anaNb; i++) { if(anaState[i] == 1) { // check first if the sensor is on anaValues[i] = (int) analogRead(anaPins[i]) / 8 ; if (anaValues[i] != anaLastValues[i]) { usbMIDI.sendControlChange(anaCtl[i], anaValues[i], channel); anaLastValues[i] = anaValues[i]; } } } // Capacitive loop if(touchOn == 1){ currtouched = cap.touched(); for (uint8_t i=0; i < touchNb; i++) { if(touchState[i] == 1) { // check first if the sensor is on if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) { usbMIDI.sendNoteOn(touchCtl[i], 127, channel); } if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) { usbMIDI.sendNoteOn(touchCtl[i], 0, channel); } } } lasttouched = currtouched; // reset our state } // Encoder if (encoderOn == 1) { encoderNewPosition = encoderSensor.read(); if (encoderNewPosition != encoderOldPosition) { if (encoderNewPosition > encoderOldPosition) { usbMIDI.sendControlChange(12, 0, channel); } else if (encoderNewPosition < encoderOldPosition) { usbMIDI.sendControlChange(12, 127, channel); } encoderOldPosition = encoderNewPosition; usbMIDI.sendControlChange(12, encoderNewPosition, channel); } } } while (usbMIDI.read()) { // Discard incoming MIDI messages. } } // Receive Midi Control Change void OnControlChange(byte channel, byte control, byte value) { // Analog sensors on/off if (control == anaStateCtl[0]) {anaState[-value+(anaNb-1)] = 0;} else if (control == anaStateCtl[1]) {anaState[-value+(anaNb-1)] = 1;} else if (control == touchStateCtl[0]) {touchState[value] = 0;} else if (control == touchStateCtl[1]) {touchState[value] = 1;} else if (control == touchStateCtl[2]) { touchOn = value; if (touchOn == 1) {cap.begin(0x5A);} } else if (control == encoderStateCtl) {encoderOn = value;} }
teensy-onoff_no-capacitif.ino (avec on/off et encoder)
// Include libraries #include <Wire.h> //#include "Adafruit_MPR121.h" #include <Encoder.h> // Midi channel const int channel = 1; // Analog setup int anaPins[] = {22,11,12,13,14,15,16,17,18,19,20,21}; // analog pins const int anaNb = 12; // number of inputs int anaCtl[] = {20,21,22,23,24,25,26,27,28,29,30,31}; // cc non-attribués int anaStateCtl[] = {20, 21} ; // sensor on (20), sensor off (21) int anaState[anaNb]; // state : on/off int anaValues[anaNb]; // current analog values int anaLastValues[anaNb]; // previous analog values // Encoder setup Encoder encoderSensor (7, 8); long encoderOldPosition = -999; long encoderNewPosition; long encoderLastPosition; int encoderStateCtl = 13; // receive ctlout 13 int encoderOn = 0; // Sampling rate elapsedMillis msec = 0; int rate = 20; void setup() { // Midi receive : on/off sensors usbMIDI.setHandleControlChange(OnControlChange); } void loop() { if (msec >= rate) { msec = 0; // Analog sensors loop for (int i = 0; i < anaNb; i++) { if(anaState[i] == 1) { // check first if the sensor is on anaValues[i] = (int) analogRead(anaPins[i]) / 8 ; if (anaValues[i] != anaLastValues[i]) { usbMIDI.sendControlChange(anaCtl[i], anaValues[i], channel); anaLastValues[i] = anaValues[i]; } } } // Encoder if (encoderOn == 1) { encoderNewPosition = encoderSensor.read(); if (encoderNewPosition != encoderOldPosition) { if (encoderNewPosition > encoderOldPosition) { usbMIDI.sendControlChange(12, 0, channel); } else if (encoderNewPosition < encoderOldPosition) { usbMIDI.sendControlChange(12, 127, channel); } encoderOldPosition = encoderNewPosition; usbMIDI.sendControlChange(12, encoderNewPosition, channel); } } } while (usbMIDI.read()) { // Discard incoming MIDI messages. } } // Receive Midi Control Change void OnControlChange(byte channel, byte control, byte value) { // Analog sensors on/off if (control == anaStateCtl[0]) {anaState[-value+(anaNb-1)] = 0;} else if (control == anaStateCtl[1]) {anaState[-value+(anaNb-1)] = 1;} else if (control == encoderStateCtl) {encoderOn = value;} }
Une piste d'utiliser la manette Wiimote pour creer un dispositif ou l'on peut changer de capteur. En démontant le nunchuk et en retirant le joystick nous pouvons utiliser deux entrées analogiques. Attention la wiimote est alimenté en 3.3v, donc nous sommes limité aux capteurs resistifs qui fonctionnent à cette tension.
On utilise ensuite OSCULATOR (sur macOS) pour recevoir les données et les transformer en midi. Voir page ressource Wiimote