The context is that of a musical piano. I am interested in catching key-up events that occur when the sustain pedal is not pressed.
I have these streams:
pedalDown$
pedalUp$
keyUp$
How can I pipe these together into an observable unsustainedUp$
that emits of keyUp$
events only while the pedal is not down?
I thought this could work, but unsustainedUp$
fires even when the keyUp$
comes after a pedalDown$
and before a pedalUp$
.
unsustainedUp$ = keyUp$.pipe(
skipUntil(pedalUp$),
takeUntil(pedalDown$),
repeat()
)
// once at setup, fire into pedal-up to get this into the correct, normal piano initial state
pedalUp$.next()