I am writing a piece of software to generate musical sequences, and I would like a way to slowly introduce notes in a chord in a balanced way across the range of the chord. I want it to be more interesting and sonically balanced than top to bottom, or stepwise.
I am looking for a sequence that subdivides a range of integers recursively.
For example, something similar to, or the same as:
For the range 1-8, generate the sequence: 4,8,2,6,3,7,1,5.
For 1-7, generate the sequence: 3,7,1,5,2,6,4
For 1-6, generate the sequence: 3,6,1,4,2,5
For 1-32: 16,32,8,24,12,28,4,20,14,30,6,22,10,26,2,18,15,31,7,23,11,27,3,19,13,29,5,21,9,25,1,17
This sequence cuts the range in half (rounding down) and records the maximum of each subdivision. It repeats, visiting the subdivisions in a balanced way. An important detail is that it doesn't just visit the subdivisions in a linear way (left to right), but in some form of symmetrical hopping.
Are there any functions or algorithms that are similar to this?