Skip to content

Performance of DIY controller prototype

RIP

gzpiano Looking at the github data, its 2ms? across escapement for 1 m/s max velocity.

Well, that is self-referring. Based on http://mtg.upf.edu/mosart/papers/p35.pdf (e.g. Fig 2, 3 the text etc) it seems that the highest desirable velocities of the hammers reach at the very minimum 3.5m/s and hopefully 7m/s

gzpiano Nyquist for a frequency domain view of github data signal properties. What can do with data lowpass filtered to half the sample rate.

+1

(and thanks again for bearing with me with my insistence....)


RIP

@"stem_piano" I created a new repository
https://github.com/gzweigle/Piano-Data

I was wondering if you have investigated those oscillations and come to any conclusions. Some advertisement videos of the WNG action claim that wooden actions do oscillate (they have slowmo video demonstrating the effect) and I was wondering if what you are seeing might be real or an electronic effect.


gzpiano

My best guess is the frame that sensors are mounted on moves up/down for an instant, due to force of shank hitting stop.


RIP

Okay, so I did another back-of-the-envelope estimation of this issue, this time reversing the role of time and space, and the result is not so bad. @JayKominek you are probably interested in this (if you haven't already done it on your own).

For this discussion I continue to make the assumption of the hammers reaching 7 m/s velocities during fortissimos, and of a worst case (in terms of time/distance travelled) escapement settings at 1mm (typically it should be regulated at 1.5-2mm).

The velocity of 7 m/s is equivalent to a more conveniently thought of 7 mm/ms, which means that the hammer travels the escapement in 1/7 of ms, i.e. 0.14ms
If we are sampling each channel at 8kS/s that means that there is one sample every 0.12ms, so it's possible to have at most 2 samples during escapement travel, but most likely there will be only one. But let me assume we can always get two samples (if we don't we can increase the letoff or increase the sampling frequency modestly, so let's keep that assumption for now and I'll get back to this at the end of this post).

Assuming there are exactly 16 bits of ENOB data and about 40mm of total hammer travel, and assuming the sensors are linear enough and well biased, let me make the back of the envelope estimation of having 65,536 levels in those 40mm ~ 65mm or about 1,000 levels per mm. Some of these assumptions (linearity for sure) are most likely not valid, but I think that 1,000 levels on the last mm can be achieved with some care into powering the LEDs appropriately and biasing the phototransistor for the purpose.

So let me repeat the previous assumptions:

  1. we can measure two data points during hammer travel during letoff
  2. the distance between these two data points is about 1/7 mm or 0.14 mm
  3. each of these two data points is measured with a resolution of about 1/1000 of a mm

Now, if we further assume that resolution is close enough to the accuracy, we can conclude that we can measure this distance with about 1% accuracy.

Finally, I'm sure that the time accuracy between the samples have negligible inaccuracies, so we can conclude that our v=s/t will have a 1% accuracy too. From previous conversations (based on the same PDF linked above), we know that the actual MIDI velocities must be logarithmic in the raw physical velocities. That translates in 2% raw accuracy at high velocities being enough to get 1% accuracy in MIDI. Of course in all this I am neglecting the Savitzky–Golay filtering (or other sophisticated way of computing raw velocity) but I'm pretty sure those will not change these outcome substantially (especially since I'm doing back-of-the-envelope estimate and not full analysis).

So in conclusion, 8kS/s (or marginally higher) can be adequate, provided that the letoff is regulated in such a way to get two "free flight" samples (or equivalently that the pianist does not have a playing style in which he/she changes the speed at the very end of the keypress) -- and provided that all the other assumptions described above are met. So one does not need super-high sampling rates if one has fast enough, and if one has high-resolution enough, sort of what is hinted at https://github.com/jkominek/piano-conversion/discussions/31

Now (and this brings us back to the one vs two samples taken during let off), this require the software to be written by keeping this fact in mind, otherwise there could be missing notes. @gzpiano this might be the problem you are experiencing which is what triggered this thread? This can happen if the software triggers MIDI note-on only when the hammer is detected "close enough" to the sensor, and computes the velocity only in that circumstance (at least that's how I wrote my first version of my software in an effort to keep compute resources low). It is possible that the hammer is never detected that "close enough" because it travels too fast for the given sampling frequency. However, the software can easily consider the velocity too and estimates the next expected position, and realize that it would never see the hammer closer to the sensor because it would bounce before the next sample is detected. Then it can trigger the MIDI note-on with the best estimate of velocity it has, "regardless" of the position of the hammer (well, not completely "regardless", but with a much larger "close enough" and I'm talking sub-ms time here, so it won't be at the wrong time). This is easily distinguished from a apparently similar case in which the hammer is travelling so slow that it never reaches the sensor, but only if velocity is taken into account to decide whether or not triggering a note-on!


SouthPark

The 8 kilo-samples per sec thing and nyquist-related details definitely matters if you're tying to produce a frequency spectrum plot, right? Such as a magnitude versus frequency plot from samples data. I guess - as somebody mentioned - it also matters if trying to estimate a key velocity. Too much time between samples or too little time matters - depending on what the key velocities are. They face similar considerations in using encoders to estimate angular velocity in motors. If the motor turns relatively super slowly - as in takes forever, then that's one extreme. And then when it turns really relatively quickly - then that's another extreme.


SouthPark

Ideally - if it could somehow be all accommodated. Absolute encoder to monitor position. And another algorithm to monitor and detect movement (of the hammer). And this is just one hammer. And we know there's a whole bunch of them.

And when there's movement, a system to estimate whether the movement is relatively slow, or relatively fast - and in which direction. And another system to keep track of which zone (or zones) the hammer is in.

I have never gone down this path before - with measurements of key velocities, and hammer positions/hammer states etc. I definitely see that a heap of excellent work has been done here, and by Yamaha, Kawai etc (which no doubt the work has collectively been a contribution or culmination from lots of people). This is in the hardware and measurements and software control/logic/control departments and more. Outstanding work! Thumbs up.


SouthPark

Forgot to mention the escapement conditions as well. Definitely appreciating the hard yards that had been put into of that.


gzpiano

Math looks good.

Looking at github data, the velocity changes continuously during hammer travel. For example hammer is decelerating under the force of gravity during last moments of free flight.

So where to measure velocity? one picometer before hammer hits the "string" of course! sample rate > 1,000,000,000 per second.

But if I can't do that, then other options (approximations) become possible and my algorithm is not trying to measure the velocity after escapement.


SouthPark

hehe …. that's the main catch. If all the resources and focus can be put into one note or key, then that would be great. But with many keys and lots of processing and relatively high data rate …..

But I must say, got to hand to the people that have gotten the technology to this stsge. Impressive.


CyberGene

I was wondering how fast and reliable the ADC is when dealing with a very steep voltage change that comes from a sensor measuring a very fast hammer? Are there any specs regarding that? Because the ADC relies on charging a capacitor which is a time based thing and when having constant voltage you may increase the sampling rate (hence decrease the single sample duration) but when that’s also linked to a highly variable voltage, maybe the precision drops too?


SouthPark

CyberGene Great question. Here is related discussion about that kind of thing at : LINK


RIP

CyberGene I was wondering how fast and reliable the ADC is when dealing with a very steep voltage change that comes from a sensor measuring a very fast hammer? Are there any specs regarding that? Because the ADC relies on charging a capacitor which is a time based thing and when having constant voltage you may increase the sampling rate (hence decrease the single sample duration) but when that’s also linked to a highly variable voltage, maybe the precision drops too?

Sorry I've been quite busy and did not see this before. Certainly @JayKominek can answer more authoritatively, but here my sloppy version.

  1. I do not think all ADCs are based on charging a capacitor, but some certainly are
  2. The specs that I have seen (for example for the STM32H743 ADCs) explicitly mention the time it takes for the capacitor to charge as a limiting factor. Most of the discussion I saw was about the parasitic resistance of the multiplexer slowing down the charge of the capacitor, and hence having slower sampling rate when using that particular signal route compared to other available options which bypassed that multiplexer. So, yes, I think that the specs from reliable vendors keep this into account.

RIP

SouthPark The 8 kilo-samples per sec thing and nyquist-related details definitely matters if you're tying to produce a frequency spectrum plot, right?

Ditto for the time it took me to respond.

I guess that could be a data analysis thing one wants to make but here we are talking about key presses, so we are interested in accurate time-domain things.

SouthPark I guess - as somebody mentioned - it also matters if trying to estimate a key velocity.

That's the whole purpose here: estimate the exact time of keypress (extremely easy with available electronics) and the velocity of the same (not so easy but still feasible), to recreate one of these hybrid pianos, hopefully with even better performance than the commercial ones (and certainly at a more affordable price).

SouthPark Outstanding work! Thumbs up.

Thanks. It takes a village and I'm just the street sweeper, so to speak 😃