Unsupervised Learning and Refinement of Rhythmic Patterns for Beat and Downbeat Tracking