• No se han encontrado resultados

8.5 Conditionals vs. Formulas 105

This call to score-gen is nested within a begin-end command that creates stream objects for pitch and velocity. The long progn expression uses many #? expressions to determine which stream ob-jects are used for each note. Recall that sg:start is the starting time of the note whose attributes are being computed. This start time is rounded to an integer s, and each different value of s selects a pair of patterns for pitch and velocity. In every case, variables pitch and vel are set, and these are then used as the values for keyword parameters pitch: and vel:. In this particular example, the resultant music cre-ates a gradually rising chromatic figure that increases in pitch and loudness as time progresses. Play it with “exec score-play(

ascent)”.

In this example, a series of conditionals is used to select changing patterns as time passes. Often, a long list of nearly identical program statements like these is an indication that the program could be ex-pressed more cleanly some other way. In this case, the variable s acts as a selector among many choices. The primitive nth uses an integer to select an element from a list. How would you rewrite Example 8.4.2 to use nth? In this program, it happens that there are exactly 5 notes per second, so with one small exception, each pattern is ac-cessed 5 times. Earlier, we saw how patterns can be composed. How would you rewrite this example to draw pitches and velocities from nested patterns to yield the same result without the long series of conditionals?

8.5 Conditionals vs. Formulas

Example 8.4.2 uses a rather elaborate scheme to spell out the computation in great detail. The previous paragraph hinted at some possible simplifications. We can also observe that the general trend is a chromatically rising pitch center and increasing loudness. In the next example, we replace the conditionals with a more numerical ap-proach, using formulas to calculate the change in pitch and velocity.

We will use the same “trick” of rounding the note time to obtain an integer, but rather than select an expression with the integer, we will use the integer directly to compute pitch and velocity.

This example is not exactly equivalent to Example 8.4.2, but it does generate similar output, and it is certainly much more compact.

It is worth considering the advantages and disadvantages of these two approaches. The first approach is more amenable to fine tuning.

It would be simple to change just one or two pitch patterns to include a half step or a large interval, whereas the formula example only has one fixed pitch pattern. It would also be simple to vary the amplitude

patterns in Example 8.4.2, for example to make a very quiet section just before a loud ending. On the other hand, the #? expressions are awkward to extend to greater durations. Each additional second re-quires another expression. In contrast, the formula approach can run for any duration with only slight changes necessary to limit velocity and pitch values. It is also possible to vary the overall shape of the pitch or velocity contour in Example 8.5.1 by editing a single expres-sion rather than editing every pitch or velocity pattern. For example, the pitch pattern will go down if you just subtract the rounded start time rather than add it.

Example 8.5.1: formula.sal begin

with pitch-stream =

make-heap(list(c4, d4, e4)), vel-stream =

make-cycle(list(20, 40, 60)) exec score-gen(save: quote(formula), score-dur: 10, ioi: .2, pitch: next(pitch-stream) + round(sg:start), vel: next(vel-stream) + round(sg:start) * 10) end

At a deeper level, this discussion is really about abstraction, one of the central concepts of algorithmic composition. We use algo-rithms to make music in order to shift the focus (and labor!) from the detailed specification of each note to more general, more abstract notions such as contour, texture, duration, and temporal evolution.

An important task for the composer is to design algorithms that af-ford the “right” kind of control, depending on individual musical goals and expressive needs.

The last two examples illustrate two very different algorithms that yield similar music. The question is not which one is faster, better, simpler, or smaller. The important question is: Which approach best lends itself to the musical goals of the composer? Programs rarely if ever produce masterpieces or even good material without a signifi-cant amount of experimentation and refinement. Part of the process of algorithmic composition is designing programs that represent mu-sical decisions in a way that supports mumu-sical exploration.

8.6 Suggested Listening 107

8.6 Suggested Listening

Matices Coincidentes (converging colors) composed by Pablo Fur-man was inspired by the use of perspective in art and architectural design. Pablo Furman explores the convergence and blending of tone colors using electronics (Furman, 1998).

British group Halal Kebab Hut uses various algorithmic techniques to generate music from everyday “junk.” The piece Variazioni con Shish No.4 uses inputs (in the form of surrounding sounds) in a set of rules for the performer to follow (http://www.

halalkebab.co.uk/download/MP3s/Kebabish/

02%20Variazioni%20con%20Shish.mp3).

Documento similar