This action might not be possible to undo. Are you sure you want to continue?

# Score generation with L−systems

Przemyslaw Prusinkiewicz

Abstract

A new method for algorithmically generating musical scores is presented and illustrated with examples. The idea is to produce a string of symbols using an L−system, and to interpret this string as a sequence of notes. The proposed musical interpretation of L−systems is closely related to their graphical interpretation, which in turn associates L−systems to fractals.

Reference

P. Prusinkiewicz: Score generation with L−systems. Proceedings of the 1986 International Computer Music Conference, pp. 455−457.

P > be a OL-system. turtle geometry.. Consider an L-system with alphabet V . CanadaS4S OA2 ABSTRACf.1and write 1. and two productions: a -t ab and b -t a. IX). 1. Becauseof the fractal nature of the createdfigures. Herman& Rozenberg (1975) and Lindenmayer& Rozenberg(1976) for classic references. respectively. 3.. This paper presentsan application of L-systemsto the algorithmic generationof musical scores.. A OL-system is deterministic iff for each a e V there is exactly one X e yo suchthat a -t X. which in turn associates L-systemsto fractals.m. To this end. we write a -t X. and presentsexamplesof pictures generated by L-systems. L-systemswere also appliedto generatefractals by Szilard & Quinton (1979) and Siromoney Subramanian & (1983).one at a time.1! such that 1.There is.1. 3. If a pair (a.10. Recently I have shown that graphical applicationsof L-systernswere not limited to plants and trees.10 co.1 a1. abaab and abaababa.an essentialdifference betweenL-systernsand the more widely known Chomsky grammars. This section summarizes the fundamental definitions and notations related to the simplest type of L-systems.P > where V is the alphabet of the system.the set of all words (strings) over V.1. while in the case of L-systemsproductionsare appliedconcurrentlyto all symbols in a given string. and angle IX. GRAPHICAL INTERPRETATION OF L-SYSTEMS. is an arbitrary word over V. .b}. co. 1. X) is a production.11 . and v+ . This sectionformalizes the notion of the turtle interpretation of a word and provides examplesof pictures generatedby OL-systerns under this interpretation. 2. ~ 1. 4 and 5 are equal to a. aba. stringsof symbols produced by an L-system are given a musical interpretation.1/1v and 1. ab. was introducedby Lindenmayer(1968).. In Chomsky grammarsproductions are appliedsequentially..respectively (Fig. SeeSalomaa(1973).fractals. however. coe v+ is a nonemptyword called the axiom and P c VxYO is a finite set of productions.SCORE GENERATION WffH L-SYSTEMS Przemyslaw Prusinkiewicz Departmentof ComputerScience University of Regina Regina. Definition 3.2s graphically. Section 3 applies the notion of a "turtle" (papert 1980.Saskatchewan. Let G = < V.10 1. Given the = {a. L-systemswere conceived to formally describe the growth processof living organisms and in this context they were extensively studied by biologists and theoretical computer scientists.1/1. A OL-system is an ordered niplet G = < V. Definition 2.. co. It is assumed that for any letter a e V..a". y. L-systems. The idea is to producea string of symbols using an L-system. 1. The words obtainedby derivationsof length I. KEYWORDS: generative modeling of music.and to interpret this string as a sequence notes.. is interpretedas the direction in which the turtle is facing. Anotherareaof applicationsof L-systemswas discoveredby Smith (1984) who applied them to generaterealistic images of plants and treesfor computerimagery purposes. = = ~ ~ Example. Section 5 describesthe hardwareand software used for experimentation. The letter a and the word X are called the predecessor and the successor of this production.Section6 presents conclusionsand lists severalpossibleextensions the described of model.or L-systems.2. e yo is directly derived from (or generated by) 1. Section 4 introducesa musical interpretationof L-systems. OL-SYSTEMS. Definition 3.the describedapproach related to the is work of Dodge & Bahn (1986) and Voss & Clarke (1978). 1. where the Cartesiancoordinates(x.x.but also includeda wide range of fractal curves (Prusinkiewicz1986).1 v iff ai -t Xi for ~ all i = l.1/1 axiom co= b. The proposedmusical of interpretationof L-systemsis closely related to their graphical interpretation.. there is at least one word X e yo such that a -t X.. A word V is generated G in a derivation of by length n if there exists a sequenceof words 1.yo . L-systemsgenerate stringsof symbolsby repetitively substitutingpredecessors of given productionsby their successors. A new method for algorithmically generatingmusical scores is presentedand illustrated with examples. The musical and graphical interpretationsof L-systemsare closely related. Abelson & diSessa 1982) to interpret strin.called OL-systems.. y) representthe turtle's position. and supposethat 1.the set of all nonemptywords over V. We = will say that the word v = Xi. INTRODUCTION The concept of parallel production systems. 2. The necessary definitions related to L-systemsare collected in Section 2. 1).. called the turtle's heading. Let V denotean alphabet. A state of the turtle is a triplet (x.

of The scores generated using the above method are quite interesting. (b) H11bert curve (Hilbert 1891). Many extensions of the basic approach described in this paper are possible.which consistsof threesteps: A string of symbolsis generated an L-system. 0 .7 synthesizer. the alphabetV contains auxiliary symbols X and Y. (e) Quedretjc Koch curve (Mendelbrot 1982). The length of derivation n. (xo. its Definition 3. Exemplesof curves genereted by OL-systems under turtle Interpretetjon. the turtle can respond to commands represented the following symbols: by F Move forward a step of length d. where x' = x + d cosa and y' = y + d sina. Figure 2 presents turtle interpretations of the wordsgenerated two deterministicOL-systems. (Here we assumethat the positive orientation of anglesis clockwise. The next state of the turtle is (x.//~ L' n=2 F+F+F+F F --+ F+F-F-FF+F+F-F abaababa Fig. by . y. 3) and the consecutive horizontal line segmentsare interpreted as notes. They are relatively complex (in spite of the simplicity of the underlying productions)but they also have a legible internal structure(they do not make the impressionof soundsaccidentallyput together). . The resulting figure is interpreted musically. CONCLUSIONS. . The string generator reads a file describinga given L-system.b a ab ~I aba ~IL abaab L -. This effect is aestheticallypleasing (as well as useful for debugging).) Turn left by angle o. The picture (set of lines) drawn by the turtle respondingto the string v is called the turtle interpretation of v. as a sequence noteswith pitch and durationdetermined of by the coordinates the figure segments. and d. Naturally. In general it is convenient use a lookup table which allows for specifying to an arbitrarymappingof y coordinatesinto note Ditches. Exl!mple of I! derivl!llon in I!n L-syslem. IMPLEMENTATION. The next state of the turtle is (x. y. Information about consecutive line segments passed the musical is to interpreter which controls the synthesizer.2. +--++ ---+- X -+ -VF+XFX+FVV -+ +XF-VFV-FX+ F-+F +-++ --+- step size d and the angle increment 0. 4.which means that the notes are played while the correspondingline segments are drawn. S. Suppose that the Hilbert curve is traversedin the direction indicatedby the arrow (Fig. Graphical and musical interpretationsare synchronized.and produces the resulting string of symbols. From the hardwareperspective. f Move forward a step of length d without drawing a line. y'.2. 2b).the initial state of the turtle. Fjg. 4 and 5. 1. A line segment between points (x. This string is interpretedgraphically as a sequence of commands controlling a turtle. In addition to the pitch and duration. experimental the systemconsists of a Macintosh microcomputercontrolling a DX. a). MUSICAL INTERPRETATION OF L-SYSTEMS. Let V be a string. A featurecalled data base amplification (the capability of producing complex objects using a small set of simple productionrules (Smith 1984» is as attractive in the musical applicationsof L-systemsas it is in their applicationsin computergraphics. to and the note duration is proportional to the segment length.fixed parameters. y') is drawn. This paper presents a technique for generating musical scores."0) . The software contains three modules. Note that in the caseof the Hilbert curve (Fig. Example. These are ignored when interpreting the final word v but are necessary during its generation. All other symbols are ignored by the turtle (the turtle preserves current state). The stateof the turtle changes to (X'. The resulting sequence notes forms a simple score shown in of Figs. a-oJ. y) and (x'. a+o). 6.Yo. string symbols generatedby an L-system may control other .The angle by increment0 is equal to 90°. + Turn right by angle o. can In the aboveexampleit is assumedthat the notes belong to the C major scale and the first note is C. any curve consistingof horizontal and vertical segments be interpretedin a similar way. This string is subsequently transferredto the graphical interpreter which draws the correspondingcurve on the Macintosh screen. the axiom (I) of the OL-system and the set of productionsP is indicatedfor both pictures. The pitch of each note corresponds the y-coordinateof the segment.

(1968). Cambridge London. the use of fractals. There is a standard technique for representing branching lines using Lsystems (Prusinkiewicz1986).R. H. HERMAN. (1986). S. computers. Tr6versing the Hilbert curve.New Yolk - Oxford. (1986).R. Mindsto"". Annln. ACKNOWLEDGMENT. LINDENMAYER. pp. Nagl & G. G.) (1976). Nr. & DISESSA. & QUINTON. Amsterdam . A.BERT. 459-460. Freeman. Developmental systems aIId longuages. (Eds.: children. 3. B. Space-filling curves and infinite graphs. Amsterdam and Oxford. The fractal geometry of nature. Iff noise in music: music from Iff noise. VOSS. P. and DODGES. development. North-Holland. PAPERT. This support is gratefully acknowledged. & ROZENBERG. Nr. PRUSINKIEWlcz. 6C. Plants. (1983). pp. SIROMONEY. Journal of Theoretical Biology 18. & SUBRAMANIAN.14 7 9 Fig. pp.H. New York and London. Graphical applications of L-systems. pp.E. (1984). Ueber stetige Abbildung einer Linie auf ein F1~chenst~ck. languages. Ehrig. C. Press. M. A. 5. Computer Graphics 18. An interpretation for DOL systems by computer graphics. Nooh-Holland. R.T. Academic Press. Score generation using L-systems is particularly attractive becauseit addresses several aspectsof computer arts: the syntactic approach to musical composition. and formal languages. I. San Francisco. M. SZILARD. G. (1978). ABELSON. (1891). pp. Musical fractals. in the commonmusical notation. Parts 1 and II. Formal languages. 3. & ROZENBERG. 185-196. Byte II. A. The score associated with the Hilbert curve 1nthe piano-roll notetion. (1982). SALOMAA. 4.Heidelberg . New York. J.B. SMITH. The researchdescribedin this paper has been supportedby grant number AO324 from the Natural Sciences and EngineeringResearchCouncil of Canada. Hll. (1980). Rozenberg (Eds. Turtle geometry. L-systems can also generate polyphonic scoresby assigninga musicalinterpretationto lines with branches. Journal of the Acoustical Society of America 63.I. 247-253. pp. & BAHN. (1979). REFERENCES. and powerful ideas. In H. Fig.T. 8-13. K. The Science Terrapin 4. G.and the combinationof visual and aural aspects a of performance. LINDENMAYER. The score associated with the Hilbert cur. A.F. Math. AUlomata. MANDELBROT.): Graph grammars and their application to computer science. . Springer-Verlag. A.L. Mathematical models for cellular interaction in development. v Fig. A. W. 1-10. (1973). D. & CLARKE. Basic Books.New Yolk . (1982). 38. froctals. Proceedings of Graphics Interface '86. R. parameters such as volume and tempo of the performance. Nr..G. Berlin . (1975).A. R.Tokyo. 280-315.