Algorithmic Composition
(with Csound and HTML5)

26 March 2018

Universidad Nacional de Quilmes, Buenos Aires


Michael Gogins

Irreducible Productions

http://michaelgogins.tumblr.com

About Me

  • Born in 1950, Salt Lake City, Utah, United States.
  • I was a music student for two years, but my degree is in comparative religion.
  • Independent composer since 1983, music programmer since 1991.
  • I present mostly things related to my own work.
  • There are many more approaches to algorithmic composition and to sound synthesis than I can show you here.
  • These are online slides that you can view from any Web browser.
  • My talk is mainly about algorithmic composition; however, some of my examples are live and actually run in Web browsers using Csound with HTML5.
  • I briefly introduce Csound and HTML5 so you can better understand what you are seeing.

Csound

  • You already know Csound... the software sound synthesis system, or sound programming language, written by Barry Vercoe in 1985.
  • Runs on Linux, OS X, Windows, Android, iOS, Raspberry Pi, Web browsers, and more.
  • APIs in C, C++, Java, JavaScript, Python, Lua, Lisp, and more.
  • Precisely because Csound is so old, it has a vast library of features, instruments, examples, etc.

HTML5

  • HTML5 is the name for standards defining HTML, JavaScript, and many other things on the Web.
  • It is an open standard, but follows the lead of Google, Apple, Mozilla, etc.
  • JavaScript is the programming language of the Web, enabling different objects in the browser to be programmed, interact, etc.
  • HTML5 is highly secure due to the browser sandbox.
  • It is versionless: everything from the old days still runs, and in the future will continue to run.

Csound and HTML5

  • Csound in each of these environments has the same interface; many pieces play in all environments.
  • Algorithmic compositions can be written in JavaScript.
  • My Silencio library provides a number of compositional algorithms.
  • Check out Gibber for another HTML5 music playground!

Csound+NW.js+HTML5

  • Csound compiled as a C++ addon runs in NW.js on desktop operating systems.
  • Csound runs as native code, multi-threaded, with native audio.
  • This is the most performant option.

WebAssembly

  • WebAssembly is a new Web standard for running compiled code on the Web.
  • JavaScript is fast, but WebAssembly can run just as fast as C.
  • WebAssembly can be compiled from source code written in C, C++, Rust, and more.
  • WebAssembly modules with JavaScript APIs can, of course, call each other.
  • WebAssembly might turn out to be a new universal computing platform.

Csound+WebAssembly+HTML5

  • Csound compiled for WebAssembly runs in major browsers and NW.js, and on desktop and mobile operating systems.
  • Audio performance with Web Audio is OK for light pieces, not good for demanding pieces.
  • This is the most portable option.
  • Audio performance may improve in time as Web Audio is improved, but there are serious issues.

Csound/HTML5


Algorithmic Composition

  • An algorithm is an effective procedure, i.e., one that can be performed by following instructions without needing to understand them, and stops with a definite result.
  • This is a fundamental concept of mathematics, and this is the technical definition.
  • Algorithmic composition is the art of composing music by writing or using algorithms.
  • Why bother? After all, you can already compose music without using any algorithms.
  • Can you?
    • The rules of voice-leading are algorithmic.
    • Canon and fugue are algorithmic.
    • The rules of harmony are algorithmic.
    • Developing variation is algorithmic.
    • The musical dice game of 1787 is a definite algorithm.

Computerized Algorithms = Programs

  • A computerized algorithm is called a program.
  • Computers run algorithms much faster than people can. This is an advantage -- not a qualitative advantage, but a major convenience.
  • Certain algorithms are computationally irreducible. It is impossible to predict the results of such algorithms without running them.
  • Irreducibility is a qualitative advantage. It amplifies the human imagination.

Irreducibility in Action

y ← 4 y c (1 - y)


0

A Few Kinds of Compositional Algorithms (more here)

  • Random variables
  • Markov processes and parody generators
  • Chaotic dynamical systems
  • Iterated function systems
  • Lindenmayer systems
  • Minimalist procedures
  • Pattern languages
  • Genetic algorithms
  • Machine learning

Problems of Algorithmic Composition

  • Not all aspects of music have known algorithms.
  • Even with good algorithms, there is too much garbage.
  • Algorithmic composition is rooted in early 20th century music, e.g. serialism, aleatoric music.
  • Tonal music, extended tonality, and contemporary trends are not so well represented.
  • Algorithmic procedures have not been applied much to acousmatic pieces.

Mathematical Music Theory

  • Just as atonal theory applies group theory to serialism, so neo-Riemannian theory applies abstract algebra to chord transformations and voice-leading.
  • A chord space is a metric space in which each chord is a separate point, and each pitch of a chord is represented by a separate dimension (Tymoczko 2006). Triads are 3-dimensional, seventh chords 4-dimensional, etc.
  • Many more kinds of mathematical music theory!
  • Group generators (T, I, T/I, Q/K) for basic symmetries of chord spaces (e.g. octave equivalence, transpositional equivalence, inversional equivalence, set type equivalence [Callender, Quinn, Tymoczko 2008]) can be used to generate or transform scores.
  • These operations are not exactly tonal, as they lack key and cadence.
  • However, I feel they are beautiful and can generate large-scale musical structures.

Trichords (OPC)

Chord Types (OPTC)

Set Classes (OPTIC)

Two Dualities (Python)

    Where is the irreducibility?

Scrims (HTML5)

  • Shows WHY HTML5 is such a big deal!
  • Interactive visual music: an animated voyage through variations on the hopalong fractal.
  • The performer controls, in real time:
    • Parameters of the hopalong fractal.
    • Mapping of fractal points to musical notes.
    • Neo-Riemannian transformations of notes.
    • Parameters of Csound instruments/effects.

Compositional Process

    Different composers have different methods. This is me. But I think there are some lessons.

    Irreducible algorithms produce complex patterns from simpler inputs. These patterns often have intrinsic beauty. That is because chaos and fractals generate much of the beauty in Nature.

    This reminds me of Aristotle's thesis that "art is the imitation of Nature."

    In this case the imitation is not on the surface of appearances, but on the deeper level of process.

    Generated patterns cannot be used raw.

    They must first be mapped to musical dimensions such as pitch and time.

    Sometimes the mapped patterns must be further transformed.

    Then the score must be arranged and balanced.

    This is an iterative procedure.

    Each of my pieces is always a single program. Sometimes the program generates several patterns that are combined in a collage.

    I work in a text editor with a key binding that instantly runs the piece in real time.

    This greatly speeds up the edit, render, listen, edit, ... cycle typical of computer composition.

    I write a dozen or so pieces until one seems interesting.

    Then I tweak the program repeatedly, the generative parameters, the transformations, the arrangement, etc.

    While Csound runs in real time, I use interactive controls to tweak the instrument sounds and balance.

    It's hard to improve a piece in one place without breaking it in another place.

    There's a lot of listening, over and over.

    If the piece pulls me in, if it makes me listen, I know I have something.

    If it not only pulls me in but doesn't have jarring flaws or awkward moments, I know I have something for you.

Blue Leaves 4e (C++)

    Where is the irreducibility?

Thank you!

Questions?