Ha, i could not stop thinking about that and got a crazy idea:
treat it like a analog signal and filter and schmitt trigger it again
https://en.wikipedia.org/wiki/Schmitt_trigger
that is what you actually would do if you have to solve it with hardware...
with a analog filter we smooth ( and delay the signal ) what works on a analog input but why not
also on a jumping digital input. see, if you run a analog filter on a PWM signal what you get?
-a- filter
tA = 0.2; // ( tunable 0 .. 1 )
// (tB = 1 - tA ) if tA = tB = 0.5 we have a average filter
PV = new input analog or digital 0.0 ... 1.0
PVf = PV * tA + PVf * ( 1 - tA );
-b- SCHMITT trigger hysteresis limits
// hH = 0.75;
// hL = 0.25;
newH = False;
newL = False;
if ( PVf > 0.75 ) { newH = True; }
if ( PVf < 0.25 ) { newL = True; }
-c- check on change and timing
if ( mySig == False && newH == True ) { mySig = True; pos_edge_time = now(); }
if ( mySig == True && newL == True ) { mySig = False; neg_edge_time = now(); }
deltaT = neg_edge_time - pos_edge_time;
// use 3 different times to select 3 different jobs example
if ( deltaT > T_job_A && deltaT < T_job_B ) { job_A(); }
if (deltaT > T_job_B && deltaT < T_job_C) { job_B(); }
if (deltaT > T_job_C ) { job_C(); }
point is you not have to deal with timers in microsec like with a software debouncing...
sorry i not have a easy idea to put that signal analysis in a trend graph to show my idea more understandable.