vendredi 11 janvier 2013

Shield

Sart again from the beginning. The proof of concept is done, so now I will try to improve oboïno functionalities and make a better conception.

First of all : make a shield.
This will allow me to add/remove every analog or digital input without unsoldering everything.
The shield will give access to all the 6 analog inputs of UNO, and 10 digital inputs (this will be enough). I will put a MIDI OUT (new functionality).
Connections are arduino basics. Digital pins are connected like this :
http://arduino.cc/en/Tutorial/DigitalReadSerial

Analog like this :
http://arduino.cc/en/Tutorial/AnalogReadSerial

And MIDI like this :
http://arduino.cc/en/Tutorial/Midi

Each analog inputs come with 3 pins connectors.
All digital inputs are connected with a 16 pin connector. I use 11 pins :
1 pin to bring 5V to each switch
10 pins to connect switches to arduino digital inputs.

Here is the top :


Here is the bottom :

Parts :
 - 2.54 mm male pin headers :
http://dx.com/p/2-54mm-1x40-pin-breakaway-straight-male-header-10-piece-pack-144191

 - prototyping PCB :
http://dx.com/p/double-sided-glass-fiber-prototyping-pcb-universal-board-3-x-7-5-piece-pack-131730

 - 10 x 10k resistors
 - 220 ohm resistor
 - MIDI connector
 - 16 PIN standard 2.54 mm male connector

samedi 25 août 2012

Oboino V1 video


Here is the V1.
Oboino is controlling a Processing synth.
Everything is working, but buttons are too hard.
Next version, I will change them, and try to put some MIDI output.

Processing code

Here are extracts of processing code to use captors and controlling a synth (the synth is not detailed here) :

1. Variable declaration

import processing.serial.*;
import cc.arduino.*;

Arduino arduino;
boolean noteon[] = new boolean[14];
int note=0;
float analogvalue[] = new float[6];
boolean play = false;
boolean selec = false;


2. SETUP
Initialization of arduino things

void setup() {
  size(470, 280);
  arduino = new Arduino(this, "COM5", 57600);
 
  for (int i = 0; i <= 13; i++)
  {
    arduino.pinMode(i, Arduino.INPUT);
    noteon[i]=false;
  }
 
  for (int i = 0; i <= 5; i++)
  {
    analogvalue[i] = 0;
  }
}


3. Function "Findnote"
It will search which note to play when buttons are pressed

void findnote()
{
  if(noteon[10]&&noteon[8]&&noteon[7]&&noteon[6]&&noteon[4]&&noteon[3]&&noteon[2])
    note = 1;
  if(!noteon[10]&&!noteon[9]&&noteon[8]&&noteon[7]&&noteon[6]&&noteon[4]&&noteon[3]&&noteon[2])
    note = 2;
  if(!noteon[10]&&noteon[9]&&noteon[8]&&noteon[7]&&noteon[6]&&noteon[4]&&noteon[3]&&noteon[2])
    note = 3;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&noteon[7]&&noteon[6]&&noteon[4]&&noteon[3]&&noteon[2])
    note = 4;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&!noteon[7]&&noteon[6]&&noteon[4]&&noteon[3]&&noteon[2])
    note = 5;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&noteon[7]&&!noteon[6]&&noteon[4]&&noteon[3]&&noteon[2])
    note = 6;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&!noteon[7]&&!noteon[6]&&!noteon[5]&&noteon[4]&&noteon[3]&&noteon[2])
    note = 7;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&!noteon[7]&&!noteon[6]&&noteon[5]&&noteon[4]&&noteon[3]&&noteon[2])
    note = 8;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&!noteon[7]&&!noteon[6]&&!noteon[4]&&noteon[3]&&noteon[2])
    note = 9;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&!noteon[7]&&noteon[6]&&!noteon[4]&&!noteon[3]&&noteon[2])
    note = 10;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&!noteon[7]&&!noteon[6]&&!noteon[4]&&!noteon[3]&&noteon[2])
    note = 11;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&!noteon[7]&&!noteon[6]&&!noteon[4]&&noteon[3]&&!noteon[2])
    note = 12;
  if(!noteon[10]&&!noteon[9]&&!noteon[8]&&!noteon[7]&&!noteon[6]&&!noteon[4]&&!noteon[3]&&!noteon[2])
    note = 13;
}



4. Function "Draw"
 
void draw() {
  background(off);
  stroke(on);
 
  for (int i = 0; i <= 13; i++) {
    if (arduino.digitalRead(i) == Arduino.HIGH)
      {
        if(!noteon[i])
        {
          noteon[i] = true;
          play = false;
        }
      fill(on);
     
    }
    else
    {
      if(noteon[i])
        {
          noteon[i] = false;
          play = false;
        }
      fill(off);
    }
   
    rect(420 - i * 30, 30, 20, 20);
  }
 
  findnote();
 
 
  for (int i = 0; i <= 5; i++) {
    analogvalue[i] = arduino.analogRead(i);
    ellipse(280 + i * 30, 240, analogvalue[i] / 16, arduino.analogRead(i) / 16);
   
  }
 
  if(analogvalue[5]>550)
  {
   
    if(!play)
    {
      play = true;
  //////// Here you can put the "note on" of your synthetisor
    }
    else
//////// Here you can put the "change volume function" of your synthetisor
//////// => volume is analogvalue[5]
   
  }
 
  else
  {
    if(play)
    {
      play = false;
//////// Here you can put the "Stop function" of your synth
    }
  }
//////// Here you can put the CC values of your synth (filter frq, resonance, ...)
//////// => values are analogvalue[i]
}

lundi 16 juillet 2012

Notes

Push-buttons positionning must respect saxophone or clarinet key positions. Left inch will switch octave key, and right inch will support the instrument. switches 5, 9 et 10 will be pressed by auricular, so they must be off-center.

Pour placer les boutons-poussoirs sur le tube support, respectons à peu près la disposition d'une clarinette ou d'un saxophone. Le pouce gauche sera la clé d'octave, et le pouce droit aura un support qui lui permettra de tenir l'ensemble de la structure. Les auriculaires actionneront l'équivalent des clés sur la clarinette. L'auriculaire droit aura ainsi le choix entre les boutons 5 et 9 (les boutons 5, 9 et 10 devront être désaxés par rapport à l'ensemble pour que les auriculaires arrivent à les atteindre)

Here is a possible implementation, close to saxophone keys (which has an octave key easier than 17th key of clarinet). After we will make more simple implementation, but it will permit to clarinetists or saxophonists not to be constrained.

Voilà une première implémentation possible, au plus proche de ce qui se fait sur un saxophone, dont la clé d'octave est plus simple que la clé de 17ème de la clarinette. On pourra ensuite inventer de nouveaux doigtés plus simples, mais ça permettra de ne pas être trop désarçonnés pour des clarinettistes ou saxophonistes.



jeudi 12 juillet 2012

Processing


Download Processing here:

http://processing.org/download/


Then install it (in fact, need to install it, it's an executable).


I will test the project in Windows and Linux. There is no reason that it does not work on mac. Processing is based on the java and is cross-platform.

Now I have to choose the strategy for developing the software "Obogen" that will translate the information received from Oboïno, or MIDI messages. Two perspectives:

1. Installing Firmata on the arduino. Firmata is a standard program for the arduino, which allows to directly access information from its input / output analog and digital instructions from Java Processing. In addition to installing Firmata on the arduino, it is necessary to associate the library in Processing.
The advantage is that there is no need to code anything for the arduino, and once flashed Firmata, we no longer need to update it. All updates are done in Processing.
http://www.arduino.cc/playground/interfacing/processing

2. Coding special software on the Arduino, and use the serial port to communicate between Processing and Arduino (the USB port on the arduino is really a serial port in disguise). The instructions are more difficult to implement in Processing (listening to the serial port, interrupt handling, data recovery in the buffer ...) and I will surely come back several times on the arduino code, and have to flash the chip every time I make changes.

Clearly, the first solution is the simplest. This is one I will use initially make Arduino and Processing communicate. It will be sufficient to develop Obogen. By cons, when to send MIDI output of the arduino, or generating sound signals, the second method will be needed.




Télécharger Processing ici :
http://processing.org/download/
Puis l'installer (en fait même pas besoin de l'installer, c'est un exécutable).
Je testerai le projet en Windows et Linux. Il n'y a pas de raisons que ça ne marche pas sous mac. Processing étant basé sur du java, il est multi-plateforme.

Maintenant, il faut choisir la stratégie pour développer le logiciel "Obogen" qui traduira les informations reçues de l'oboïno en son, ou en messages MIDI. Deux optiques :

1. Installer FIRMATA sur l'arduino. Firmata est un programme standard pour l'arduino qui permet ensuite d'accéder directement aux informations de ses entrées/sorties analogiques et numériques à partir d'instructions Java dans Processing. En plus de l'installation de Firmata sur l'arduino, il faut mettre la library associée dans Processing.
L'avantage c'est qu'il n'y a pas besoin de coder quoi que ce soit pour l'arduino, et qu'une fois le Firmata flashé, on n'a plus besoin de le mettre à jour. Toutes les mises à jour se font dans Processing.
http://www.arduino.cc/playground/interfacing/processing

2. Coder un logiciel spécifique sur l'arduino, et utiliser le port série pour communiquer entre Processing et l'arduino (le port USB de l'arduino n'est en fait qu'un port série déguisé). Les instructions sont plus fastidieuses à mettre en place dans Processing (écoute du port série, gestion d'interruptions, récupération de données dans le buffer...), et il faudra sûrement revenir plusieurs fois sur le code de l'arduino, c'est à dire le reflasher à chaque fois qu'on apporte une modif.

Clairement, la première solution est la plus simple. C'est celle que j'utiliserai dans un premier temps pour faire dialoguer l'arduino et Processing. Ca sera donc suffisant pour développer Obogen. Par contre, quand il faudra envoyer des messages MIDI en sortie de l'arduino, ou générer des signaux sonores, la deuxième méthode s'imposera. 

Arduino's choice / Choix de l'arduino

Arduino list / Liste des arduinos :
http://arduino.cc/en/Main/Hardware

For prototyping, UNO is better, we can find numerous shields like MIDI shield, or Bluetooth Shield. After prototyping, Arduino Mini or Nano will be better, because they are smaller and have more analog inputs.

Pour le prototypage, je prends un arduino UNO, on peut trouver de nombreux shields qui faciliteront la vie (shield MIDI, shield bluetooth...). Par la suite il vaudrait mieux prendre un arduino mini ou nano, qui ont plus d'entrées analogiques, et qui sont plus petits. 

Electronic schema / Schéma électronique

Here is the very simple Oboïno schema. 10 switches plugged to Arduino numerical in with a resistor, and analog sensors directly plugged to arduino analog inputs.

Voici le schéma on ne peut plus simple de l'oboïno. Il suffit juste de brancher 10 switchs aux entrées numériques (avec une résistance qui évitera de relier la masse au 5V quand le switch est fermé), et les capteurs analogiques aux entrées analogiques (je n'en ai représenté que deux, on peut aller jusqu'à 6).