TEENSY - DIY midi Touch controls with Teensy 3.x, code included

Started by PD FX, April 16, 2015, 08:41:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PD FX



6 touchpads are mounted close to the strings, so that they can be touched like normal strings. They are connected to a microcontroller, that generates midi controls accordingly. Some assignments in the Roland GR55 make the trumpets appear when you touch them. I'll do a more technolike example later.



I've placed small brass parts between the string, touching them creates a midi controller command. The teensy is mounted in the bridge pickup hole, under the touchpads, for short wires are recommended for using Teensy's touchread() function.
The teensy is connected to my laptop, and a software bridge routes the midi commands to my GR55. that way i could test this without too much extra wires going to my guitar, just 1 usb cable.
Using stan dard midi is also possible: I've included it in the code. But please start with the usb route, for the touchsensors might make some noise on your normal pickups, you should test it out yourself. I use a piezo guitar here, piezos are not so sensitve to interference.

cheers,
Paul


Small demo of a simple touch interface for Teensy 3.x, here used together with a Roland GR55.
I've shared the example code below:

// --------------------------------------
// touchMidi for Teensy 3.x
// --------------------------------------
// A very simple midi touchcontrol interface
// Compile with tools/ usb type: midi.
// outputs standard midi and usbmidi
// The teensy needs a usb connection to be powered, but you can also use a standard usb powersupply.
// Connect touchpins/pads to A1,A2,A3,A4,A5 & **A8**, they will deliver cc's 1,2,3,4,5 & 6
// the touchsensitivity can be adjusted by connecting a potentiometer to A9.
// Using the assigns in Roland equipment like the GR55, one can make a hexaphonic killswitch or the opposite: a "note on touch",
// which turns your guitar into some kind of piano or whatever.
//
// Paul Driessen, April 2015

// here the settings
//int touchPin[6]={A1,A2,A3,A4,A5,A8}; // the touchpins used, there are 12 touchable pins on a Teensy 3.x.
int touchPin[6]={A8,A5,A4,A3,A2,A1}; // reversed mount, the touchpins used, there are 12 touchable pins on a Teensy 3.x.
int touchCc[6] ={1 ,2 ,3 ,4 ,5 ,6};  // and the cc's send  by them, you can change them to whatever you want, ranging from 1 to 127
int touchCh[6] ={1 ,1 ,1 ,1 ,1 ,1};  // midichannels used, from 1 to 16
int sensePin= A9;                    // optional: for the sensitivity potentiometer
int treshold=1200;                   // default sensitivity, lower is smore sensitive.



void setup()
{
  Serial1.begin(31250); // the midi output, so you can e.g. connect a Roland GR55 or VG88/99 straightaway.
  analogReadRes(10);    // not too much resolution for the sensitivity pot.
}

int actSense=0;
boolean touching[6];                 // keep track of the touch-state                 
void loop()
{
  /*int trySense=analogRead(sensePin);  .//uncommment this section for using sensitivity pot.
  if(trySense!=actSense)
  {
   actSense = trySense;
   treshold = actSense << 6;  //
  }  */
  for(int tp=0; tp<6; tp++)   // start of "read all touchpins" loop..
  {
   int tryRead=touchRead(touchPin[tp]);
   if(tryRead>treshold)
   {
     if(!touching[tp])               // if we tought we were untouched
     {
       touching[tp]=true;            // yes, we are touched..
       Serial1.write(0xB0 + touchCh[tp]-1);// cmd=control. midichannelnr's are hard, and 0 based.
       Serial1.write(touchCc[tp]);   // cc from settings..
       Serial1.write(127);           // = on
       usbMIDI.sendControlChange(touchCc[tp], 127, touchCh[tp]); // usb midi cc  version 
     } 
   }else{
     if(touching[tp])
     {
       touching[tp]=false;            // no more touching..
       Serial1.write(0xB0 + touchCh[tp]-1); // cmd=control
       Serial1.write(touchCc[tp]);    // cc from settings..
       Serial1.write(0);              // = off
       usbMIDI.sendControlChange(touchCc[tp], 0, touchCh[tp]); // usb midi cc  version 
     }
   } 
  }                           // end of "read all touchpins" loop..
} // end of main loop() 





maxdaddy

Wow. What exactly is going on there with the right hand?

PD FX

Quote from: maxdaddy on April 16, 2015, 08:23:16 PM
Wow. What exactly is going on there with the right hand?
thanks maxdaddy, I've made a more tap and touch style demo, you can see that I tip the sensors to play the flute lead sound .

richfromne2

 :) Pretty  amazing.  Are you going to post the other video ? Not 100% sure what part of the sound is  originating from the touch sensors.

PD FX

Quote from: richfromne2 on April 17, 2015, 11:09:07 AM
:) Pretty  amazing.  Are you going to post the other video ? Not 100% sure what part of the sound is  originating from the touch sensors.
thanks! and..aw, this is allready the second video, the high pitched flutesound is switched by the touch sensors. The idea is, to be able to use the synth only where you need it, so you can decide per note whether you want a synth there, or not.. secondly, it avoids having to damp the open strings, and enables you to dial in the pcm synth more sensitive.

gumtown

So the touch sensor is mounted at the bridge, I am not quite sure how this is working?
I assume it is not contacting with the strings, are the touch pads raised above the strings?
I can't quite see how it is working without damping the strings.

Impressive playing though!!  :)
Thank You for sharing  ..
Free "GR-55 FloorBoard" editor software from https://sourceforge.net/projects/grfloorboard/

PD FX

Quote from: gumtown on April 17, 2015, 03:00:13 PM
So the touch sensor is mounted at the bridge, I am not quite sure how this is working?
I assume it is not contacting with the strings, are the touch pads raised above the strings?
I can't quite see how it is working without damping the strings.

Impressive playing though!!  :)
Thank You for sharing  ..
thanks, Gumtown.. and yes, the pads are raised above the strings. My initial idea is to tunnel the strings through the lusterterminal  s I use for the pads, so that you can tip the pad without inadvertedly touching the string. But I'm not sure whether or not this is a good idea: it is better to have some kind of shielding in between the pads and the strings, if you want to use this with a magnetic pickup.
I've changed the first video, so that you have a better look at how my setup is. I'm sure it can be done better.
For the sake of being complete, here the last vid, with closeup of the pads:

stingray05


Hi, Guitarpolson

just found your very interesting contribution by chance - and copied it as a test - works wonderfully!

I would like to extend the code so that a query between strings and frets also works for note recognition.

If I use the principle of a keyboard matrix, I need a lot more TouchSense PINs than the Teensy 3.2 has.
(29 touch sense PINs, for 5-string bass with 24 frets).

Which port expander is the easiest to use (MPR 121?, Which would you recommend)?
Can the Expander TouchSense PINs be used in addition to the Teensy TouchSense PINs?


wish you "rest of Easter" - stay healthy


Greetings from Germany
Greetings from Germany - and please stay healthy in these difficult times!

-----

WIN 10
Cantabile Performer
Guitar Wing
Komplett 11 Ultimate
Sampletank 3
VB 99, GR 55, US 20, FC 300
MM Stingray 5 with GK Kit BG
Dingwall Lee Sklar with GK Kit BG + Graphtech Piezo

PD FX

hi, Stingray!
Glad somobody finds it usefull ;)
You cant use this touch for scanning which strings are pressed on which fret.
The touch works with capacitance and it will not work with frets and multiple strings pushed on mutliple frets. the matrix is not solvable for all chords and fingerings that way. Also the touch functions can not work with so much capacitance.







stingray05


Hi Guitarpolson,

Thank you for your prompt reply !


It was already clear to me that the contact works via capacitance ...

Did you actually use resistors in series with the touch pin input?

In theory, I thought of it like this:
Strictly speaking, your system is already half an XY "keyboard matrix" that would be used to determine the Midi notes on the fingerboard (5 lines / 24 columns) ...
In addition, "only" the 24 frets would have to be queried by (capacitive) touch.
Each fret would be an additional touch sensor with a fixed midi note.

Touching the strings would then shift the given midi notes by the appropriate fourth ...

In order to be able to test that, I miss the TouchSense pins mentioned.
You used 6 pins. For my idea, I need 5 for the strings and an additional 24 for the frets (a total of 29 ...) ...

Hence the question of what can be used as an expander for the touch pins?

stay healthy

Greetings from Germany
Greetings from Germany - and please stay healthy in these difficult times!

-----

WIN 10
Cantabile Performer
Guitar Wing
Komplett 11 Ultimate
Sampletank 3
VB 99, GR 55, US 20, FC 300
MM Stingray 5 with GK Kit BG
Dingwall Lee Sklar with GK Kit BG + Graphtech Piezo

PD FX

what I tried to explain is, that you can not use touch for scanning strings and connected frets.

let me give an example
imagine a chord: 577655  ( A major bar chord at fifth position )
now scan string 6.
fret 4,5,6 & 7 seem touched by string 6!
In fact, all strings will seem touching fret 4,5,6 & 7...

The reason is that your chord connects all these frets together, giving no clue where each indivual string is fretted for any simple touch function.

stingray05

Hi Guitarpolson,

of course you are absolutely right with your objection - at least when you try to use the frets together with
the strings as galvanic switches.
With the capacitive method I am not quite sure whether the problem actually occurs (see link).

Have you ever tried to pick up frets and strings capacitively, but (individually)?

OMB Guitars does note recognition, for example, by capacitively querying the frets and the strings.
This LINK https://www.vguitarforums.com/smf/index.php?topic=28193.msg205490#msg205490,
post # 3 in the third and fourth video, shows how this is assembled.

Interestingly, the fingerboard has only one sensor, the strings are queried individually ... -


So it seems to work with far fewer sensors than in my example with sensors for every fret and every string.

Anyone have an idea how this system can work?
Greetings from Germany - and please stay healthy in these difficult times!

-----

WIN 10
Cantabile Performer
Guitar Wing
Komplett 11 Ultimate
Sampletank 3
VB 99, GR 55, US 20, FC 300
MM Stingray 5 with GK Kit BG
Dingwall Lee Sklar with GK Kit BG + Graphtech Piezo

PD FX

he certainly dont use the matrix method, because that doesn't work.
Most likely he uses the "time of flight" method (there are actually mulitple methods, but this one seems most probable, because of what I see htere)
A signal pulse is put on the string at the bridge, the pulse travels thourgh the string,  to the fret pressed, the fret is connected to a ground line that is not really a ground line, is it lifted of the ground by an inductance, but the impedance is low enough to rule out the finger capaitcance (the inductance has most likely a resistor parallel). This returned signal is then fed back to the inverting input of the amp, thus switching the sign of the signal, starting the second half of the period.
The length of the loop then determines the oscillators frequency. A frequency counter then counts the frequncy, and calculates the loop lenght and therefore the fretted fret.