Working on beat detection algorithm