Don’t apologise - this is part of the fun learning and sharing process . I just spent this morning with my head in my hands trying to get my head around some Indian classical music theory so we’re all learning something somewhere.
If you have your slices like this in an array or buffer:
0 100 200 300 400
and we also have some spectral analysis for each consecutive pair of slices:
4000 353 30 9000
We can, in our minds attach each pair to those values.
0 100 = 4000 <-- slice 0
100 200 = 353 <-- slice 1
200 300 = 30 < -- slice 2
300 400 = 9000 < -- slice 3
and we know that the first value (4000) belongs to the first slice (0 if we 0 count) and we know the start and boundaries (because all the info is stored in the buffers somewhere).
If we sorted this collection of data by the descriptor values we would get something like this:
200 300 = 30 <-- slice 2
100 200 = 353 <-- slice 1
0 100 = 4000 <-- slice 0
300 400 = 9000 <-- slice 3
Now, our collection is sorted by the descriptor values, they go from 30 to 9000 and we remember the slice that these descriptor values belong to. But hold on, remembering which slice belongs to each descriptor value is in our heads, not the computer, right? To keep that relationship in the code we can infer the slices from the position of elements in an array, as well as the ordinal (which in the above example is derived from the .order
function called on any Sequencable Collection
.
So in this case our ordinal of the above collection would be [2, 1, 0, 3]
because if we had to sort this:
4000 353 30 9000
we would rearrange those elements into an array by taking the 2nd, 1st, 0th and 3rd element in that order. You can think of it kind of like a lookup table.
So our ordinal ([2, 1, 0, 3]
) actually tells us what order to grab the slices, based on the descriptor values.
That is the order we would have to put things for those descriptor values. If we referenced back to our slices:
[0, 100, 200, 300, 400]
The slice with the lowest spectral centroid would be 2
, (the first element in our ordinal list), or 200 and 300 for start and end times of that slice.
Does that make more sense? Maybe I can ping the wise @tedmoore for some SuperCollider magics in which there is some playback based on descriptor values?