First iteration of beat detection