Professional Documents
Culture Documents
An Approach To Musical Live Coding
An Approach To Musical Live Coding
An Approach To Musical Live Coding
http://eprints.qut.edu.au/
aa-cell IN PRACTICE:
AN APPROACH TO MUSICAL LIVE CODING
Andrew Sorensen Andrew R. Brown
MOSO Corporation Computational Arts Research Group
Brisbane, Australia Queensland University of Technology
andrew@moso.com.au Brisbane, Australia
a.brown@qut.edu.au
parameters is more musically significant than the data modulus values it is possible to loop subsections of the
being consumed. envelope as a method of motivic development.
As a result we have found that simple probabilistic
functions, in particular linear and gaussian distributions, ;; simple pitch quantized envelope
can provide effective variety and interest. It is worth ;; with randomized rhythmic performance
(define melody
noting that our use of probability is often subtle and
(lambda (env pos)
usually highly constrained. Randomness provides two (play-note (now) zeb1
useful functions in our practice, 1) the function of non- (pc:quantize (floor (env (fmod pos 8)))
determinism for the provision of structural novelty and '(0 2 4 5 7 9 11))
variation and, 2) the less commonly discussed role of 80 3000)
abstraction, where it provides the most practical means (callback (+ (now) (random '(7500 5000)))
for abstracting away many of the details of performance 'melody env
nuance and human inaccuracy. We do not mean to (+ pos (random '(.25 .5))))))
suggest that a simple random selection is the best
computational mechanism for handling performance (melody (make-envelope (vector 0 60 3 72 5 79 8 60))
0)
parameters; only that when used subtly it can often
provide adequate variation, making it a useful tool for
live programming. Often aa-cell use pitch envelopes in conjunction
with a gaussian-random whose mean follows the
;; A Simple diatonic progression - 1st Order Markov envelope and whose standard-deviation is either fixed or
(define chords changed over time by an auxiliary envelope, with the
(lambda (degree) final result often quantised to a pitch class set.
(play-chord 60 80 3 Some of our other common applications of
(pc:diatonic 0 '^ degree) polynomial functions include using two curves for
*second*)
tendency masks, specifying upper and lower boundary
(callback (+ (now) *second*) 'chords
conditions [Berg ICMC 86] and for controlling synthesis
(random (cdr (assoc degree
'((i v7 iv ii)
parameters.
(ii v7)
(iv ii v7 i) 3.3. Periodic Functions and Modular Arithmetic
(v7 i))))))))
Another family of functions common to musicians are
the periodic functions. Periodicity is pervasive in music
The example above demonstrates how simple providing structure from micro foundations through to
probabilistic techniques can be used to succinctly realise macro forms [Citation??]. We have been exploiting
musical goals. A simple first order Markov model from periodic functions as a means for generating structure in
diatonic musical theory provides a simple process for all aspects of musical form - pitched, rhythmic,
harmonic progression. Most of the examples that follow structural and timbral. These functions have a range of
will also make use of probability. applications for the live coder, including metric
pulsation and pitch cell extraction as well as more
3.2. Linear and Higher Order Polynomials common usages such as low frequency oscillation for
In his book “Structural Functions in Music”, Wallace timbral (synthesis) variation. Like polynomial functions,
Berry outlines some of the relationships between linear periodic functions can provide subtle contours through
functions and musical structure. He discusses these to grandiose gestures and when combined with various
relationships in pitched, rhythmic and timbral material probabilistic tricks can produce engaging performance
at multiple perceptual levels [Berry 1976]. Linear results.
functions are generally applied to abstract One aspect of periodic structure that aa-cell
representations of features that are often based on regularly exploit is the “composer’s pulse” [Clynes
perceptual scales, even if the underlying physical 1984]. By mapping a cosine function to amplitude it is
properties are non-linear. For example, chromatic or possible to provide a metric pulse. Multiple levels of
diatonic pitch organisation can be linear even though metric information can be easily provided by mapping
pitch frequency relationships are not. aa-cell use linear multiple periodic functions simultaneously. Further,
functions extensively across all musical elements; pitch, Clynes showed that these same functions can be applied
duration, amplitude, timbre and so on. We also make use to other rhythmic elements such as note duration and
of higher order polynomials and splines. tempo. In fact our experience suggests that it is only
Linear functions are often applied via break point through interaction at multiple musical dimensions that
envelopes to provide temporal structure at many levels an engaging musical performance is obtained.
in an aa-cell performance, ranging from milliseconds One common aa-cell application is to use a cosine
(microstructure) to an entire work (macrostructure) in function on note amplitude to provide a metric pulse to a
duration [Xenakis 1992]. The code below demonstrates regular pattern, such as a hi-hat part. Modifying the
a simple looped pitch cell generated from an envelope. period of the oscillation probabilistically produces
Although this is a trivial example it does outline two subtle yet engaging syncopation in the rhythmic pattern.
important practical benefits that envelopes provide for Another, pitch based trick, is to use an oscillator for
outlining pitched material; (a) they naturally coordinate selecting drum samples, occasionally changing the
rhythmic and pitch variation and (b) by changing the oscillation rate in order to modify the drum pitch
pattern, while retaining a constant rhythmic pattern. As
Sorensen, A. and Brown, A. R. (2007). aa-cell in practice: an approach to musical live coding. Proceedings of the International
Computer Music Conference, Copenhagen. ICMA, pp. 292-299.
with most of aa-cell’s live coding techniques the interest sequences with high level structural control. The simple
in these simple structures comes from a combination of example below outlines the probabilistic, two octave
constant localized change and larger scale regularity. transposition of a musical *cell* within the bounds of
The example below uses an oscillator to choose drums *pcs*.
samples and amplitudes.
(define *cell* '(60 62 63)s)
;; a trivial drum machine (define *pcs* '(0 3 7 8 10))
(define drum-machine
(lambda (time p) ;; random two octave transposition of *cell*
;; period drum pattern changes each 4 beats ;; with random choice of mutation to *cell*
(play-note (now) kit (pc:transpose
(+ 50 (* 6 (* cos (* time p pi)))) (random -7 7)
(+ 60 (* 20 (* cos (* time p pi)))) (random (list *cell*
2000) (invert *cell*)
(case (fmod time 4.0) (retrograde *cell*)
((0 2.5) ;; kick (expand/contract *cell*
(play-note (now) kit *kick* 80 5000)) (* 5 (random)))))
((1 3) ;; snare *pcs*)
(play-note (now) kit *snare* 80 5000)))
(callback (+ (now) 11025) 'drum-machine 3.5. Recursion and Iteration
(+ time .25)
(if (= 0 (fmod time 4.0)) Recursion and iteration provide many opportunities for
(random '(2 3 4 5)) repetition, evolution, pattern programming, grammars,
p)))) and they are fundamental to notions of computational
time.
Modular arithmetic is another tool which aa-cell use Like almost anything we can conceive of, it is
to control the regular cycles common to musical possible to think of music as a collection of processes
structure. The example above demonstrates the use of arranged in some form of hierarchical structure that
modulus for locating the beat position within a 4/4 bar. unfolds through time. To a large extent it is the
arrangement of these processes that defines the
3.4. Set Theory (Pitch Class Sets) organisation of sound that we describe as music, as
Wallace Berry notes, “Musical structure may be said to
Set theory has become a standard tool in 20th Century be the punctuated shaping of time and space into lines of
music composition [Straus]. aa-cell make extensive use growth, decline and stasis hierarchically
of set theory for manipulating pitch space (tonal or ordered.” [Berry 1976 pp??].
otherwise) [lerdahl]. Pitch Class Sets (PCS) provide a Our live coding makes extensive use of Impromptu’s
simple yet powerful tool for manipulating musical ability to precisely schedule closures (a function and its
patterns. environment) for future invocation. The ability to
By applying common musical devices such as schedule functions self referentially was first discussed
inversion, expansion/contraction, retrograde and in 1984 by D. Collinge in reference to his Moxie system
transposition to a musical cell, or motif, and then [9]. Using this mechanism functions1 may continuously
filtering the output though a PCS quantisation process it re-schedule their own invocation. The ability for a
is possible to rapidly develop interesting musical
;; a chromatic one octave random walk The code example above demonstrates a simple
;; crotchet and quaver rhythm in samples
temporally recursive transition network. The network
(define melody
contains two nodes, the functions func-a and func-b,
(lambda (pitch duration)
(play-note (now) piano pitch 60 duration) each maintaining its transition conditions specified
(callback (+ (now) duration) within the callback function. In this example, func-a is
called and must call itself ten times before passing adequately reducing the time spent defining higher level
control (calling) to func-b, which then has a 50/50 formal structures, there is a severe physical limit to the
chance of calling itself or calling back into part-a. This amount of immediate change available in a text based
simple technique provides a useful mechanism for environment. To be clear, we are not suggesting that
building higher level musical structure on-the-fly. immediate change cannot be “programmed”, we do this
regularly, but as live programmers our ability to respond
4. PERFORMANCE PRACTICES immediately is limited by the time required to make and
evaluate source code changes.
In addition to the computational approaches inherent in
aa-cell’s practice, there are a number of performance 4.2.1.Editor tools
considerations that do not impact so much on the We ameliorate this situation, in part, by providing
musical result as on the effectiveness and presentation functionality in the text editing environment. For
of performances. example, Impromptu allows programmers to set up to
ten mark points. These marks can be set, moved to and
4.1. Code Expansion have their underlying expressions evaluated with key
One problem that all live programmers must deal with is bindings. This provides for rapid movement around the
how to physically type the required code within a text editing environment and allows programmers to
reasonable period of time; reasonable for both the evaluate text that maybe located outside of the current
audience but, probably more importantly, to assist the viewable text region or even in another text buffer.
performer to more rapidly realise ideas. 4.2.2.External controllers
In addition to parsimonious and efficient
algorithmic descriptions discussed in section three, an Text editing features only go so far in providing
obvious way to deal with this issue is to abstract away real-time programmers with the ability to effect
as much detail as possible into pre-built functions and immediate change. To augment, or provide better
libraries. This “preparation” is an important aspect of gestural control, we can also employ external control
live-coding and aa-cell regularly spend time working on surfaces with various dials, faders, buttons and so on.
library code. However, the downside with this approach Impromptu can communicate to these via MIDI or OSC
is that abstracting away the ideas restricts our ability to as required. We have developed code libraries to
change, modify and re-evaluate the code during the facilitate the direct assignment of external controllers to
performance. We spend a good deal of any given pre-bound global symbols. In practice this allows aa-
performance modifying and extending code structures, cell to trivially assign controller values to arbitrary code,
in fact a performance may well be based around the providing real-time gestural control at any point in our
constant manipulation of a single temporal recursion. code.
Given that code is our medium, and that abstracting
;; play a series of notes with random pitch
away code reduces our range of expression we have
;; bounded by the current value of
been using code expansion as a complementary ;; controller 1 and controller 2
technique to functional abstraction. Code expansion (define melody
allows aa-cell to program the essential elements of an (lambda ()
expression and abstract away the remaining details to a (play-note (now) piano
code template. The template generates code based on the (random ctrl1 ctrl2)
arguments supplied to the template. Once the generated 60 22050)
code is pasted into the environment we can interact with (callback (+ (now) 22050) 'melody)))
it as normal; executing, extending and running it as we
would any other code. Our code expansions cover a In particular we have found that control surfaces
basic set of regularly usage patterns including melodic, with motorised controllers allow two way
chordal and rhythmic structures. Code expansion communication between musician and computer.
provides aa-cell with an efficient mechanism for Manual control can update assigned values, and
customising common usage patterns and has proven programmatic variations can be reflected in automated
itself to be a huge benefit in performance as it allows us movement of the motorised controllers.
to concentrate on the essential details without having to It is worth emphasising that the interactive, real-
worry about writing boiler plate code. time influence exerted on the generative algorithms at
play is, we believe, central to our live coding practice.
4.2. Non-programmable control
4.3. Collaboration and Communication
While text programming languages can be an effective
medium for expressing processes and structures, their Like any performance practice, live coding requires
textual nature makes them less capable of handling rapid coordination between the performers and consideration
change. The issue of rapid change in live programming of how the audience relates to the performance practice.
is of continuing concern for live programmers. As
4.3.1. Collaboration
Fredrik Olofsson states, “I feel I’d have to rehearse a lot
more to be able to do abrupt form changes” [7]. In our The major consideration regarding collaboration
experience the problem may be more intractable than between performers in aa-cell relates to
this. While we have been able to find methods, such as synchronisation, timing and data sharing. At a global
code expansion and functional abstraction, for level this often includes tempo, metre, harmonic
Sorensen, A. and Brown, A. R. (2007). aa-cell in practice: an approach to musical live coding. Proceedings of the International
Computer Music Conference, Copenhagen. ICMA, pp. 292-299.
progressions and other structural features. Impromptu Critics of live coding have suggested that this makes
supports a number of mechanisms for communication the projection of the source code an unnecessary and
between remote hosts. intrusive endeavour. Our experience is that despite
In recent years Open Sound Control (OSC) has people’s inability to understand the detail of the code,
become a de-facto standard for musical communication they appreciate that the work is being built up as it
and provides a convenient mechanism for proceeds and seem to enjoy participating in identifying
communication between Impromptu hosts and a variety symbolic queues. To this end we make an effort to use
of other computer music tools supporting the OSC function and variable names that people will recognise
protocol. and that may assist in their interpretation of the code.
I m p ro m p t u a l s o o ff e r s a n I n t e r P r o c e s s Symbol names such as “outrageous-kick” and “grunge-
Communication (IPC) mechanism for communication it-up” never fail to communicate our intent! Regardless
directly between remote processes. This provides a of the audiences’s level of understanding, code
powerful mechanism for sharing and executing code projection highlights to the audience that structures are
across remote Impromptu hosts. In practice this allows coded during the performance. This is particularly
aa-cell to share functions and global variables during a important at this early stage in the development of live
performance. More specifically the IPC mechanism coding as a musical practice.
allows us to define functions and variables in each To further enhance the appreciation that live coding
other’s Scheme interpreter. Unfortunately this powerful builds structure on the fly we always start our
feature is limited without the ability to view and edit the performances with a blank text editor. We feel that the
associated source code. growing complexity of the typed code paralleled by the
In order to resolve this issue, aa-cell anticipate the increasing complexity of the sonic outcome helps to
future addition of a collaborative text editing articulate the building process to the audience. In
environment to the Impromptu IDE3 . This would addition, the Impromptu environment has text
provide live programmers with the ability to work highlighting features that not only assist the
collaboratively on a single source code file programmer, but the audience to see where the
simultaneously. We anticipate this to be a significant programmer’s attention (cursor) is positioned and to
addition that would allow live programmers to work indicate when functions are evaluated.
together in a more substantially collaborative
environment. However, that said, aa-cell also enjoy 5. CONCLUSION
exploring the separation of environments.
Impromptu’s precise timing and interactive In this paper we have outlined the theoretical and
environment encourages users to “perform.” By this, we practical aspects that are significant in our live coding
mean that aa-cell often work without the safety net of practice as aa-cell. The paper has focused particularly
networked time codes, shared harmonic structures etc. on processes related to musical structure and event level
and instead concentrate on performing our individual considerations and discusses some of the techniques that
environments by manually timing the execution of code, aa-cell have found useful for defining musical processes
manually adjusting tempo and metre, and interacting in in a live coding performance.
a constant dialogue of harmonic and timbral change We are certainly not the first people to discuss the
within a vocabulary of shared musical queues. No doubt usefulness of simple mathematical functions for
our continued exploration of live coding practice will modeling musical behaviors and it is perhaps
continue to oscillate between fixed and freer forms of unsurprising that aa-cell would find these functions
coordination. useful in our practice. What has been a surprise to us,
however, is just how much utility a small set of
4.3.2. Audience Communication processes have provided. It is possible that our success
with these simple functions is due to our manual control
In order to enhance the audience appreciation of aa-
of higher level structure through our manipulation of
cell performances we have adopted a number of
running process, but it may also point to a more
performance conventions. As has become standard in
profound revelation about parsimonious computational
live coding practice we project the computer displays so
representations of music and improvisational
that the audience can see the code being typed. We try to
performance. We hope to expand more on these ideas in
make the code as legible as possible.
the future.
However, even with a strongly technical audience,
Many of the performance aspects of live coding
complete comprehension of the generative ramifications
practice are still being hotly debated and aa-cell are still
of the source code being run during a performance is
actively considering the pros and cons of various
challenging. Knowledge of the programming language,
performance related issues. However, we feel confident
the environment, the algorithms used, musical, sonic
that as the practice matures, and audiences become more
and more general cultural knowledge, even knowledge
familiar with this new practice, these issues will resolve
of individual performers’ practice are all necessary for a
themselves. In the meantime we are busying ourselves
complete mapping of the projected code to the musical
with music making.
outcome. Consequently, most audiences will struggle to
This article has provided several brief, and
fully realise the connections between the code and any
necessarily trivial code examples. We have provided a
generated material.
web page http://impromptu.moso.com.au/icmc-
3 For a good example of collaborative text editing see the SubEthaEdit text editor http://www.codingmonkeys.de/subethaedit/
Sorensen, A. and Brown, A. R. (2007). aa-cell in practice: an approach to musical live coding. Proceedings of the International
Computer Music Conference, Copenhagen. ICMA, pp. 292-299.
examples.html with supplementary material relating to Computer Music Conference. San Francisco:
this paper, including expanded code examples and ICMA
related audio recordings. We hope this will provide [12] Click Nilson (Forthcoming 2007) Live Coding
more compelling documentation for the interested Practice In Proceedings of the New Interfaces
reader. Screen casts of complete live coding for Musical Expression Conference 2007.
performances can also be found on the Impromptu
website. [13] Collinge, D. J. (1984) MOXIE: A Language for
Computer Music Performance. In Proceedings
6. REFERENCES of the 1984 International Computer Music
Conference. San Francisco: Computer Music
[1] Berg, P. 1996. Abstracting the Future: The Association
search for musical constructs. Computer Music
Journal 20(3): 24-27. [14] Collins, N., McLean, A., Rohrhuber, J. and
Ward, A. 2003. Live Coding in Laptop
[2] Berry, W. 1976 “Structural Functions in Music” Performance. Organised Sound 8(3): 321-330.
General Publishing Company Limited
Toronto,Ontario. 1987 Publishing by Dover [15] Collins, N. 2003. Generative Music and Laptop
Mineola, NY. Performance. Contemporary Music Review.
22(4): 67-79.
[3] Blackwell, A. and Collins, N. (2005). The
Programming Language as a Musical [16] Collins, N. and Olofsson, F. 2006. klipp av:
Instrument. In P. Romero, J. Good, E. Acosta Live Algorithmic Splicing and Audiovisual
Chaparro and S. Bryant (eds.) Proceedings of Event Capture. Computer Music Journal. 30(2):
the 17th Workshop of the Psychology of 8-18.
P ro g r a m m i n g I n t e re s t G ro u p . S u s s e x [17] Cope, D. (2000). The Algorithmic Composer.
University, pp. 120-130. Madison: A-R Editions.
[4] Brown, A. R., Towsey, M., Wright, S. and [18] Dean, R. (2003). Hyperimprovisation:
Diederich, J. (2001). Statistical analysis of the Computer-Interactive Sound Improvisation.
features of diatonic music using jMusic Middleton: A-R Editions.
software. Proceedings of the Computing Arts
2001: Digital Resources for Research in the [19] Desain, P. & Honing, H. (1993). Tempo curves
Humanities. Sydney, pp. considered harmful∗. In Time in contemporary
musical thought J.D.Kramer(ed.),
[5] Brown, A. R. (2002). Opportunities for Contemporary Music Review. 7(2). 123-138.
Evolutionary Music Composition. In P. Pre-printed in: Desain, P. & Honing, H. (1992).
Doornbusch (ed.) Proceedings of the Music, Mind and Machine. Studies in Computer
Australasian Computer Music Conference. Music, Music Cognition and Artificial
Melbourne: ACMA, pp. 27-34. Intelligence.Amsterdam: Thesis Publishers.
[6] Brown, A. R. (2004). Playing with Dynamic [20] Dodge, C. and Jerse, T. A. (1997). Computer
Sound. In E. Edmonds and R. Gibson (eds.) Music. New York: Schirmer Books.
Proceedings of the Interaction: System,
Practice, Theory. Sydney: Creativity and [21] Haus & Sametti 1992 in “Computer Generated
Cognition Studios Press, pp. 435-450. Music” editor Denis Baggi. 1992 IEEE
Computer Society Press
[7] Brown, A. R. 2004. An aesthetic comparison of
rule-based and genetic algorithms for [22] Hiller, L. and Isaacson, L. 1992. Musical
generating melodies. Organised Sound 9(2): composition with a high-speed digital
191-198. computer. In Machine Models of Music, S. M.
Schwanauer and D. A. Levitt, Eds. MIT Press,
[8] Brown, A. R. (2005). Exploring Rhythmic Cambridge, MA, 9-21.
Automata. In F. e. a. Rothlauf (ed.) Proceedings [23] Huron, D. (2006). Sweet Anticipation: Music
of the Applications of Evolutionary Computing: and the Psychology of Expectation. Cambridge
EvoWorkshops 2005. Lausanne, Switzerland: MA: MIT Press.
Springer, pp. 551-556. [24] Lerdahl, F. (2001) Tonal Pitch Space. NY, NY:
[9] Brown, A. R. 2003. Music Composition and the Oxford University Press.
Computer: An examination of the work [25] Rowe, R. (1993). Interactive Music Systems:
practices of five experienced composers. PhD Machine listening and composing. Cambridge,
dissertation. Brisbane: The University of MA: MIT Press.
Queensland.
[26] Sorensen, A. and Brown, A. R. (2000).
[10] Brown, A. R. 2006. Code Jamming. M/C Introducing jMusic. In A. R. Brown and R.
Journal 9(6). http://journal.media- Wilding (eds.) Proceedings of the InterFACES:
culture.org.au/0612/03-brown.php The Australasian Computer Music Conference.
[11] Clynes, M. (1984) The secret life of music. In Brisbane: ACMA, pp. 68-76.
Proceedings of the 1984 International [27] Sorensen, A (2005). Impromptu: an interactive
programming environment for composition and
Sorensen, A. and Brown, A. R. (2007). aa-cell in practice: an approach to musical live coding. Proceedings of the International
Computer Music Conference, Copenhagen. ICMA, pp. 292-299.
p e r f o r m a n c e . I n P ro c e e d i n g s o f t h e
Australiasian Computer Music Conference,
2005.
[28] Sorensen, A. The Impromptu programming
environment: http://impromptu.moso.com.au
[29] Straus, J. N. (1989). Introduction to Post Tonal
Theory. Prentice Hall College Div.
[30] Taube, H. (2004). Notes from the Matalevel:
Introduction to Algorithmic Music Composition.
London: Taylor & Francis.
[31] Winkler, T. (1998). Composing Interactive
Music. Cambridge, MA: MIT Press.
[32] Wang, G. and Cook, P. R. (2003). ChucK: A
Concurrent, On-the-fly, Audio Programming
Language. Proceedings of the International
Computer Music Conference. ICMA, pp.
219-226.
[33] Xenakis, I. (1992). Formalized Music: Thought
and Mathematics in Music. Stuyvesant NY:
Pendragon Press.