Figure and Ground in Music makes sense when Silence is perceived as Ground and the disrupting Musical Notes, as Figures. You can have a set of random frequencies at random intervals pierce through the quietude, but that doesn't really tie the whole thing together. Music has to be patterned. It has to be a Patterned Disruption of Silence.
This way, the concept of Music boils down to a series of frequencies related by scales, spaced out in a pattern, determined by the Time Signature. A set of (usually)repeating or non-repeating beats gives us a Bar.
Jargon aside, the point is, patterns are cogs in the device that is Music. Now, if we hook up Sound to a source of patterns, we have a self-sustaining system that generates Music. Algorithms generally spew out patterns. All that's needed to get sound to acknowledge algorithmic patterns is a language that's common to both. Numbers. Numerical Patterns.
Exciting, the prospect of finding out how algorithms actually sound.
Portaudio for playback and libsndfile for dumping frequencies to a file) going on now. As for the implementation, check out the code here. In short, for every step in the sorting algorithm (this includes traversing over an array element, and also swapping):
- I take the value dealt with (typically one value in the unordered list for a traversal, and two for a swap),
- multiply the value(s) with a scaling factor (such as 200) so that the frequencies are actually audible,
- assign a play time for each frequency (such as 100 ms),
- play the frequencies with portaudio,
- populate a new list with all these frequencies in chronological order,
- dump the frequencies to a wav file in the same order.