Sunday, August 12, 2012

MIDI Breath Controller: Phase 2 completion thoughts.



As mentioned, a video of the breath controller in action, as well as a description of what the various parts of the controller are for.

There are some aspects about this that I don't like yet, that I hope to rectify next.

First, the actual blowing aspect. Because I'm now just blowing down a tube, if I actually put too much lip pressure on the tube, it collapses and needs more pressure to get the high values. I think some sort of mouthpiece needs to be constructed for it. Maybe like a used saxophone mouthpiece, or something in the shape of a recorder's mouthpiece.

I still haven't considered how to make it hands-free, as I need that capability in the future. More tweaking of the physical layout of the tubes is also probably required to try to maximize the dynamic range of the sensor. Right now I'm only using about 2/3 of the range.

Next, I'd like to test out various sensitivity curves on the data. Right now, it is just directly remapping 0-1023 to 0-127. I'd like to see the results with a power function applied, so if you are playing a soft piece, a value of 2 will give most of the range to the softer side of things, and if you need loud fast, applying something like 0.4 will give you that.

Maybe I can have a footswitch of sorts that would allow us to dynamically switch between pre-defined curve types, so if I'm in a loud staccato passage, I can use 0.4, then back to 1 for normal passages, and 2 when I need more dynamics on the softer side of things. Mmmmm. I like cheese.

Hardware wise, I'd like to move on to using the MPX5010GSX, so I can bypass all the external circuitry for power and signal amplification. Curiously, I wonder if this sensor will provide similar performance to the one I'm using now.

I also want to miniaturize the arduino side of things. There are many "minimal arduino" setups around, only needing a few discrete components to work. There are two versions I'd like to build, one designed to work at my daw, and one that is portable for performance.

Given that I only need ONE input, and that the requirements seem to be so minimal (I mean, 4 lines of code?), instead of using a full blown AtMega chip, I could look into using one of the slower, more compact microcontrollers (e.g. tinyAVR).

Oh, here's the full arduino code:

/*
11th August 2012
Breath controller code by Alvin Yap

Use at your own risk!

*/

#include 
int serialDebug = 0;
int breathInput = 0;


void setup() {
  // put your setup code here, to run once:
  
  if (serialDebug)
    Serial.begin(9600);
  else
    MIDI.begin();
}

void loop() {  
  
  breathInput = map(analogRead(0),0,1023,0,127);
  
  if (serialDebug)
    {
    Serial.println(breathInput);
    delay(50);
    }
  else
  {
    if(breathInput >0)
      MIDI.sendControlChange(2,breathInput,1);    
  }

  delay(41); // sleep for 41 milliseconds; 
  // so assuming there is actually some values detected, we only send about 24 messages a second. 
}


As you can see, if I were to strip out the debug code, the essence of it can be run with about 4 lines:

breathInput = map(analogRead(0),0,1023,0,127); // read and remap
if(breathInput >0) 
 MIDI.sendControlChange(2,breathInput,1); // send cc if it is more than 0
delay(41);  

 That said, to reach these 4 lines took me like 1 hour+ to figure out how to send CC data to the daw, testing said commands, then finally integrating the hardware and software (*cough* one wire *cough*), as well as completing some side quests in Solatorobo and Ocarina of Time. I think the side quests took most of that time.

Also, sampling. There is no filtering right now. Sending the midi data at about 24 times a seconds seems to work much better than my original tests at 100 times a second. In fact, a lower value may even work better, but I'll have to test it.

Finally, I am also pondering about how to connect the device to the pc on its own. Using the midi route is fine, but what about midi over usb? Stuff like that would probably be more tedious to implement, but if the software works well, I think porting it over for midi over usb won't be too difficult. Maybe. Hopefully :P The key advantage would be using usb directly for power, as with the arduino, instead of having to have batteries or some power hookup.

What's next?
Given that I started this project about a year ago and only spent like maybe 8 hours on it in the last 2 weeks, I'm the penultimate king of slackers (*rawr*) I'm going to put this aside for a bit and figure out how to do watercolours, I'll be back.... someday. Heck, I still have a ribbon mic to build.

7 comments:

Patrick Woo said...

Amazing, dude, and in a few hours too!

Was your Oxygen keyboard controller on a keyboard stand, or was it on some kind of suspension rig? It was moving about in a precarious sort of way, and I didn't understand what was holding it up, so I asked :)

Gallen Wolf said...

Yo yo!
Actually the keyboard is just sitting on my lap :P

deep said...

Inspiring project! Thank you for posting it...
Did you try the 5 Volt sensor(MPX5010)?
I' m working to a MIDI trombone...
Andrea.

Gallen Wolf said...

Hello!
I haven't yet got the MPX5010 as I can't seem to find stock of it in the UK. That has got to be easier to use than the sensors I've used :) Do you have a wip of your midi trombone?

deep said...

I found a similar component here in Italy, MPX5010 GX, I' m going to order it tomorrow and let you know...
For now the trombone is just a sketch on the paper, but i made some experiments with pitch bend using arduio+ linear encoders from old printers. It works :)
I'll update you if something moves on...
Ciao!

Gallen Wolf said...

All the best dude :)

Gasblaster said...

I'm planning to use the MPX5010 to build a workalike clone of a Yamaha BC3a breath controller that can be simply plugged directly into a Kurzweil keyboard.

Since these have been discontinued by Yamaha for a few years now there is an incredible demand for them.

Thread where this is being discussed is

http://www.cunka.com/forum/index.php?topic=4269.0

My source for the MPX5010 is here for $16 apiece in North America

http://ca.mouser.com/ProductDetail/Freescale-Semiconductor/MPXV5010DP/?qs=sGAEpiMZZMt7FrWooXVB10Y9ARi1Fcfd

With any luck with a prototyping board, the sensor, a couple of 2N2222's a 5 V Zener Diode and a few caps, resistors and a trimmer and the cheapest hardware money can buy I should be able to crank one out for under $35 give or take.

Feel free to join the discussion over at cunka.

Gary