giuliomoro Hi Giulio,
First, thanks so much again for making these changes to the centroid detection algorithm!!
Re non-monotonicity:
It turns out that the non-monotonicity in y-coordinates was indeed corrected by changing the prescalar from 1 (which i realized was for some reason set to 1 in my earlier tests) to 2. I did not need to use the /dev version of the code to see this improvement in monotonicity. See plots below.
Using the Bela code from /dev with the code that you provided in record-trill looks even better:
Re the oscillation in delta(finger position):
Many thanks for confirming here giuliomoro that you see the oscillation in delta(finger position) due to moving the finger across pads (where on each pad not all locations on the surface are not sensed equally, as you suggested). I am also replicating this oscillation with the /dev code. This oscillation does not really seem to go away with different noise thresholds, and actually seems to increase as I increase the prescalar settings.
This oscillation is my main concern, as I am sonifying the y-coordinate of the finger location by mapping the y-coordinate range (-1 to 1) onto a pitch frequency range of 1000 Hz, and was able to hear that as I moved my finger the pitches did not change at the same rate.
If I use a 500 Hz range, then the oscillation in pitch space is quite large, ~20 Hz for proximal sensor locations, which makes sense since the y-coordinates show an oscillation of ~.08, which is 4% of the y-coordinate range (-1 to 1):
Alternately, if I use a 200 Hz range, then the oscillation in pitch space is much smaller, ~5 Hz for proximal sensor locations:
So, if I choose a small enough pitch range and high enough frequencies then probably this oscillation in rate of pitch change across finger location is not perceptible. I think that this is a practical solution to this issue for my purposes, unless there is some additional parameter change that you think might help?
Again, many, many thanks for your input, and for looking into this issue!