Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
projets:teensymiditouchcontroller [2015/03/31 13:38] arbuste [Tutoriel] |
— (Version actuelle) | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Controleur Midi avec touches tactiles ====== | ||
- | * Porteur du projet : [[user: | ||
- | * Date : 22/12/2014 | ||
- | * Licence : libre ! | ||
- | * Contexte : installation utilisant le midi comme interface de commande | ||
- | * Fichiers : | ||
- | * Lien : | ||
- | ===== Description ===== | ||
- | Petit texte + vidéo ou photo de la réalisation finale | ||
- | ===== Matériaux ===== | ||
- | |||
- | - une carte Teensy 3.1\\ | ||
- | |||
- | - un [[https:// | ||
- | |||
- | - cable usb micro-B: [[http:// | ||
- | |||
- | - OPTIONNEL (mais très fortement conseillé): | ||
- | |||
- | - fil de montage\\ | ||
- | |||
- | - pièces de cuivre, ou bandes d' | ||
- | |||
- | - potentiomètres (10K)\\ | ||
- | |||
- | - interrupteurs momentanés ou switches\\ | ||
- | |||
- | - 12 résistances (par controleur construit) | ||
- | ===== Tutoriel ===== | ||
- | |||
- | les cartes Teensy ( http:// | ||
- | |||
- | Si Arduino est une solution très répandue (et efficace) dans de nombreux projets impliquant du MIDI pour communiquer avec un ordinateur ou des synthétiseurs, | ||
- | |||
- | Dans le cas où l'on veut fabriquer un contrôleur MIDI USB, une carte Teensy s' | ||
- | |||
- | L' | ||
- | |||
- | Ce tutoriel documente la construction d'un Controleur Midi Usb avec: | ||
- | |||
- | - 12 touches tactiles qui envoient des notes MIDI\\ | ||
- | - 8 entrées analogiques qui lisent des potentiomètres et envoient des Control Change (CC) MIDI\\ | ||
- | - 4 entrées digitales qui envoient des Control Change\\ | ||
- | |||
- | |||
- | |||
- | |||
- | **1- DESIGN D'UN PCB:** | ||
- | |||
- | en utilisant Fritzing ( [[http:// | ||
- | |||
- | le fichier du PCB que j'ai envoyé au fritzing fab (tout se fait depuis fritzing) est ici: | ||
- | |||
- | (Le design ne respecte surement pas toutes les règles de design d'un circuit imprimé et est surement loin d' | ||
- | |||
- | Le circuit vu dans Fritzing: | ||
- | |||
- | {{: | ||
- | |||
- | Le circuit une fois reçu, et monté: | ||
- | |||
- | {{: | ||
- | |||
- | **2- MONTAGE DES COMPOSANTS SUR LA CARTE:** | ||
- | |||
- | Commencer par les résistances smd de 10K: poser un peu de soudure sur un des plots carrés qui leurs sont destinés, placer la résistance et souder un de ses cotés sur le plot en appuyant doucement dessus, lorsqu' | ||
- | |||
- | Souder ensuite les borniers, et enfin la carte teensy (auparavant montée sur son Breakout). | ||
- | |||
- | |||
- | Voilà la carte montée: | ||
- | |||
- | {{: | ||
- | |||
- | |||
- | **3- LE CODE:** | ||
- | |||
- | J'ai trouvé sur le site du brillant [[http:// | ||
- | |||
- | **ATTENTION: | ||
- | |||
- | |||
- | voilà ma version du code qui a été utilisée sur les contrôleurs: | ||
- | |||
- | < | ||
- | |||
- | /* some code designed for using the Teensy 3 as a USB MIDI controller | ||
- | v1.0, December 17 2013 | ||
- | by Yann Seznec www.yannseznec.com | ||
- | |||
- | modified by Matthieu Pernaud for teensy 3.1 and for different purposes: | ||
- | |||
- | use of all 12 touch pins to send midi notes. | ||
- | use of all analog pins available. | ||
- | use of digital pins to send notes. | ||
- | |||
- | remember to select MIDI as your USB Type in the Tools menu | ||
- | |||
- | this should also work with other Teensy boards, apart from the " | ||
- | |||
- | things that are kind of dumb in this code: | ||
- | - the touch threshold is hard coded (int touchThreshold) | ||
- | - touch pins only send midi note on/off with no velocity change | ||
- | - no system for sending touch pin as CC | ||
- | - the CC assignments are sort of random, probably should have another array for them | ||
- | |||
- | */ | ||
- | |||
- | /* TOUCHPINS - send midi notes */ | ||
- | |||
- | int const numTouchPins = 12; // number of pins to use as touchpins, sending note values | ||
- | int touch[numTouchPins]; | ||
- | int touchon[numTouchPins]; | ||
- | int touchpin[] = { | ||
- | 0, | ||
- | int touchpitch[] = { | ||
- | 36, | ||
- | int touchThreshold = 3200; | ||
- | int touchMax = 4000; | ||
- | |||
- | /*ANALOG PINS*/ | ||
- | |||
- | int const numPins = 8; // number of analog inputs | ||
- | int currentVal[numPins]; | ||
- | int newVal[numPins]; | ||
- | int analogPins[] = { | ||
- | A10, | ||
- | }; | ||
- | int analogstartcc = 50; // MIDI CC number to start from. | ||
- | |||
- | |||
- | |||
- | int const numDigPins = 0; // number of digital pins to send note values | ||
- | int currentDig[numDigPins]; | ||
- | int digitalpin[] = { | ||
- | 2, | ||
- | }; | ||
- | int digitalpitch[] = { | ||
- | 48, | ||
- | int digInput[numDigPins]; | ||
- | |||
- | |||
- | int const numDigPinsCC = 4; // number of digital pins to send CC | ||
- | int currentDigcc[numDigPinsCC]; | ||
- | int digitalpincc[] = { | ||
- | | ||
- | }; | ||
- | int digccstart = 10; // CC number to start from | ||
- | |||
- | int digInputcc[numDigPinsCC]; | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | // the MIDI channel number to send messages on | ||
- | |||
- | const int channel = 1; | ||
- | |||
- | |||
- | |||
- | void setup() { | ||
- | |||
- | pinMode(10, INPUT_PULLUP); | ||
- | pinMode(11, INPUT_PULLUP); | ||
- | pinMode(12, INPUT_PULLUP); | ||
- | pinMode(24, INPUT_PULLUP); | ||
- | |||
- | Serial.begin(38400); | ||
- | |||
- | } | ||
- | |||
- | void loop() { | ||
- | | ||
- | | ||
- | // touch sending notes | ||
- | | ||
- | for (int i = 0; i < numTouchPins; | ||
- | touch[i] = touchRead(touchpin[i]); | ||
- | |||
- | if (touch[i] > touchThreshold && touchon[i] == 0) { | ||
- | usbMIDI.sendNoteOn(touchpitch[i], | ||
- | touchon[i] = 1; | ||
- | } | ||
- | if (touch[i] < touchThreshold && touchon[i] == 1) { | ||
- | usbMIDI.sendNoteOff(touchpitch[i], | ||
- | touchon[i] = 0; | ||
- | } | ||
- | |||
- | /* touchpads | ||
- | for (int i = 0; i < numTouchPins; | ||
- | touch[i] = touchRead(touchpin[i]); | ||
- | |||
- | if (touch[i] > touchThreshold && touchon[i] == 0) { | ||
- | usbMIDI.sendControlChange(i+25, | ||
- | touchon[i] = 1; | ||
- | } | ||
- | if (touch[i] < touchThreshold && touchon[i] == 1) { | ||
- | usbMIDI.sendControlChange(i+25, | ||
- | touchon[i] = 0; | ||
- | } | ||
- | |||
- | } | ||
- | | ||
- | */ | ||
- | |||
- | |||
- | // digital pins sending notes | ||
- | // for (int i = 0; i < numDigPins; i++) { | ||
- | // if (digitalRead(digitalpin[i]) == 1 && currentDig[i] == 0) { | ||
- | // usbMIDI.sendNoteOff(digitalpitch[i], | ||
- | // currentDig[i] = 1; | ||
- | // } | ||
- | // if (digitalRead(digitalpin[i]) == 0 && currentDig[i] == 1) { | ||
- | // usbMIDI.sendNoteOn(digitalpitch[i], | ||
- | // currentDig[i] = 0; | ||
- | // } | ||
- | // } | ||
- | |||
- | //// digital pins sending CC | ||
- | |||
- | for (int i = 0; i < numDigPinsCC; | ||
- | if (digitalRead(digitalpincc[i]) == 1 && currentDigcc[i] == 0) { | ||
- | usbMIDI.sendControlChange(i+digccstart, | ||
- | currentDigcc[i] = 1; | ||
- | } | ||
- | if (digitalRead(digitalpincc[i]) == 0 && currentDigcc[i] == 1) { | ||
- | usbMIDI.sendControlChange(i+digccstart, | ||
- | currentDigcc[i] = 0; | ||
- | } | ||
- | } | ||
- | |||
- | //// analog pins | ||
- | |||
- | for (int i = 0; i < numPins; i++) { | ||
- | |||
- | newVal[i] = analogRead(analogPins[i]); | ||
- | | ||
- | if (abs(newVal[i] - currentVal[i])> | ||
- | { | ||
- | usbMIDI.sendControlChange(i+analogstartcc, | ||
- | currentVal[i] = newVal[i]; | ||
- | } | ||
- | | ||
- | |||
- | } | ||
- | | ||
- | // i think if you remove these last two lines everything breaks and things are sad and people cry | ||
- | while (usbMIDI.read()); | ||
- | delay(5); | ||
- | } | ||
- | |||
- | } | ||
- | |||
- | |||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ===== Photos ===== | ||
- | |||
- | {{tag> |