Csound Magazine Summer 1999

Beginners Synthesis Processing Real-Time AXCsound Composing Ecological Modeling Links Editorial Contribute Back Issues

Using CMask in ecological modeling

Damián Keller
School for the Contemporary Arts
Simon Fraser University
June 1999





Examples: 1 2 3 4 5 6


CMask is a score generator for the audio synthesis language Csound (Vercoe, 1993). This helper application features several functions to produce stochastic events in Csound (Bartetzki, 1997). This short tutorial presents some simple examples and provides the basic features of more elaborate scores used in ecologically-based pieces. Other examples can be found in touch¹n¹go (Keller, 1999).

This tutorial does not cover the basics of CMask or Csound because manuals for both applications are widely available (cf. links). As far as possible, we will provide links to definitions and pointers to web documentation. Before getting into the subject we have to warn the user of some limitations in CMask:

  • It ignores its output, so it only allows for a top-down compositional approach.

  • It lacks state-dependent parameter control. All variables are defined at initialization time and cannot be changed according to the state of other variables.

  • It lacks state-dependent time control. Duration of an event is defined at initialization time.

    To overcome these limitations we have resorted to other software to generate the Csound scores: AC Toolbox (Berg, 1998), Alcaucil (Keller, 1998). Nevertheless, CMask has proven to be useful for synthesizing several sound classes. The working method that we present in this tutorial covers a few classes of ecologically-modeled sounds, and provides some basic examples of the ecological approach to sound resynthesis. No attempt is made to cover theoretical and conceptual issues which are already discussed in other sources (cf. Keller & Truax, 1998; Keller & Rolfe, 1998; Keller, 1999b).



    Conventions

    Throughout this tutorial, we use the word event to define a sound produced by the combination of multiple grains (in the order of hundreds to thousands). The grains are previously sampled and edited sounds which keep their original spectral and temporal qualities (Keller & Truax, 1998). Thus, a single event is generated by this procedure:

  • Generate a single-section score in CMask.

  • Synthesize the event in Csound by loading an orchestra, the produced score, and the necessary samples.

    We have tried to keep some consistency by following Csound syntax conventions in the score formatting process. Resolution is always kept at 5 decimal places for floating point variables, and at integer for integer variables (usually used for ftable numbers). In CMask syntax it is indicated thus:
    prec 5    ; 5 decimal places (0.00000).

    prec 0    ; integer.

    Most parameter values are normalized (0 to 1 range) and scaled in the Csound instrument. We keep the sound file¹s original amplitude and select the scaling option in Csound to avoid clipping.



    Parameter fields

    Each CMask parameter stands for a pfield in Csound. p1 to p3 are mandatory to get any output from CMask. To simplify notation, we have not included these parameters in the examples. So the user should add them when trying out the examples. All our Csound instruments read each line score by this convention (p stands for pfield or parameter field):
    (mono)

    p1 instrument number

    p2 onset time

    p3 duration

    p4 amplitude

    p5 frequency

    p6 sound file

    (stereo)

    p1 instrument number

    p2 onset time

    p3 duration

    p4 amplitude

    p5 frequency left channel

    p6 frequency right channel

    p7 sound file left channel

    p8 sound file right channel

    Sound files

    ftables provide the fastest way to keep sounds available in RAM. When using stereo files, care should be taken to keep the stereo image by using consistent playback of the two channels (of course, sometimes this is not wanted or needed). Here is a typical ftable statement:
    f2 0 65536 -1 ³soundfile.sd2² 0 4 1 ; left channel
    f3 0 65536 -1 ³soundfile.sd2² 0 4 2 ; right channel

    We reserve ftable 1 for the windowing function. While using several dozens (or hundreds) of sound files, we felt the need to automate this process a bit. So we made some Applescripts for BBEdit 4.0 to write the file names and the trapezoidal window function.



    Interpolation

    There are three types of interpolation available in CMask (we encourage to use always one of them):

    ipl 0

    ipl 1.5

    ipl -1

    ipl cos
    ; linear: a straight line between initial and end value.

    ; exponential: a convex curve when the sign is positive.

    ; a concave curve when the sign is negative.

    ; half-cosine: useful when doing smooth transitions between adjoining events.




    Random functions

    There are two possible uses of random functions in CMask: (1) fixed range, (2) time-varying range. In the fixed range case, the low and high boundaries are kept constant throughout the event duration. For the time-varying range a tendency mask is employed.


    Example 1
    f 0 5

    p1 range .1 .3

    prec 5
    ; Fixed range

    ; random function.

    ; low boundary = .1, high boundary = .3.


    f 0 5

    p1 range .1 2

    mask [.1 1] [.3 2]

    prec 5
    ; Time-varying range

    ; random function.

    ; initial low boundary = .1

    ; initial high boundary = .3,

    ; final low boundary = 1

    ; initial high boundary = 2

    In the fixed range example, the grain onsets will be constantly spread between 10 and 30 ms. In the second example, the density will begin at a 10 to 30 ms. range and will finish at a range of 1 to 2 seconds once the five-second event duration has elapsed.



    Random to deterministic transitions

    There are two methods in CMask to establish transitions from random values to deterministic patterns. One is to use a tendency mask to reduce the range until a single value is reached. Another one is to set a grid of values using quant. Then change the degree of randomness around the deterministic grid.


    Example 2
    f 0 5

    p5 range .8 1.2

    mask [.8 1] [1.2 1]

    prec 5

    In this example, the playback frequency of the sound file is randomly varied within a range of 20% higher and 20% lower sample rates. This range is shrunk until the original frequency is reached after 5 seconds.


    Example 3
    f 0 5

    p4 range 0 1

    quant .2 [1 0] .1

    prec 5
    ; random function, range = 0-1

    ; grid parameters: interval = .2

    ; strength = 0 to 1

    ; offset = .1

    In this case, we set a grid for the amplitude values at an interval of .2, that is (0, .2, .4, .6, .8, 1). Given that the strength parameter is set to maximum, 1, the only amplitudes values that we¹ll get are the ones in the grid. Let¹s say that we do not want any silence (amplitude = 0). Then we set the third parameter, offset, to .1. This adds .1 to all values so we will get values from .1 to 1.1, and the grid will become (.1, .3, .5, .7, .9, 1.1). As time passes, the grid strength is reduced until reaching 0. At 5 seconds, the grid disappears and we are left with a random distribution.



    Bubble-gum functions

    Most ecological sound models are constrained to a small variation in their time-spans. Their timbral characteristics are directly linked to their evolution through time. By keeping parameters linked to the time-axis we allow for changes in their time-scale without affecting their mesostructure and without having to remap parameters. In simple words, bubble-gum functions work as a bandoneon. They adapt to the Œlength¹ they are given. These functions are defined by:



    Example 4
    f 0 1

    p4 seg [1 0 ipl 0]

    prec 5
    ; time-span = 1 second

    ; pfield 4 = a line going from 1 to 0.

    ; Interpolation = linear.

    ; Precision = five decimals. (0.00000).
    f 0 2

    p4 seg [1 0 ipl 0]

    prec 5
    ; time-span = 2 seconds

    ; pfield 4 = a line going from 1 to 0.

    ; Interpolation = linear.

    ; Precision = five decimals. (0.00000).


    In this example, the event duration is extended from 1 second to 2 seconds. We can use exactly the same CMask function because we indicated only initial and end time. This is accomplished by using [ ] instead of ( ) (cf. CMask manual for details on the syntax). Thus, [1 0 ipl 0] replaces the breakpoint function (0 1 1 0 ipl 0).



    Concatenating sub-events

    When synthesizing complex events, such as breaking glass or multi-bouncing patterns, sometimes we need to combine several sub-events. When a seamless transition is desired half-cosine interpolation can be used to concatenate the grain distribution of two sub-events. Extending the previous example:


    Example 5
    f 0 5 p4 range 0 1

    mask [0 1 ipl cos] [.1 1 ipl cos]

    prec 5
    ; first sub-event.

    ; half-cosine interpolation.
    f 5 10 p4 range 0 1

    mask [1 0 ipl cos] [1 .1 ipl cos]

    prec 5
    ; second sub-event.

    ; half-cosine interpolation.

    By combining two sub-events of 5 seconds, we get a ten-second event with an amplitude profile going from 0-.1 to 1-1 and back to 0-.1. No discontinuity or sudden peak will be produced at 5 seconds.



    Three CMask operators: accum, mask, and quant

    accum, mask, and quant have been widely used in ecological models. So we provide some CMask examples to show how they can be employed in simple tasks. accum has been used to implement a scraper model. quant allowed us to produce a continuum of voice-like clusters which slowly turn into a rich harmonic sound (cf. Vox Populi in touch¹n¹go).


    Example 6


    accum
    1. accumtest.msk
    2. accumtest.orc
    3. accumtest1.msk


    Samples

    1. bot.sd2
    2. metal.sd2
    quant
    1. quantest.msk
    2. quantest.orc
    3. quantest1.msk
    4. quantest2.msk
    5. quantest3.msk
    mask
    1. mask2events.msk
    2. mask2events.orc
    3. masktest.msk
    4. masktest.orc
    5. masktest1.msk
    6. masktest2.msk
    7. masktest3.msk
    8. masktest4.msk
    9. masktest5.msk

    (Reminder: when synthesizing the examples, do not forget to place the two samples provided, in the Csound sample folder. The samples are in Sound Designer II format.)



    References and links

    Bartetzki, A. (1997). CMask. Csound score generator. Berlin: STEAM.
    ftp://ftp.kgw.tu-berlin.de/pub/cmask/
    http://www.kgw.tu-berlin.de/~abart/CMaskMan/CMask-Manual.htm

    Berg, P. (1998). Algorithmic Composer Toolbox. Macintosh PPC application. The Hague.

    Keller, D. (1998). Alcaucil. Csound score generator for ecologically-based granular synthesis. Burnaby, BC: Simon Fraser University.
    http://www.sfu.ca/~dkeller/download.html

    Keller, D. (1999a). touch'n'go / toco y me voy. Compact Disc. Burnaby. BC: earsay productions.
    http://www.earsay.com

    Keller, D. (1999b). touch'n'go: Ecological Models in Composition. Master of Fine Arts thesis. Burnaby, BC: Simon Fraser University.
    http://www.sfu.ca/sonic-studio/srs

    Keller, D., & Rolfe, C. (1998). The corner effect. Proceedings of the XXI Colloquium in Musical Informatics. Gorizia, Italy.
    http://www.sfu.ca/~dkeller/CornerEffect/CornerEffect.html

    Keller, D., & Truax, B. (1998). Ecologically-based granular synthesis. Proceedings of the International Computer Music Conference. Ann Arbor, IL: ICMA.
    http://www.sfu.ca/~dkeller/EcoGranSynth/EGSpaper.html

    Vercoe, B. (1993). Csound. Cambridge, MA: MIT Media Lab.
    http://www.leeds.ac.uk/music/Man/c_front.html
    http://mitpress.mit.edu/e-books/csound/frontpage.html




    Examples: 1 2 3 4 5 6


    Send comments to:

    dkeller@sfu.ca


    Csound Magazine Summer 1999

    Beginners Synthesis Processing Real-Time AXCsound Composing Ecological Modeling Links Editorial Contribute Back Issues