BJG145 wrote: ↑Mon Sep 18, 2023 1:48 pm
OK, thanks for the clear explanation. I get that, but I was thinking of when you said:
If you want to calculate velocity by the time it takes to travel a fixed distance...you get a variable response time. Whether that lag on a slow push is enough to put timings off sufficiently to be noticeable you’ll have to determine yourself.
I'm not quite sure what you meant by that. But...you're saying that if the sensors are all consistent, then despite the curve in the output graph I'll get a linear response across different velocities...?
Not really.
Hopefully we've determined that the signal strength from the Hall Effect sensor is related to the amount the key has been pressed down. And that it's not quite a linear response, it's a slight curve.
If we consider the time it takes for the signal to drop from a value of 200 to 100, then the faster the key is pressed, the shorter that time is.
So we have two variables: the change in signal level and the time taken for the signal level to drop a certain amount.
As I've said before, there are two basic velocity detection methods we can use.
1) We fix the signal level drop we want and measure the time it takes to drop that far.
The faster the velocity, the less time it takes for the signal to drop that far.
The slower the velocity, the longer it takes for the signal to drop that far.
2) We fix the time period we measure the signal drop in and measure how far the signal drops during that time period.
The faster the velocity, the further the signal level will have fallen in that time period.
The slower the velocity, the less the signal will have fallen in that time period.
.....
Hopefully you can see that with method 1), the slower the velocity, the longer the time we need to wait before we can determine the velocity. And we can't send out a note without a velocity value.
So say at our fastest velocity, the signal has dropped from 200 to 100 in 0.5ms. That's nice and quick and we can send out our 'note on' MIDI message almost immediately. You won't notice a 0.5ms delay.
But at a medium velocity, it might take 10ms to drop from 200 to 100, so we cant send out our MIDI message until after 10ms has passed since the key started being pressed. That's getting quite laggy.
And at a really slow velocity it might take 100ms to drop from 200 to 100, so we cant send out our MIDI message until after 100ms has passed since the key started being pressed, and that's
really laggy.
That's what I mean about a variable response time.
So I prefer method 1) where you pick a fixed measurement time and work out how far the signal level has fallen in that period.
You could pick say 3ms as an acceptable lag to allow for a measurable drop in signal level. 1ms or 0.5ms might be fine. You're the one with the test results so you should know what the timings are like.
But to do this well, your signal level measurements need a high degree of resolution. If you can only measure in steps of 4 units, you're OK with the big drops, but as the drops get smaller in that time period as the velocities decrease, your calculations for the velocities get less and less precise and you end up with big jumps in the calculated values.
A drop of 100 in a 1ms time frame is reasonably accurate, even if you can only resolve down to 4 units, but a drop of around 5 units in 1ms might read as 4 units or 8 units, depending on the exact voltage. And that can give you quite a different velocity.
Again, you know what sort of resolution you're getting on the signal levels, which is why you may need to match the signal voltage to the maximum A/D input voltage to maximise the resolution. If you can measure in 0.5 unit steps, then that's probably good enough, and 0.1 is fine.
But if you are happy with the note on info not being sent out until the bottom of the key press (remember it's not a piano keyboard) then method 1) is probably easier to implement. You just need to set a maximum keypress time to get a workable minimum velocity figure.