Category Archives: code

Common Music 3: Remix drum loops with Scheme

Working though porting some old instruments which generated Csound scores from Common Music 1 to Common Music 3. This example illustrates a few techniques I used in my piece Anxious from 1999. I kept myself to a few drum sounds, primary this loop, which comes from a Jimmy Smith tune originally, but was known to me through Professor Booty. Grab the loop - jam.aif Grab the .orc Grab the .scm file Here's the CM code:
; 14 segments for jam.aif
(define idxdur '((0.018 q) (.697 q) (1.376 s) (1.538 e)(1.869 s)(2.032 s)(2.2 e)
    (2.543 s)(2.705 q)(3.373 e.)(3.895 e)(4.232 q)(4.894 e)(5.236 s)))

; given the dur of a quarter, return tempo
(define (quarterDur->tempo quarterdur)
  (* 60 (/ 1.0 quarterdur)) 
  )

;
; remix - based on idxdur, remix sections of jam.aif loop
;
; args: 
; - tem: tempo (should be a float)
; - pan: angle to pan signal (between 0 and 90)
; - amp: attenuate signal (between 0.0 and 1.0)
; - totaldur: process continues until totaldur is exceeded
; 
(define (remix tem pan amp totaldur)
  (let* (
   (iter (make-cycle (list 
    (make-cycle '(5 6 7 8))
    (make-cycle '(5 6 7 8))
    (make-heap '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 ))
    (make-heap '(5 6 7 8))
    )))      
   (origtem (quarterDur->tempo (- .697 .018)))
   )
  (process with curtime = 0
             for t = (elapsed #t) ; get true score time
             for i = (next iter)
             for dist = 5
             for pct = .025
             for idx = (nth idxdur i)
             for indx = (nth idx 0) 
             for origdur = (rhythm (nth idx 1) origtem)
             for endx = (+ indx origdur)
             for r = (rhythm (nth idx 1) tem)
             for d = (rhythm r tem)
             for p = (/  tem origtem)
; faster tempo, the quieter
            for a = (+ .5 (- amp (/ tem 210.0)))
            until (> curtime totaldur)
            do
            (cs:i 3 t d a p pan dist pct indx)
            (set! curtime t)
            (wait r)
            )
      )
  ) 
;
; make-reverb-note
;   Turn instrument on for duration of score
;
(define (make-reverb-note dur)
  (process repeat 1 do
  (cs:i 99 0.0 dur 5))
)
; A verbose way to sprout this process at multiple tempos.
; The result is a Nancarrow-esque tempo canon
(sprout (list 
    (remix 100.0 10 1.0 30) 
    (remix 110.0 30 1.0 30) 
    (remix 120.0 60 1.0 30) 
    (remix 130.0 80 1.0 30) 
    (remix 140.0 10 1.0 30) 
    (remix 150.0 30 1.0 30) 
    (remix 160.0 60 1.0 30) 
    (remix 170.0 80 1.0 30) 
    (remix 180.0 10 1.0 30) 
    (remix 190.0 30 1.0 30) 
    (remix 200.0 60 1.0 30) 
    ) "remix.sco" :play #t :orchestra "sndwarp.orc" :header "f1 0 262144 1 \"jam.aif\" 0  0 0\nf2 0 16384 9 .5 1 0
\n")

; A cleaner, less verbose way to generate the same
(define mixes '())

(loop for i from 100.0 to 200.0 by 10.0
    do
    (set! mixes (append mixes (list (remix i 45 1.0 60))))
    )

(sprout mixes "remix.sco" :play #t :orchestra "sndwarp.orc" :header "f1 0 262144 1 \"jam.aif\" 0  0 0\nf2 0 16384 9 .5 1 0
    \n")

; a single instance of remix, with reverb note
(sprout (list (remix 100.0 10 1.0 30) (make-reverb-note 40)) "remix.sco" :play #t :orchestra "sndwarp.orc" :header "f1 0 262144 1 \"jam.aif\" 0  0 0\nf2 0 16384 9 .5 1 0
\n")

Common Music + Grace – Undead algorithms alive again

I’ve been getting reacquainted with Common Music and Grace for the past few weeks, looking at old pieces I create in CM 1.4 and porting them as I go to CM 3.9. I’ll be keeping some notes here which may morph into posts on a separate blog/forum/site dedicated to CM. For now, here are the relevant online resources I’ve been able to identify: Specific to Common Music: Main Common Music page Common Music Dictionary  The CM Dist Mailing List Taube’s Notes from the MetaLevel is best acquired through Amazon AFAIK Csound Journal article on CM/Grace For oldtimers like me, the pre-2002 cmdist archives can be useful Grace builds are archived here. I had a problem with the latest Mac build available through the App Store, but found a working package here. Scheme and other relevant resources: Schemers.org - hub of the online Scheme community. CM is an extension of Scheme, which in turn is a dialect of Lisp. One python programmer’s notes on learning scheme. He’s a good writer so it’s a fun read. Main S7 page - S7 is an extension of Scheme which CM leverages. Two free books! The Scheme Programming Language and Practical Common Lisp

Realtime Csound from Grace using OSC routing

Intro While working with Grace’s Csound rendering recently, things got a little bogged down as I tried to access the same score file from multiple processes. Here’s a post I made to the CM list a little while back, which sums up my problem: I'm stuck with a problem trying to sprout processes and work with Csound. I'm trying to do something more complex with a piece I'm working on, but managed to boil down the problem I'm having by using the Csound Scheme example. If you take a look at that example, you'll see a function called ransco:
    (define (ransco len rhy lb ub amp)
      (let ((dur (* rhy 2)))
        (process repeat len
                 for t = (elapsed #t) ; get true score time
                 for k = lb then (between lb ub)
                 do
                 (cs:i 1 t dur k amp)
                 (wait rhy))))
A bit further down in the example, there's some instruction on sprouting this bit multiple times, using :write #f to 'collect' the events generated into one score:
    ; This will generate a score without writing an audio file. execute
    ; the expression several times and use the Audio>Csound>Export... item
    ; to export all the score data in various formats

    (sprout (ransco 10 .2 60 72 1000) "test.sco" :write #f)
I was assuming I'd be able to do this same thing from a process, but I'm getting an error that Grace is unable to get a file handle to "test.sco". Here's the function:
    (define (f1)
      (process repeat 3
      do
      (sprout (ransco 10 .2 60 72 1000) "test.sco" :write #f)
      (wait 1)))
...and I try to execute it like so:
    (sprout (f1))
Instead of trying to bend CM to my will, I decided to use OSC to fire Csound events in realtime. This has been pretty successful so far, so I’m posting my ‘OSC Router’ Csound score and example Scheme file for others to use. Links: The .csd is here  Sample scheme file is here Scheme file My .scm file is pretty verbose for this illustration, but I figured more is more right? :) At line 2, I open up an osc listener:
(osc:open 7779 7825)
I’m not receiving anything incoming, but not the outbound port 7825 - you’ll see that again in the .csd file. The lion’s share of the file is 4 nearly-identical functions which generate separate lines, ultimately to be played by guitar quartet. Instead of the familiar call to cs:i, we use osc:message:
(osc:message "/router" 1 t dur amp pitch pan dist pct )
Essentially routing p-fields of a score event to outbound port 7825. At this point, we can just sprout a list of calls like I do at lines 128-134:
(sprout (list 
         (quartetlet-1 10 300 (make-heap '(gs4 b4 a4 fs4)))
         (quartetlet-2 30 300 (make-heap '(gs4 b4 a4 fs4)))
         (quartetlet-3 60 300 (make-heap '(e5 fs5)))
         (quartetlet-4 45 300 (make-heap '(fs3)))
         )
) 
…but I wanted to sprout them within a process, along rhythmic lines. Hence the function beginning at line 136:
(define (launch num)
  (let*  (
   (rhythms (make-cycle '(w w+h w+w w+w+w)))
)
  (process 
           for r = (rhythm (next rhythms) 72)
           for iternum from 0 to num
           do
           (set! iternum (+ iternum 1))
           (sprout (list 
            (quartetlet-1 10 5 (make-heap '(gs4 b4 a4 fs4)))
            (quartetlet-2 30 5 (make-heap '(gs4 b4 a4 fs4)))
            (quartetlet-3 60 5 (make-heap '(e5 fs5)))
            (quartetlet-4 45 5 (make-heap '(fs3)))
         )
                    )
           (wait r)
           )
  )
)
Launch like so:
(sprout (launch 50))
You’ll hear bursts of quartet material initiated according to the rhythm generated by
(rhythms (make-cycle '(w w+h w+w w+w+w)))
which generates a 5-second burst of quartet material for each rhythm generated. Here’s a sample (player at top) Osc Router  Let’s look at the csd, which routes incoming OSC data from Grace. At line 10, we open up an osc listener on line 10:
gihandle OSCinit 7825
Instr 1 uses the pluck ugen with the familiar parameters for duration, amplitude and pitch, along with parameters to locate the note in stereo space using locsig/locsend. Instr 99 provides reverb (actually not used here..).. Instr 1000 is the relevant instrument here:
instr   1000
kinst init 0
kstart init 0
kdur init 0
kamp init 0
kpitch init 0
kpan init 0
kdist init 0
kpct init 0
kwhen init 0

nxtmsg:
    kk  OSClisten gihandle, "/router", "ifffffff", kinst, kstart, kdur, kamp, kpitch, kpan, kdist, kpct
    if (kk == 0) goto exit
    schedkwhen kk, -1, -1, kinst, kwhen, kdur, kamp, kpitch, kpan, kdist, kpct
    kgoto nxtmsg
    exit:
endin  
I init k-rate variables to hold incoming p-fields, and fill them with incoming data via OSClisten. If I get an osc message (signalled with kk, the trigger from OSClisten), I use schedwhen to fire an event to the intended instrument. On my macbook, I run the csd with the following params:
csound -odac1 -+rtaudio=CoreAudio -Q0 -B512 -b64 osc_router.csd
Conclusion The Common Music family of releases has shaped my music making, and getting back up to speed with the latest from Rick Taube, Bill Schottstaedt + co. at CCRMA has been rewarding. These projects (Common Music 1, 2 and 3.x, Grace, CLM, Snd) have little in terms of PR out there, but deserve more airtime out there IMHO. I hope that this examples serves to steer others in productive directions. More soon! Once again, the links: The .csd is here  Sample scheme file is here

My Sound: January 2015

So I've been reading these books by Norwegian writer Karl Ove Knausgaard called My Struggle, where he fills out details of memories to make a sort of embellished autobiographical picture of his life. Not quite non-fiction, it takes a shape of it's own, pulling you into a part of his life and seeing yourself there. Episodes combine to form a very lucid portrait of the artist. I've been obsessively collecting sounds for as long as I've been able, but they're sitting in boxes and on hard drives, gathering dust. What's worse: I'm constantly adding to this pile and not making art of out it. So here we go: the first installment of my monthly sound journal. This first issue is all about soundtrack music I've written, with some drafts that stayed in the notebook along the way. My hope is that as I pool these sounds into cohesive packages, a broader narrative arises that will sound like me. Let's see if it works. My Sound: January 2015
  1. Moon
  2. Planets
From Circadia Sees the Moon (2005) In 2005, Dave Hanagan asked me to make some music for his short Circadia Sees the Moon. In this beautiful little film, a young woman is kept from seeing the moon and, it seems, her adulthood. I tried to give childlike quality to the surface but rhythmic chaos underneath. I had just been seduced by the first three records by The Books, and had some of this in mind while building these sounds with Csound and my guitar. The Books taught me to trim the attack off of the note, which was extremely liberating. I began to find all these new ideas in sounds I already had. The film features a repeated shot of the moon, which I supported with this stretched high slide guitar sound you hear here, and later on this disc.
  1. VCS3 Taste Sometime in 2004 I wrote a program to impersonate the EMS VCS3, a synth I’d heard on lots of recordings, including Dark Side of the Moon. The sound was sweet and thick, like pork fat. I loved the sound and spent a week or so hacking this instrument together that would eventually be the backbone for my synth weirdness band Wizard Prison. This is the 1st improv I recorded with my new toy I made. The pulses transfixed us. At the end you hear what we in WP called the ‘Party’s Over’ sound, which Scott and I would use to signal it was ready to move on to the next idea.

  2. Highway 99

  3. Park Music
  4. Lego Music
  5. Proto Stay Love
  6. These are Circles
  7. Bizzy Bizzy

Inspired by Raymond Scott, from Urban Scarecrow (2002-2006) I had heard Raymond Scott’s music in cartoons growing up, but hadn’t heard his groundbreaking electronic music work until the Manhattan Research Inc compilation Basta released in the early 2000s. Like some classic mad scientist, Scott built oscillators and mechanic sequencers from scratch, designing everything along the way. I pictured RS’s circular sequencers rotating to create loops of sound and wrote these pieces, under the influence of Soothing Sounds for Baby and the occasional scotch. Most of these were created for my brother’s beautiful film Urban Scarecrow. The first three made it in (I think) but the final three I used for other things…

  1. Ascending
  2. Backwards
  3. Broken Waltz
  4. Cherry Blossoms
From The Emergency Pants Collection (2004) Using the computer and my programming skills for so much music made part of me rebel and crave organics. I set a challenge for myself: create pieces solely with my 4 track, the crappiest guitar pedal I had, and my piano. Brandon Schaeffer liked them and used them in his impossible-to-find Emergency Pants collection of films - maybe he will let me post them on Vimeo? The ring modulator you hear on Broken Waltz is the only reason I keep that pedal around.
  1. Short Waves (2008)
I am addicted to collecting sounds, and for long binges during the winter I will sit in our shed, long into the night, trawling the air for new sound on my shortwave set. I made this out of three recordings. First, the pulsing time signal you can pick up anywhere in the world on 5000Hz, 10000Hz, 15000Hz, you get the idea. Second, a brief digital signal coming from a buoy in our Puget Sound. Third, a distant voice speaking Arabic.
  1. Anxious (1998)
One of the first pieces of sound art I was actually proud of. I made this while in the composition program at the University of Washington, studying with Richard Karpen. My head was full, one part Squarepusher, one part Iannis Xenakis. I’m not sure this has much to do with either. One loop is used throughout - you can hear it, unedited, in the first full bar of 4 in the piece. Xenakis created Concrete PH from a single recording of charcoal burning. With him in mind, I wanted to create as much as I could from this single loop. You’ll hear glitchy tweaker beats, a Nancarrow-style tempo canon, and Noh Theater-inspired spatial minimalism.
  1. End Credits
From Circadia, a reverse overture that crams all of the elements from the soundtrack into a final pulsing climax. The visuals involve crosscuts of a train crashing through a wall and the moon breaking through the clouds, which I try to reflect.

Roundware

I've been an active developer on the open source project Roundware for the past few months, and it's been very exciting. I've gotten the opportunity to pitch in a project used in Sound Artist Halsey Burgund's last few installations, as well as develop a location-based media platform geared towards ART instead of broadcast. From the page: "Roundware is a flexible, open-source interactive audio platform which can be used to create unique participatory audio experiences. Initially developed for sound art installations, Roundware has been used for museum audio tours as well as other educational purposes. Roundware creates a seamless location-sensitive layer of audio comprised of musical elements and participant commentary in any geographic space. Roundware organizes an ever-growing collection of audio information such that it can be accessed in both educational and artistic ways. Roundware serves individualized audio streams to users in a flexible non-linear way based on participant inputs. So you see, Roundware is the foundation that ANYONE can build an audio installation with. Halsey's video for his piece Scapes illustrates the idea well: Scapes Intro from Halsey Burgund on Vimeo. The exciting news of late is that we're being leveraged by the Smithsonian Institute for their recent Stories from Main Street as well! If you have an iPhone, download it and submit a story - it may end up on the Smithsonian's web page!

Shortwave: Hidden Spaces

In 2007 I created a piece with Iole Alessandrini called Hidden Spaces. From the press release:
Hidden Spaces is an interactive light and sound installation. Lasers create planes that form flat spatial fields. Through the use of video tracking and computerized sound, the planes are 'audio-visualized': people explore, with their own movements, the spaces hidden within the planes of light by triggering sounds heard as they intersect these planes. While I'll post more on the software down the road, this post is dedicated to the sound sources used in Hidden Spaces. I have spent many a winter's night in our backyard shed, armed with a glass of scotch, trawling the Shortwave spectrum for sounds to use in pieces. A very meditative way to spend the evening. Here are some fruits from that labor. If you want an idea of what the opening sounded like, picture 100 or so people crammed into at 20"x20" dark room lit only by laser light, and hit play on all of these. Long story short - the piece worked best when experienced alone. Warning - these are noisy and a little loud..
Audio MP3
Audio MP3
Audio MP3
Audio MP3
Audio MP3
Audio MP3
Audio MP3
Audio MP3
Audio MP3

The VCS3

I began writing pieces in a language called Csound when I was at UW in the mid 90s. Working on SGIs, we wrote programs in LISP to generate these huge lists of notes; lists to be interpreted by instruments written in Csound. This conveyer belt way of making music felt weird and wack at first, since my main mode of taking down ideas involved my 4 track, guitar, voice, cheap synth and tape manipulation. When I left UW things got more interesting: processors got cheaper and Csound evolved into a realtime sound processing tool. Many folks have contributed to a floating life raft of a code archive of Csound instruments; one night's trawl through the archive led me to Steven Cook's VCS3 instrument. It was designed to be fed the note lists, but look at the original! Covered in buttons, knobs and plugs, I had to lay a UI on top of this. Gabriel Moldonodo's CsoundAV was the first incarnation of Csound to make this possible - I could (reiterate ui on top of Csound orc). He added the FLTK toolkit to Csound, but I could never customize it past the default gray look. So it doesn't look as good as it should (yet) but sounds awesome, and that's what's important. Gabriel himself added a screen to save presets, I added MIDI in.
My band Wizard Prison relied heavily on it when we opened for Animal Collective on their Strawberry Jam tour, and on each of our 3 records. Some audio featuring my VCS3: 1st test:
Audio MP3
From Wizard Prison's second album, ][:
Audio MP3
Also feature on this little film: Soul Gold from listen faster on Vimeo.

Code

You'll find the csd file here. Csound can be found here. I get requests for this instrument here and there, and it can be painful to set up, so I'm working on an independent cross platform installer . Hit me with an email if you want to be part of the beta test group.