'Add scratching sound effect for Scratch Card using UITouch

I want to add a scratching sound effect for a Scratch Card.

I have a scratch sound which goes like 1 scratch/swipe.

I am able to play the scratch sound on touchesMoved and touchesEnded. However, the sound effect doesn't match the user swipe. Like for example if I swipe 1 long swipe, the sound plays multiple times.

I want it to play only once for one continuous swipe.

I want it to play again ONLY if the swipe changes direction or stops moving for a while then swipes again.

Moreover, how can I match the sound effect speed to the swipe speed. Is that possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source