Researchers have discovered a mathematical formula that governs fractal-like patterns in music.