Implementation of a tempo detection algorithm in Swift.
The algorithm was originally proposed by Tsang Kei Man in his 2006 paper titled Tempo Extraction using the Discrete Wavelet Transform.
- A discrete wavelet transform is applied to the audio data for four iterations to obtain the DWT coefficients, cD1 to cD4.
- Peak detection is performed for cD1 to cD4 concurrently.
- After getting the peaks of these coefficients, the beat intervals are calculated from these peaks.
- Four sets of beat interval information are combined to create a histogram.
- The histogram is smoothed with a Gaussian function to improve accuracy.
- After these stages, the tempo of the audio data can be obtained.
- Improve peak detection using the derivative method
- Identify the beat locations