Vous êtes sur la page 1sur 6

   

AMFM – A Minimal Fractal Music Language

Mondegreen Team
Apoorv Agawal Architect aa2644@columbia.edu
Brian Hsieh Tester bh2181@columbia.edu
Pier Francesco Palamara Tools Guru pp2314@columbia.edu
Tal Giat Project Manager tg2235@columbia.edu
  2

I. Domain and Motivation

The AMFM language is mainly intended to provide a support for musical


experimentation. Music consists of sounds organized in time, and its structure
(rhythm, harmony, melody, structure, and texture) has been studied for several
centuries. Music can be coded in several ways, and many computer languages for its
representation have been created in the past few decades. Some languages are also
intended to support composers and help them explore new possible combinations of
sounds. The expression Algorithmic Composition1 has recently emerged to describe
the use of algorithms to create music. This can be achieved using mathematical
models, knowledge-based systems, grammars, evolutionary methods, machine
learning, or a combination of these approaches.
A large number of languages for music generation that we have encountered
in our search rely on the principle of self-similarity. In these languages some patterns
are extracted from a string of notes, and then used to evolve the same string of notes
in a fractal-like song. The most cited language of this kind is Fractal Composer2.
Fractal composer allows the creation of interesting fractal-like songs with a very
small effort. A user is only required to define a “germ” (i.e. a small number of initial
notes) and some parameters, and a self-similar number of extensions are added,
resulting in a song. This process produces interesting results, but somewhat limited by
the fact that only a germ can be specified, whereas music composition is often the
result of creative interleaving of different patterns and instruments that yield a
pleasant interaction.
AMFM makes use of self-similarity to assist the user with the composition,
providing a mean of easily creating songs from an initial string of notes. Differently
from Fractal Composer, AMFM allows the definition of multiple patterns, providing a
way of interleaving them. To do so, it takes inspiration from another publicly
available language: Context Free Art3. Context Free Art is a language for the creation
of images from a set of rules that resemble a context free grammar. The rules are
recursively called while some elementary shapes are being printed on the screen.
Some of the shape parameters are dynamically changing to create widely different
forms with a very limited number of instructions (e.g. the examples available at
http://www.azarask.in/projects/algorithm‐ink/). AMFM borrows this grammar-
like programming approach, porting it to the music domain. It also relies on Fractal
Composition, to allow a user to easily build songs by providing some simple strings
of notes. AMFM doesn’t require more musical and programming ability than what is
required to users of Fractal Composer or Context Free art. The language produces
MIDI files that can be edited and modified. A stochastic component is present in the
language, so that the user is not completely controlling his composition. This feature,
together with the aid provided by the self-similarity, allows for an interesting musical
experimentation.
                                                        
1 http://en.wikipedia.org/wiki/Algorithmic_music 

2 http://fractalcomposer.com/ 

3 http://www.contextfreeart.org/ 

 
  3

II. Language Properties

AMFM is a functional language since it has no state and no mutable data.


Since rules are defined with probabilities the compiler cannot determine which rule to
call at compile time and thus the language will use late (runtime) binding.
The output of the compiler will be our own proprietary language that will be
read by a renderer written in Java using the Java Sound API4 that would take this
language as input and will produce music or (an optional nice-to-have) MIDI5 file.

III. Syntax

AMFM has a succinct syntax, which consists mostly of simple rule definitions (rules
are equivalent to procedures in other languages). There are very few operators or
expressions and there are no semicolons.

startrule The rule to start with


maxbars The maximal number of bars the program will play
rulename p#{ } Rule definitions, where rulename is defined by the
regexp[a-zA-Z][a-zA-Z0-1]*
p# Denotes a probabilistic rule, where # is an integer, this
is not mandatory (default p1)
rulename(args) Execute a rule
Instrument(notes) Play an instrument with the given notes
// Comment (ends at the end of line)

A rule can only contain instruments and rule executions. The arguments for a rule
execution are the dimensions we want to apply the fractal behavior on, two options
are available P – for pitch and V- for volume. Thus a rule execution can be called
with zero and up to two arguments.

Musical Notes
We borrow the syntax used by fractal composer6 for the specification of our seeds.
The syntax for the seeds has the following format:

INSTRUMENT(<Pitch Class>\s+ <ScaleName>\s+ NOTE1\s+ NOTE2…)

Where \s is the space character ‘ ’, INSTRUMENT is an instrument in the set


{PIANO, FLUTE}, ScaleName is a scale type in the set {MAJOR, MINOR} and
each note has the format:

<Pitch Class><Octave>, \s* <duration fraction>, \s* <volume>

                                                        
4 http://java.sun.com/products/java‐media/sound/ 

5 http://en.wikipedia.org/wiki/Midi  

6 http://fractalcomposer.com/ 
  4

with:
• Pitch Class: A letter name (A to G), optionally followed by a #
• Octave: A number from 0 to 9 specifying which octave this note is in.
• Duration Fraction: A fraction indicating how long the note should last.
• Volume: One of PPP, PP, P, MP, MF, F, FF or FFF, listed in magnitude order.

Example of a seed:

PIANO(C MAJOR F4,1/4,MF G4,1/8,F A4,1/8,MF)

All notes for all instruments should be the same length otherwise a semantic error will
be returned.

IV. Sample Code

Example I
startrule RULE1

maxbars 3

RULE1{

PIANO(C MAJOR F4,1/4,MF G4,1/8,F A4,1/8,MF F4,1/4,MF,F4 G4,1/8,F)

RULE1()

 
 

 
  5

Example II 
startrule RULE1

maxbars 4

RULE1 p4{

PIANO(C MAJOR F4,1/4,MF G4,1/8,F A4,1/8,MF F4,1/4,MF,F4 G4,1/8,F)

RULE1(P)

RULE1{

PIANO(C MAJOR F4,1/4,MF G4,1/8,F A4,1/8,MF F4,1/4,MF,F4 G4,1/8,F)

RULE1(P)

RULE2 ()

RULE2 {

FLUTE (C MAJOR F4,1/4,MF G4,1/8,F A4,1/8,MF F4,1/4,MF,F4 G4,1/8,F)

RULE2 (V)

 
The user starts by defining a few rules and a start rule. Rules contain the instrument to
be played and the notes. 'P' in RULE1 implies the fractal function is applied on the
pitch of the notes, 'T' stands for volume. p<x> are the probabilities with which a
certain rule will be selected. The timeline below shows the step-by-step traversal of
our program.

 
  6

Example I shows the way Fractal composer will perform if we were to use our
language to mimic it. Example II shows the strength of our language in comparison to
Fractal Composer. In Example I, the first line of code states the starting rule. Since
there is only one RULE1, it is called. maxbars specifies the length of time for which
the composition resulting from our language will be played for. Once RULE1 is
called the statements inside the RULE1 block are expanded. It must be noted that the
expansion follows a breadth first order of expansions. For instance, when RULE1 is
called, the statement stating the instrument (Piano in this case) and a call to RULE1
are put at the head of a priority queue. Once Piano is expanded, the instrument to be
played becomes available. Also, the notes and their length is available at this point.
Thereafter, RULE1 is called again. The empty parenthesis in our sample example
could have for instance P (pitch) or T (volume) as an input. Empty parenthesis means
play the earlier set of notes again without any transformation. In case of P, a fractal
transformation will be applied to the pitch and then played using the instrument in
context. Example II conveys the probabilistic nature of our language that makes it a
dynamic tool for producing music. The probabilities are optional to mention. If they
are absent, they'll be assumed as 1. Moreover, probabilities of the same rule should
sum to 1. In case they are greater or less than 1, we could either lag an error message
or normalize the probabilistic scores to make them sum to one. This is actually a
design question that we look to resolve at the time of fixing a grammar for our
language.