Tuesday, April 9, 2013

Polysix - Aftertouch Curves

After the success of simply getting the aftertouch system working on my Korg Polysix, now comes the effort to tune the response of the system so that the *feel* of the aftertouch is just right.  The feel of the aftertouch has a bunch of components: the physical resistance of the keybed, the force needed to initiate the aftertouch, and the sensitivity of the aftertouch to increasing pressure.  This last bit is defined by the "response curve", and it's the creation of my own response curve that I'm focusing on today.

Gathering Aftertouch Data via my Arduino Mega (the Blue Board in the Back)
The first step in tuning the aftertouch response is to be clear how aftertouch works in my system.  My new Fatar keybed (bought from Keyparts UK) has the aftertouch pressure sensor built-in.  This analog sensor is a long force sensitive resistor whose resistance drops when pressure is applied.  The sensor strip is plugged into the keybed scanning electronics (also from Keyparts UK).  The electronics include some sort of circuit that senses the resistance of the strip and generates a MIDI aftertouch message as pressure is applied.  The MIDI message includes a data field who's value is increases with increasing pressure.  What this sensor looks like, or how they convert their measured value into a MIDI data value, I'm not sure...but it has a strong effect on how the aftertouch feels.  It is especially important for defining the force required for the onset of the aftertouch effect.  Currently, I have no control over this part of the aftertouch response.

Once the electronics generate a MIDI aftertouch message, it is conveyed to my Arduino Mega via the Arduino's built-in TX/RX serial connections.  When the Arduino receives an aftertouch command, it induces pitch changes (vibrato) in the Polysix.  The magnitude of the vibrato is proportional to data value in the aftertouch MIDI message.  So, more key pressure generates a MIDI message with a bigger data value, which causes my system to put more vibrato on the pitch.  Easy.  But to be musically useful, the amount of vibrato needs to be controllable via the amount of force that I put on the keybed (not just ON or OFF), which means that the scaling between key force and vibrato response needs to be just right.

So, to get that scaling "just right", we need to get quantitative.  I need to record the actual aftertouch values generated by my system as I press on the keys.  Since I've got the Arduino in the system, I'm able to easily echo the MIDI aftertouch messages through the Arduino to my PC for logging and analysis.  Below is a plot of the aftertouch data values logged by my PC for three key presses.


As you can see, the aftertouch values span 0-127, which the full range allowed in the 7-bit space afforded by aftertouch MIDI message.  The next thing to notice how steep the curves are at the beginning and end of the each key press.  Being very steep means that my vibrato comes on strongly and suddenly.  My goal is to smooth that out so that I can have better control over more subtle amounts of aftertouch-induced vibrato.

My approach is to take the in-coming aftertouch value and to re-map it to a new value using my own aftertouch response curve.  The new response curve will be shaped to reduce the slope of the onset of the aftertouch.  Since I don't have the ability to set the response curve inside the keyscanning electronics (yet), I will have to implement the new response curve in the Arduino.  Fine.  But what response curve should I use?  I don't know.  We'll have to try some out.

Below is one of the first candidate curves that I tried.  It is simply two linear segments stitched together.  For small aftertouch values (like the onset), the slope is reduced so that the onset is more gentle.  This sounds like what I want.  The plot on the right shows the data from one of the key presses from the graph above.  The blue curve is the raw data.  The green curve is the re-mapped data.  Note that, yes, the steep onset is reduced, but I don't like that flat plateau that follows the onset.  That plateau will feel like a dead spot where nothing happens.  That isn't good.  Pressing harder should give a stronger response.  This is a Fail.


My next attempt at a new response curve was just a shot in the dark.  I tried an exponentially shaped curve because I knew that it would have a gentle slope at the beginning of the response and that it would smoothly transition up to its steeper portion (see the left-hand plot below).  Sounds good, right?  Unfortunately, as you can see in the right-hand plot, it's onset is far too gentle and its output stays low for far too long.  Then, finally, towards the climax of the keypress event (when the force is highest), the response suddenly leaps relatively from a low value up to the maximum allowed value.  Bad.  Again, Fail.


I then tried a whole bunch of other curves.  Lots and lots.  You can see many of them plotted together in the figure below.  Some of them looked decent enough on paper to be worth trying on the Arduino.  So, I coded them up as a simple look-up table and gave them a test drive.


After trying a bunch of curves, and after iterating the details of the most promising candidate, I finally converged to the curve below -- a curve made up of 4 linear segments.  As you can see in the right-hand plot, the new onset and release seen in the green curve is very smooth.  It gives me the best control (that I could find through this guess-try-and-tweak method) over both subtle and strong amounts of vibrato.  It feels pretty darned good!


My remaining criticism with the response of my aftertouch is that it takes too much force to get the aftertouch started.  Sadly, I have no control over when the aftertouch starts -- the start of the aftertouch is entirely set by when the keyscanning electronics decide to start generating MIDI aftertouch messages.  Don't get me wrong, I think that the folks over at Keyparts UK set a very good general-purpose aftertouch threshold into their keyscanning electronics.  I just think that *I* like my aftertouch to start with far less force than most other folks.  I like it to start with a mere feather of a force...an amount that would drive other folks crazy.

To address this "problem", I'm thinking that there's probably a configuration setting in the keyscanning electronics that'll let me adjust the aftertouch threshold.  The electronics are amazingly configurable and under continued development.  I think that it's time for me to dive in and figure it out.  Fun!

Next Step: Tuning the Portamento

2 comments:

  1. Very detailed post, and thanks for the review on the Keyparts keybeds!

    I'm also a fan of light aftertouch (I miss my CS-60) and wonder how well that keyscanner board can be adjusted for lighter touch. Do you have the manual for it or a link where to buy? Google and the Keyparts site don't yield much.

    ReplyDelete
    Replies
    1. Hello Laurence,

      The Keyparts people are in the UK, so their web address is http://www.keyparts.co.uk.

      Visiting them again, I see that they still have not released their keyboard controller for public sale. If you email them, and reference my post, maybe they'll let you sell you a "beta version" (like they did for me).

      Their controller is a decent bit of kit. It's still working great in my Polysix.

      Chip

      Delete