<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div> </div>

<div>I never did this, so grain of salt advised ;)</div>

<div>Hrm, the fact that there are two switches with a guaranteed minimum time limit between them (assuming a human hits the key, not some robot ;) ) could make this easier / no classic debunding needed.<br/>
If all a detection of the first switch closing does is marking that key to up-count its time counter, and all tis release deteciton is does to reset / unmark time counter, nothing further needs to be done for that switch, let it bounce? When then the closing of the 2nd switch is detected, generate the MIDI event, and ignore any further changes of the 2nd switch until the 1st switch is also released. The guaranteed distance between the switches should make this not "jumpy" ? So when then the 1st switch starts to bounce again it measn the key has rtavelled so far thet 2nd switch will not bounce anymore, so it's back to some marking and unmarking of the "key is about to strike "stage...</div>

<div> </div>

<div>Steve<br/>
 </div>

<div> </div>

<div>
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><br/>
<b>Von:</b> "Richie Burnett" <rburnett@richieburnett.co.uk><br/>
<b>Betreff:</b> Re: [sdiy] MIDI velocity</div>

<div name="quoted-content">Roman wrote:<br/>
<br/>
> ...regular scanning starts and is repeated until all keys are<br/>
detected released and debounced.<br/>
<br/>
Out of interest, what rule do you use for the de-bouncing of musical<br/>
instrument keys?<br/>
<br/>
For general switches in the user-interface of embedded control projects I<br/>
have always used the rule that the switch state must have been stable for<br/>
10ms before updating the output state. So, whatever action the switch<br/>
causes only takes place after the switch has been in the active state<br/>
without bouncing for 10ms, and then the action variable only cancels when<br/>
the switch has been in the inactive state for 10ms without bouncing. This<br/>
works very well for de-bouncing pushbuttons and toggle switches in things<br/>
like industrial control equipment because it inherently rejects any brief<br/>
glitches due to EMC transients, as well as removing the effects of<br/>
mechanical switch bounce. Nobody notices 10ms latency on the start and stop<br/>
buttons of a CNC machine, or an oscilloscope, or whatever it is used for.<br/>
But for musical keys, or drum pads, I am thinking that this 10ms latency on<br/>
the closing of the switch is not acceptable. Maybe I should revise the<br/>
algorithm to act on the first inactive-to-active transition and update the<br/>
output state to active immediately. I would be interested to hear what rule<br/>
you apply.<br/>
<br/>
-Richie,<br/>
<br/>
_______________________________________________<br/>
Synth-diy mailing list<br/>
Synth-diy@dropmix.xs4all.nl<br/>
<a href="http://dropmix.xs4all.nl/mailman/listinfo/synth-diy" target="_blank">http://dropmix.xs4all.nl/mailman/listinfo/synth-diy</a></div>
</div>
</div>
</div></div></body></html>