Today I am going to show you how I have managed to use capacitive touch in conjunction with the piezo transducer to enable pitch changes within a pad.


In the example I was given at QMUL for using MPR121s, a sine wave of different frequencies plays every time a different electrode is touched. However, in order to have all of the control on the Pure Data side of things, I wanted to send a raw data stream, same as I had been doing with the Raspberry Pi in the old setup.


Luckily, I found a couple of commented out lines for debugging that did exactly that and printed the data. With some help from Chris at Enzien Audio, I managed to turn this into a message that could be interpreted by Heavy audio tools and sent into my compiled pure data patch. Then in Pure Data, I would be able to receive those values and use them for anything I could think of (within the possible).

The function looks like this:

void readMPR121()
  for(int i = 0; i < NUM_TOUCH_PINS; i++) {
  sensorValue[i] = -(mpr121.filteredData(i) - mpr121.baselineData(i));
  sensorValue[i] -= threshold;
  if(sensorValue[i] < 0)
  sensorValue[i] = 0;
        hv_vscheduleMessageForReceiver(gHeavyContext, "sensorValues", 0, "ff", (float)i, (float)sensorValue[i]);


For now, all I wanted is to check this worked so I made each electrode send a different frequency to the KarplusStrong patch I was already using. This is how it looks on Pure Data:



And this is what it sounds like:


Not a bad start. The next steps are getting all four MPR121s to work simultaneously (by giving them different I2C addresses) and setting rules for multi-touch within each pad (like playing a chord when more than 2 electrodes are touched at the same time).


On another note, Bela platform gets released on Kickstarter tomorrow so make sure to check Bela.io!