added a beats per minute detection algorithm