Proceedings of SMC Sound and Music Computing Conference 2013
Total Page:16
File Type:pdf, Size:1020Kb
Proceedings of the Sound and Music Computing Conference 2013, SMC 2013, Stockholm, Sweden Komeda: Framework for Interactive Algorithmic Music On Embedded Systems Krystian Bacławski Dariusz Jackowski Institute of Computer Science Institute of Computer Science University of Wrocław University of Wrocław [email protected] [email protected] ABSTRACT solid software framework that enables easy creation of mu- sical applications. Application of embedded systems to music installations is Such platform should include: limited due to the absence of convenient software devel- • music notation language, opment tools. This is a very unfortunate situation as these systems offer an array of advantages over desktop or lap- • hardware independent binary representation, top computers. Small size of embedded systems is a fac- • portable virtual machine capable of playing music, tor that makes them especially suitable for incorporation • communication protocol (also wireless), into various forms of art. These devices are effortlessly ex- • interface for sensors and output devices, pandable with various sensors and can produce rich audio- visual effects. Their low price makes it affordable to build • support for music generation routines. and experiment with networks of cooperating devices that We would like to present the Komeda system, which cur- generate music. rently provides only a subset of the features listed above, In this paper we describe the design of Komeda – imple- but in the future should encompass all of them. mentation platform for interactive algorithmic music tai- lored for embedded systems. Our framework consists of 2. OVERVIEW music description language, intermediate binary represen- tation and portable virtual machine with user defined ex- Komeda consists of the following components: music de- tensions (called modules). scription language, intermediate binary representation, vir- tual machine and module system. The language helps to create a musical score with place holders – so called ”blanks” 1. INTRODUCTION – which are filled in by the code running as a part of user defined module. The score takes a form of note sequence We believe that artists creating music installations are lim- organized into patterns. In addition to that the language ited by the choice of platforms that can run their software. offers a limited set of control structures, pattern invoca- Personal computers, either desktops or laptops, can be too tion and statements that allow communication with mod- obstructive to the visual and spatial form of an installa- ules. Modules may represent instruments, note generator tion. Mobile devices (i.e. phones and tablets) are not well algorithms, sensors, etc. Each module is assigned a set of suited for this purpose – problems like: device cost, re- parameters and actions that a user can read, modify or in- placeability, complex software stack, limited battery life, voke, respectively. The binary representation was designed difficulties with expandability (i.e. no easy way to add to be platform independent bytecode for KomedaVM. The custom external sensors and output devices) don’t make virtual machine provides player routine – or more specifi- them a great choice. Apparently the most viable option is cally a scheduler and driver for instrument modules – and to use small embedded systems, which could be easily in- an interpreter for the bytecode. corporated into both static and movable parts of a music installation. Such systems should be build with affordable components and be easily expandable with peripherals. It 3. LANGUAGE is natural step forward to construct systems composed of 3.1 Design handful or tens of such devices. An artist that desires to explore the idea of distributed music generation should be The first and the most important component of Komeda able to easily expand the system with communication ca- platform – at least from user’s point of view – is the lan- pabilities and protocols. Hardware that matches the de- guage. It is mainly focused on providing a succinct mu- scription above already exists, but it’s not backed up by sic notation description. However, it is not solely a data definition language like XML. It incorporates computation statements, control structures and other features specific to Copyright: c 2013 Krystian Bacławski et al. This is programming languages. We enable the user to express an open-access article distributed under the terms of the easily following concepts: Creative Commons Attribution 3.0 Unported License, which permits unre- stricted use, distribution, and reproduction in any medium, provided the original • music organized into parts (i.e. patterns, phrases, author and source are credited. choruses), 239 Proceedings of the Sound and Music Computing Conference 2013, SMC 2013, Stockholm, Sweden • rich structure of music score (incl. loops, repetitions, some of them – most notable examples are key signatures, alternatives), bars and time signatures. Here we would like to supply • playback of score fragment in modified context couple of arguments for these omissions. (i.e. transposition, volume change), The notion of key signature associated with tonality was made somewhat obsolete by atonal techniques or scales • virtual player synchronisation (e.g. concerted transi- other than modes of the major system. Moreover, intro- tion to next music part), ducing the key signature could result in the decreased read- • interaction with external world (e.g. sensors, con- ability. Such is the case with Oliver Messaien’s prelude trollers). La colombe notated in E major key in which most of the chords have more than one accidental, which makes hard to Having language users without much of a former expe- keep track of exact pitches in signatures with four sharps. rience, we would like them to find the concepts clear and Similarly notation of music based on the non-standard hep- the code readable. To help with adoption of Komeda, we tatonic scales requires custom key signatures (e.g. some decided to base its syntax on something widely known in of the pieces from Bela Bartok’s Microcosmos which uti- both worlds – of music notation and programming lan- lize both flats and sharps in the signature) or usage of ac- guages. Hence, significant number of concepts were bor- cidentals instead of the key signature. Scales with more rowed from LilyPond [1] and Java. than seven pitch class appearing for example in the mu- The main challenges we experienced while designing Ko- sic of Bartok [4] [5] and Messaien (whose modes of lim- meda were: ited transposition [6] mostly have more than seven tones) cannot be notated without accidentals. The same happens • capturing all concepts needed to represent music score with works based on the serialism, dodecaphony and inter- unambiguously – i.e. a user should be encouraged to vals pairings [7] or other atonal techniques. There is also express ideas in the least number of possible ways, another argument for foregoing the key signature even for • balancing between having a readable syntax and con- tonal works. Contemporary composers often chose to no- cise notation – note that these two aspects collide tate them with only accidentals - great example here is the with each other, as shorter constructs become more first movement of III Symphony by Henryk Gorecki,´ who obscure, always notated F# with accidental in this E-minor piece. • finding effective mapping to intermediate form (Ko- Bars and metre are used in music mainly for three things: meda bytecode) – shape of binary data that repre- structuring, as a help for the performer in keeping track of sents the music to be executed in VM, the score and to introduce default accents in music. In Ko- meda the visual structure of music can be imposed using • simplicity of virtual machine and user modules. the white characters and comments. Obviously Komeda Our design went a complete overhaul several times, as we does not need any help in keeping track of the score, so were discovering dependencies between all three layers of we are left with only last application of measures. The Komeda environment: the language, the binary represen- problem of accent induced by metre is that there is not one tation and the virtual machine. standard of it. Underlying pulse of different time signa- At the time of writing we have working compiler from tures is associated with genre, period and personal styles Komeda to intermediate representation. The implementa- of both the composer and the performer. Moreover in the tion is written in Haskell, a purely functional language with contemporary music the implicit accent is non-existent [8]. strong static typing. Our choice is justified by a few argu- The lack of bars also simplify music generation. ments: 3.3 Syntax concepts • Haskell [2] has set of rich abstractions and expres- 3.3.1 Channels sive types - our code looks clear and simple, there is little verbosity or boilerplate code, that obliterates Top-level construct of komeda language is a channel. It the ideas, describes a behavior of monophonic audio source. Each • availability of great parser frameworks – Parsec [3] channel is assigned an independent thread of execution that is used to express Komeda grammar. interprets Komeda language and in turn produces note se- quence to be played. 3.2 Theoretical considerations channel 0 play @Pattern0 We choose to model the language after western music no- Listing 1: Channel notation example tation (with Helmholtz pitch notation). It has many draw- backs, nonetheless it is the most popular music notation The definition above states, that the channel number 0 which virtually anyone can read. Every person having for- will play a program defined by Pattern0. Number of mer experience with western music notation should imme- channels is limited by the implementation of KomedaVM diately recognize familiar structures in Komeda language. and may depend on hardware capabilities. On the other hand we didn’t try to create a music engraving Note that the program executed by the channel may make language, so we had some flexibility in implementing mu- use of certain sensor, voices or generator modules.