• No se han encontrado resultados

LA DEFENSA PÚBLICA Y EL ACCESO A LA JUSTICIA

Scaling and offsetting can be combined to produce patterns that consist entirely of a single shape that is projected in identical proportions at smaller and smaller magnitudes. This kind of pattern is called a self-similar, or fractal pattern. Self- similarity can be found not just in visual patterns, but in musical ones as well. For example, the intervals in the chromatic scale are derived from a single ratio of 21/12. An equal-tempered melody sounds the same when transposed to different octaves even though the actual Hertz frequency values between the tones are not equivalent.

One simple way to create a self-similar pattern is to apply the same set of rules (i.e. an algorithm) over and over again at different levels of magnitude until the pattern has been generated to a sufficient resolution. Self-similarity is most naturally implemented using a recursive function definition. A recursive function is a function that calls itself to solve successively simplified versions of a problem. In order to illustrate self-similarity and recursion we will create a function that simply “chops up” a quantity into self-similar segments at smaller and smaller magnitudes and then returns a list of all the segments that it calculates. For example if an input of 8 were chopped into 2 segments over 4 levels of magnitude the algorithm would return the list:

(8 4 2 1 1 2 1 1 4 2 1 1 2 1 1)

which corresponds to the levels and proportions in Table 16-1.

Table 16-1. Levels and proportions of a self-similar organization.

Level 1 8

Level 2 4 4 Level 3 2 2 2 2 Level 4 1 1 1 1 1 1 1 1

The sschop function Example 16-8 is a recursive algorithm that calls itself to

reproduce the exact same behavior at different levels of magnitude. Its recursive nature means that sschop reflects self-similarity in its definition as well as in the

results it returns.

Example 16-8. Self-similar segments of a line.

(define (sschop value segments levels) (if (< levels 1)

'()

(let* ((nextval (/ value segments)) (nextlev (- levels 1))

(chopped (loop repeat segments

append (sschop nextval segments nextlev)))) (list* value chopped))))

The function sschop takes three inputs: a value to chop, the number of segments

to chop value into, and the number of magnitude levels to chop over. The function returns a list of chopped values. The body of sschop consists of a single if expression. If the value of levels is less than 1 then sschop returns an empty

list (Interaction 16-11). If levels is greater than zero then sschop calculates a list

of values to return. These values consist of the current value added to the front of a list containing successive levels of chopped values at proportionally smaller sizes. The let* establishes three variables. nextval is the proportionally smaller

next value, computed by dividing the current value by the number of segments in each level. nextlev is set to level-1. Chopped holds the list of segments that constitute all the values under nextlev. This value is computed by a loop that iterates segments number of times and appends the results of a recursive call to sschop at the next smaller size and with levels reduced by one. Since sschop always returns a list, the append clause is used to concatenate each sublist into

one large list. The list* function then adds value to the front of this list so that

the current level's value is in front of all of its recursively generated segments.

Interaction 16-11 shows several sample calls to sschop that demonstrate its self-

similar nature.

Interaction 16-11. Calling sschop.

cm> (sschop 440 2 0) () cm> (sschop 440 2 3) (440 220 110 110 220 110 110) cm> (sschop 36 3 3) (36 12 4 4 4 12 4 4 4 12 4 4 4) cm>

Sierpinski's Triangle

Sierpinksi's Triangle is a famous two-dimensional fractal (Figure 16-7). The rules to create Sierpinski's triangle are simple:

1. Start with a triangle.

2. Draw a smaller triangle in the middle of the larger triangle with the points of the smaller triangle on the midpoints of the larger triangle's sides. This partitions the large triangle into 4 smaller triangles: a middle triangle and the triangles at each of the corners of the larger triangle.

3. Leave the middle triangle empty.

4. Visit each of the corner triangles in the larger triangle and repeat the rules starting with step 1 but now using each of these smaller triangles as the starting triangle.

Figure 16-7. A four-level Sierpinsk Triangle.

We will now transform our sschop algorithm into a musical process that

generates a self-similar melody as an “homage” to Sierpinski's Triangle. Our algorithm will use the basic method described in sshop to generate its self-

similar melody from of set of three tones, where each tone represents the side of a triangle.

Example 16-9. Sierpinski's Melody

(define (sierpinski tone melody levels dur amp ) (let ((len (length melody)))

(process for i in melody

for k = (transpose tone i) ;; play current tone in melody

output (new midi :time (now) :duration dur :amplitude amp :keynum k

:channel 0) when (> levels 1)

;; sprout melody on tone at next level

sprout (sierpinski (transpose k 12) melody

(- levels 1) (/ dur len) amp)

wait dur)))

The sierpinski process reproduces a melodic shape based on successive

degrees and octaves of itself. Tone is the current melodic tone to play, melody is a list of intervals representing the melody, level is the number of levels of the melody to produce, and dur and amp are the tone's duration and amplitude, respectively. The variable len is set to the number of intervals in the melody. The process first outputs the current tone If levels is greater then 1 then the process sprouts a recursive process definition to generate the next melodic level. The next level's tone is calculated by transposing the current tone in the melody up one octave. The duration for each tone becomes the current level's duration divided by the number of intervals in the melody. Thus, the entire melody in the next level will occupy the same amount of time as the current tone in the current

level (Figure 16-8).

Figure 16-8. Self-similar melody from sierpinski.

The value for levels is decremented by 1 , which will cause the recursive generation to finally stop when this value reaches 0.

Interaction 16-12. Listening to sierpinski.

cm> (events (sierpinski 'a0 '(0 7 5 ) 4 3 .5) "sier.mid") "sier-1.mid"

cm> (events (sierpinski 'a0 '(0 -1 2 13) 5 24 .5) "sier.mid") "sier-2.mid"

cm>

→ sier-1.mid

→ sier-2.mid

Specify levels and melody with care! The number of events the sierpinski

process generates is exponentially related to the length m of the melody and the number of levels l:

Accordingly, the first events call in Interaction 16-12 generates 120 events and the second produces 1364.

Chapter Source Code

The source code to all of the examples and interactions in this chapter can be found in the file mapping.cm located in the same directory as the HTML file for this chapter. The source file can be edited in a text editor or evaluated inside the Common Music application.

H. Taube 05 Oct 2003

Warren, C. (1973). Brunelleschi's Dome and Dufay's motet. Music Quarterly, 59, 92-105.

Previous Contents Index Next

Previous Contents Index Next

17

Etudes, Op. 6: Sonification of