User Tools

Site Tools


sound_of_space-filling_curves_ii

Herman Haverkort > Recursive tilings and space-filling curves > Sound of space-filling curves > Sound of space-filling curves II

The sound of space-filling curves II

Sonifying the landscape of locality-preserving properties of space-filling curves and permutation sequences

Sonifying locality-preserving properties

Computers often need to do computations on points in a grid. For example, when computing a weather map, the colour of each pixel of the map has to be computed. The order in which these pixels are processed can influence the efficiency of the computation. Ideally, the order is locality-preserving: that means that points that are close to each other in the grid are also close to each other in the order. However, this is not always possible. For example, in the figure on the left, the pairs of points marked in red are neighbours in the grid, but one of them is processed much later than the other. In the figure on the right, we also see such pairs, but the pattern is different: the times at which red points are processed differ, and the delays between neighbours are also different.

If I had not marked pairs of points with major delays between them in red, their locations would have been hard to spot in the figure. With high resolution grids of, say, 128 x 128 points, it would be even harder. To make it clear where the pairs of points with major delays between them are, we can visualize the processing order as a landscape: starting from a horizontal plane, we move each point of the grid up in a third, vertical dimension according to its position in the processing order:

Thus, the processing order becomes visible as a steadily ascending path, and pairs of points with long delays between them become visible as high, steep slopes. But what about processing orders for higher-dimensional grids? To show the pairs of points with long delays in a three-dimensional grid, we would need to create a four-dimensional landscape—which I cannot draw.

The goal of this project is to make the slopes of these undrawable landscapes hearable, in particular for processing orders of three-dimensional grids, and even higher-dimensional grids. The idea is that we process the points of the grid one by one, in the given order. When we process a point P, we also look at the other points of the grid. If there are other points close to P that were processed much earlier, or will be processed much later, we create a sound. If the nearby point was processed long ago, we create a high-pitched sound; if the nearby point will be processed far in the future, we create a low-pitched sound. The longer ago, the higher; the further in the future, the lower. We construct these sounds for the neighbourhoods of all points of the grid, in the order in which they are processed, at high speed: in some of the examples below, we go through more than 40,000 points in about 100 seconds. The result is a sound track in which low sounds indicate that we are approaching mountains that tower high above us in the four- or higher-dimensional landscape; high sounds indicate that we approach the edge of a cliff overseeing a valley far below. The sound track is polyphonic, because at any point in time, there may be cliffs and mountains on various scales in various directions. The overall trend in the sound track is that it rises in pitch. This is because initially, all points are still to be processed in the future, so only low sounds can be created, whereas eventually, all points will have been processed in the past, so only high sounds can be created. Alternatively, we can swap the roles of high and low and obtain a falling sound track.

Math or music?

Below you will find thirteen sound tracks that have been generated from different processing orders for various grids. Depending on your background, you may find that the tracks violate many rules of musical composition and you may wonder why I did not correct those errors. Or you may feel that the tracks sound so musical, that this cannot be just the math at work: what you are hearing must be my own musical interpretation of the processing orders. Therefore, let me try to clarify what these tracks really are, and what aspects of the sound are actually under my control.

I did not compose any notes at all (it is better like that: I am not a composer). I created and ran a computer program that converts grid processing orders into sound, based on some basic parameter settings. I hope to publish a report later in which I explain the technical details, but for now: I would say these parameter settings are comparable to choosing, say, a photo camera's focus, aperture, shutter time, and film speed. But indeed, I also had an influence on the sound that goes a bit further than that.

First, I chose the processing orders to sonify. Tracks 2–7, 10, and 13 use processing orders that have been known in the mathematics and/or computer science literature for their technical merits. I selected these particular processing orders because I found that they sound interesting. I omitted other well-known processing orders (following a Hilbert or a Pólya curve, for example), because I found their sound tracks too chaotic: I could not find nice structures which I could focus my “sound camera” on. Tracks 1, 8, 9, 11 and 12 are created from simple variations on a well-known processing order. I designed these variations specifically in an attempt to create interesting sound tracks.

Second, I tried to control some aspects of sound colour, in particular the mix of overtones and formant strengths and frequencies. Sometimes I used different colours for different pitch ranges to make the sound tracks more transparent. Note, however, that my control of sound colour is limited. What sounds like a single note in a sound track, typically emerges from separate points in a traversal that goes through up to hundreds of points per second. It is still a bit mysterious to me what effects this has on the sound colour. In any case I cannot control the envelope (the development of sound over time) of the emergent apparent notes: the envelopes are determined by the processing orders that are sonified.

Third, I chose how exactly to map delays between pairs of nearby points to pitch. More precisely, at each point in the traversal of the grid, I calculate the relative times of all other points: their positions in the processing order relative to the current point. I map these relative times to pitch; loudness is determined by the discrepancy between the other point's relative time and its distance in the grid. With some processing orders, practically any value can appear as a relative time with high discrepancy. In such cases I chose a continuous mapping from relative time to pitch, so that the slightest variations in relative times can be heard, often as glissandos. In the case of Tracks 1, 3, 4, 9, 11, and 13, however, I found that a small set of different values for relative time dominated, and I decided to map the relative times to a set of discrete pitch values. In other words, I mapped the relative time values to a musical scale, which I tuned by hand. Thus I had some control over the harmonies and dissonances that appear. However, I always kept to the following rules: 1) the same relative time value always results in the same pitch; 2) higher pitch means further in the past (or, in a falling-pitch track: further in the future); 3) I try to make different relative times map to different pitch values on a chromatic scale. In practice this means that when I would try to get a particular note or chord at some point in the sound track, this would typically affect other notes and chords throughout the entire sound track—so tuning the scale is a complicated puzzle.

As a post-processing step, I let some tracks fade out at, or sometimes before, the end.

Sound tracks

The sound tracks are quite different in style. You will probably like some of them more than others. I recommend listening to at least some parts of Tracks 1 to 9 to hear a more or less representative sample. Below the tracks are presented one by one. For all tracks at once, click here.

1. Z-Order Variation A on a three-dimensional grid

32,768 points at 114 points per second, cut after about 26,000 points, falling pitch

Z-Order is a processing order induced by a curve that was described by Lebesgue in 1904. It has been known in computer science at least since a report by Morton from 1966; therefore, numbering points in a grid in Z-Order is also called Morton indexing. Z-Order has many applications in improving the efficiency of computations. The figure below illustrates this processing order for a two-dimensional grid. The grid is subdivided into four parts, which are processed one by one, making a Z figure. Each part is again subdivided into four parts that are processed one by one, again making Z-figures. This subdivision procedure is repeated until we arrive at the level of single grid points. The figure illustrates the resulting order for a two-dimensional grid of 8 x 8 = 64 points.

For this harmonically interesting sound track I used a variation of Z-order for a three-dimensional grid in which the Z-figures are reversed on every second level of subdivision. In two dimensions, this would look like this:

The three-dimensional grid that underlies the sound track consists of 32 x 32 x 32 = 32,768 points.

2. Steinhaus-Johnson-Trotter algorithm for permutations of eight

40,320 points at 448 points per second, falling pitch

The sonification approach does not only work for regular grids, but also for permutations. A permutation is an order of distinct numbers. For the numbers 1 to 2, there are two different permutations (12 and 21); for the numbers 1 to 3, there are six different permutations (123, 132, 213, 231, 312, and 321). For the numbers 1 to 4, there are 24 different permutations, as follows:

In this figure, permutations that differ only by swapping two adjacent numbers, are connected by a line. Thus, the permutations also form some kind of grid. There are different methods to enumerate all permutations in such a grid, and they create different patterns of high and low sounds that are generated when nearby permutations appear much earlier or much later in the enumeration order. A famous algorithm to enumerate permutations is known by the names of 20th century authors Steinhaus, Johnson and Trotter. However, the algorithm has in fact been known since Stedman's 1677 book for its application in change ringing: varying the order in which to ring a set of church bells. With this algorithm, consecutive permutations differ only by one swap of adjacent elements. In other words, consecutive permutations are always immediate neighbours in our grid. This sound track sonifies the locality-preserving properties of this permutation enumeration method going through all 40,320 different permutations of eight numbers. We hear a collection of falling glissandos.

3. Backtracking algorithm for permutations of eight

40,320 points at 420 points per second, rising pitch

This sound track is based on a simple algorithm to enumerate permutations that my academic father and I have been teaching in our algorithms classes for many years, because it is relatively easy to remember and easy to prove correct. Its locality-perserving properties appear to be very good, so, compared to the other sound tracks, I had to exaggerate the pitch differences a lot to make their structure noticeable. The structure consists of an interesting interplay of shifting rhythmic patterns, much unlike anything else in this collection.

4. Heap's algorithm for permutations of eight

40,320 points at 288 points per second, rising pitch

This sound track is based on an algorithm to enumerate permutations that was published by Heap in 1963. It appears to be the most efficient algorithm to enumerate permutations; however, it seems to be more difficult to understand and to get right than the previous algorithms. Its sound track distinguishes itself from the others in this collection by an unusually melodic bass line between 1/8 and 3/8 of the track's length, mirrored by a high-pitched melody in the last quarter of the track.

5. Mitchison-Durbin order on a two-dimensional grid

9,216 points at 184 points per second, rising pitch

In 1986, Mitchison and Durbin figured our how to enumerate the points in a two-dimensional grid such that the sum of the delays between all pairs of direct neighbours is minimised. But that does not mean that these delays are the same everywhere. This sound track sonifies the structure of their processing order on a grid of 96 x 96 points.

6. Z-Order on a seven-dimensional grid

16,384 points at 69 points per second, rising pitch

This sound track presents the locality-preserving properties of Z-Order on a seven-dimensional grid of 4 x 4 x 4 x 4 x 4 x 4 x 4 = 16,384 points.

7. Peano curve on a four-dimensional grid

6,561 points at 42 points per second, rising pitch

In 1890, Peano was the first to describe a true plane-filling curve. His curve is infinitely thin and infinitely crinkly and still it fills a square completely without jumping. When applied to a grid of appropriate size, it induces a processing order in which consecutive points are always immediate neighbours in the grid (note that with Z-Order, this is not the case). This sound track sonifies the locality-preserving properties of the Peano curve on a four-dimensional grid of 27 x 27 x 27 x 27 points. The climax is in the middle of the track, when we pass through the centre of the grid. Here the processing order squeezes itself in between points visited long before and points that are still to be visited far in the future; thus high tones and low tones are both strong there.

8. Z-Order Variation B on a three-dimensional grid

32,768 points at 126 points per second, rising pitch with marked jumps

This track sonifies a Z-Order variation in which the processing order is flipped inside the parts of the subdivision. The figure below illustrates the idea for a two-dimensional grid:

For this sound track, we apply the same idea to a three-dimensional grid. Note that this processing order (like most processing orders on this page) often jumps from one point to another point that is far away. This sound track also features a percussion sound effect that accentuates these jumps: the farther the jump, the louder the sound.

9. Z-Order Variation B on a five-dimensional grid

32,768 points at 81 points per second, rising pitch

This track is based on the same Z-Order variation as the previous track, but now on a five-dimensional grid. Whereas the previous track sounds a bit like a march, this one is more like a lullaby.

10. Meurthe curve on a three-dimensional grid

19,683 points at 36 points per second, rising pitch

The two-dimensional Meurthe curve was presented by Freek van Walderveen and myself in 2008 as a plane-filling curve that optimizes locality-preserving properties under certain technical conditions. This track sonifies the three-dimensional version of the curve. It is probably my personal favourite, even if it is a bit eerie: it is somewhat similar to Track 7, but it is richer, with longer and stronger melodic phrases that fit together well even though they do not adhere to any kind of musical scale.

11. Z-Order Variation B on a five-dimensional grid

32,768 points at 75 points per second, falling pitch

This track is based on the same processing order as Track 9, now with a different, falling scale and a different sound colour.

12. Z-Order Variation C on a three-dimensional grid

32,768 points at 120 points per second, rising pitch

Track 12 is the result of a conscious attempt to create a processing order that sounds musical. The other Z-Order variation tracks all sound a bit anti-climactic: in the last part, nothing new or surprising happens anymore and the tracks can barely (if at all) maintain their musical momentum. To counter this, I changed Variation B (from Track 8) into Variation C by making the last square (in three dimensions: the last of eight subcubes) similar to the curve as a whole, but reversed.

Since this change works on all levels of subdivision, this introduces a bit of variation on all levels, without creating chaos. Moreover, this change turns the end of the curve inwards: thus, at the end of the processing order, we process points that are relatively close to many points that were processed before. Thus, the sound track features an increasing number of high-pitched tones near the end and does not lose power.

13. Z-Order on a three-dimensional grid

32,768 points at 105 points per second, cut after about 26,000 points, rising pitch

The final track sonifies the original Z-Order in three dimensions, with a result that is quite similar to Track 1, maybe a bit less atmospheric and more plainly melodic.

All tracks at once

sound_of_space-filling_curves_ii.txt · Last modified: 2021/11/29 08:05 by administrator