This version handles the vinyl speed correctly while scratching. I made some modifications. I’m using TIM8 input capture while not scratching and to jump into and out of scratch mode (touch on and off events) because it’s more punctual to measure frequency.
And I’m using TIM3 in encoder mode while scratching, because with that I can count the ticks of both the rising and falling edges of both channels of the encoder, without any interrupt or code. It gives me 4 times the resolution than if I counted the input capture interrupts.
And another video with master tempo and synch working properly.