Cubic Bézier​ Curves

A project log for Concertina MIDI Controller

A Bluetooth LE MIDI controller in the shape of an English concertina

Dave EhnebuskeDave Ehnebuske 08/19/2019 at 18:540 Comments

Before embarking on a redesign of the bellows to make it less springy, I decided to fiddle with the function that translates bellows pressure into MIDI expression. I'd been using a function of the form expression = a*ln(pressure) + b* pressure + c for no good reason other than that for suitable values of a and b it rises quickly and then flattens out which more or less is what I think a traditional concertina feels like it does. But after playing it for a while, I decided I didn't like how it jumped in volume at low bellows pressures. A traditional concertina requires a minimum pressure to do anything at all and then rises slowly for a bit and then quickly until finally flattening out again.

In casting about for a a curve that looks like that, I sketched it out in Adobe Illustrator. Which got me to thinking, why not use the same kind of curve used in vector graphics programs and standards: cubic Bézier curves. A cubic Bézier curve is a continuous vector-valued function of t where t is a real number in the range 0 to 1. The function's values sweep out a curve between two points called "anchor points" as t goes from 0 to 1. The shape of the curve between the anchor points is controlled by two other points called "control points." Because of this, not all Bézier curves are functions where y = f(x) -- which is what I need -- but many are, and it's easy and natural to control the the shape of the curve if you've ever used a vector graphics program like Illustrator or Inkscape.

So, I implemented a change that calculates a pressure-to-expression lookup table using a cubic Bézier curve. The table is calculated during initialization and used at runtime. The feel is much improved and it's easy to fine tune how it behaves. Plus designing and implementing this change gave me a really good reason to look into the nuts and bolts of Bézier curves, which I've used in Illustrator and SVGs for years but never really studied.