How to write a SC plugin / Biquad filter!!!

The tutorials in the SC distro are not really great on how to do plugins, so here’s my version. After you get the SC source code (an exercize left to the reader), you’re going to want to build your own copy of SC. This should not be the same copy that you use for doing your music, because development tends to break things and you don’t want to break your instrument. First build the Server, then the Plugins, then the Lang.
Once you’ve done that, open the plugin project with Xcode. In the Project Window, pick a target and ctrl-click on it to duplicate it. Then option click the new target to rename it to [whatever]. Double click on it to bring up the target inspector. In the summary, rename Base Product Name to [whatever].scx .  Then click on “Settings” in the list on the left. Change Product Name to [whatever].scx .  Close the target inspector menu and go back to the project menu. Drag your new target into the list for All, so it gets built when you build all.

Ctrl-click on your new target again to Add. Add a new C++ file. Don’t generate a header file for it. This is my example, a biquad filter:

/*
 *  LesUGens.cpp
 *  xSC3plugins
 *
 *  Created by Celeste Hutchins on 16/10/06.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// all plugins should include SC_Plugin.h
#include "SC_PlugIn.h"

// and this line
static InterfaceTable *ft;

// here you define the data that your plugin will need to keep around
// biquads have two delayed samples, so that's what we save

struct Biquad : public Unit
{

    // delayed samples
    float m_sa1;
    float m_sa2;
};


// declare the functions that your UGen will need
extern "C"
{
 // this line is required
 void load(InterfaceTable *inTable);

 // calculate the next batch of samples
 void Biquad_next(Biquad *unit, int numsamples);
 // constructor
 void Biquad_Ctor(Biquad* unit);
 
}

//////////////////////////////////////////////////////////////////////////////////////////////////


// Calculation function for the UGen.  This gets called once per x samples (usually 66)

void Biquad_next(Biquad *unit, int numsamples) 
{

 // pointers to in and out
 float *out = ZOUT(0);
 float *in = ZIN(0);
    
 // load delayed samples from our struct
 float delay1 = unit->m_sa1;
 float delay2 = unit->m_sa2;

 // the filter co-efficients are passed in.  These might change at the control rate,
 // so we re-read them every time.
 // the optimizer will stick these in registers
 float amp0 = ZIN0(1);
 float amp1 = ZIN0(2);
 float amp2 = ZIN0(3);
 float amp3 = ZIN0(4);
 float amp4 = ZIN0(5);
 
 
 float next_delay;
 
 // This loop actually does the calculation
 LOOP(numsamples,

  // read in the next sample
     float samp = ZXP(in);

  // calculate
     next_delay = (amp0 * samp) + (amp1 * delay1) + (amp2 * delay2);

  //write out result
     ZXP(out) = next_delay - (amp3 *delay1) - (amp4 * delay2);

  // keep track of data
     delay2 = delay1;
     delay1 = next_delay;
     
 );
 
 // write data back into the struct for the next time
 unit->m_sa1 = delay1;
 unit->m_sa2 = delay2;
 
}


// The constructor function
// This only runs once
// It initializes the struct
// Sets the calculation function
// And, for reasons I don't understand, calculates one sample of output

void Biquad_Ctor(Biquad *unit)
{

 // set the calculation function
    SETCALC(Biquad_next);
    
 // initialize data
    unit->m_sa1 = 0.f;
    unit->m_sa2 = 0.f;

 // 1 sample of output
    Biquad_next(unit, 1);

}

// This function gets called when the plugin is loaded
void load(InterfaceTable *inTable)
{

 // don't forget this line
    ft = inTable;

 // Nor this line
    DefineSimpleUnit(Biquad);
}

Ok, when you build this, it will get copied into the plugin directory. But that’s not enough. The SCLang also needs to know about your new UGen. Create a new class file called [whatever].sc .&nbsp You can stick this in your ~/Library, it won’t mess up your other copies of SuperCollider. This is my file:

Biquad : UGen {

 *ar { arg in, a0 = 1, a1 = 0, a2 =0, a3 =0, a4 =0, mul = 1.0, add = 0.0;
  ^this.multiNew('audio', in, a0, a1, a2, a3, a4).madd(mul, add)
 }
 
 *kr { arg in, a0 = 1, a1 = 0, a2 =0, a3 =0, a4 =0, mul = 1.0, add = 0.0;
  ^this.multiNew('control', in, a0, a1, a2, a3, a4).madd(mul, add)
 }
 
}

The multiNew part handles multiple channel expansion for you. The .madd ads the convenience variables mul and add. Your users like to have those.
I don’t know if a biquad filter comes with SC or not. I couldn’t find one. They’re useful for Karplus-Strong and a few other things. For more information, check out the wikipedia article on Filter Design
Tags: ,

HID, SuperCollider and whatnot

My HID classes are now in version 1.0 and I’m not going to change them again without good reason. The change is that the call back action passes the changed element back as the first parameter, followed by all the other parameters. It’s redundant, but it matches how the subclasses work. This should be usable for HID applications. a helpfile will be forthcoming.
I am trying to write a Biquad filter UGen and also to compile a FFTW UGen that my friend wrote. Jam fails when I try to compile, on both files. I think there is a step missing in the howto document on Ugen writing. My code is simple and the syntax looks ok. I’ve done every step (as far as I know) in the howto. bah. I could use a better error message than “jam failed.” sheesh. I like XCode, but it’s got nothing on the Boreland compilers I used to use back in the 90’s as far as usability and usefulness of error messages.
Workaround: Take an existing target and duplicate it and use that for your target. Rename it and replace the files in it with your own. Ctrl-click on the target to bring up a menu with the option to duplicate.
Tags: ,

Chez mois est chez vous

I would like to start by noting that I can’t connect to blogger for some reason from my school network lately, so I’m posting this via lynx in a shell account I have in the US.
Just wanted to post a note to folks I know in Real Life (TM). If you want to come visit me, my futon is your futon. I don’t live in Holland’s most exciting town, but I’m a short and cheap train ride away from some more exciting towns, like Amsterdam. Also, near to Belgium, a bit farther to Cologne. (the most exciting thing about going to Cologne, IMHO, is not Europe’s largest cathedral, but rather that the train passes through Gouda!! Home of cheese! (sort of))
Last year, about one person a month came through. It was nice to have people around. I got caught up in ‘merican stuff and went and did touristy things with them. Touristy things are fun, but I tend not to do them unless I have some sort of reason. However, yesterday I went to a couple museums in The Hague. They were a bit small, but not bad. I purchased a museum card which will gain me free entry into nearly every museum in the Netherlands. Huzzah.
Also, recently, I went to Cologne for the Computing Music festival. (Did I blog this already?) Twas fun. They had instrument-playing robots. The robots have a call for scores, so I will have to make a journey to Gent, Belgium to try out some robot stuff. I need to download some robot manuals to figure out what to do.
I’ve 60% decided that I should enlist Cola to retrieve Xena when she sees her parents. Xena would then fly direct from L.A. to Amsterdam. I need to confer with a vet to see what risks this entails for my poor dog. Also need to confer with the landlord.
If I sell my house in Berkeley, what will I do with all my stuff? I don’t think I should ship my grandmother’s piano to Europe . . .. I wish I could find a job as a composer that would pay to relocate me.
In other news: Nicole is going nuts from boredom and some mother fucking spammer keeps listing me as a return address, which means my inbox fills up with hundreds of bounce messages every day, which aren’t spam-filtered out because they’re not spam. augh. kill.
Tags: ,

Dear Americans

I feel it would be remiss if I did not post an encouragement for you to go vote. I sent in my absentee ballot already. I understand if you feel a tad discouraged about many things. However, vote for the local stuff at least.

I went to Cologne last weekend for a music festival that involved instrument-playing robots. Normally the mad scientist behind it dances naked with them, but he did not do so this time. Male nudity in high art type situations is, perhaps, under explored. They have a call for scores. I may go to Belgium to see what I can do with robots. However, I don’t think I will do any naked dancing. This sort of reminds me of a post I made a while ago about creatively placed and decorated joysticks. Maybe I could do some sort of virtual nudity/wanking. I worry that the implicit criticism inherent within such an act would adversely effect my reputation, especially since naked-robot-guy is on the admission committee of the Doc Artes program.
If anybody wants to suggest a project ro research thing that I could do for the next few years, I need ideas. I am not well suited to these applications. I want to know something, I just go do research on it. I don’t need a university for that, just a university library. Or the internet.
Things I’m potentially interested in: Spectral processes and improving the Phase Vocoder UGens in SuperCollider. I also have interest in using music or instillations to communicate political ideas without representations like pictures or words, but rather somehow inherent in the sounds or interactions. Can an installation model a political system in a way that the user ‘gets,’ at least subconsciously? And I like bells. And granular synthesis. And want to (eventually) write an opera.
Tag:

Applying myself

It’s that time of year again, when a young person’s heart turns towards PhD applications. I’m alo thinking about starting an M.A. collection and getting one from here. The program director was encouraging. I will talk to him about it on Monday. I’m also thinking about applying to some PhDs, but I dunno where I want to go. I’m leaning towards continental Europe, but most countries here are civilized enough to have not joined the composers-must-have a PhD craze.

What I need to know to teach is the stuff I can get here. What I need for a piece of paper in order to have any chance of surviving in academia is also possibly available through here (sort of). I speak of the Doc Artes program. The downsides are that it is rumored to be poorly organized and I must learn Dutch (which I’m going to start doing anyway . . . any day now). Upsides are that I could study with people here and learn what I need to learn and get the piece of paper I need if I want to return to the US ever. But they only take 5 people from all disciplines and they already have a few composers, so maybe it’s impossible. Therefore, plan B, C, D, etc are required.
There’s Birmingham and some other schools in the UK. Birmingham, especially is supposed to be becoming the center of the SuperCollider universe, which would be nice. I’m not so sure about the English speaking world, though, alas.
I can probably apply to Berkeley again. I heard two rumors recently: one was that they actually did admit a CNMAT-type person who also knew things like how to do 12 tone row blahdyblah (ack, kill me) and would never admit anyone with my reduced more specialized skill set. The other is that they don’t think you’re serious unless you apply to multiple schools.
DocArtes seems like the best bet, but the chances of me getting in are very small.
Anybody got any thoughts about where to apply? SuperCollider focus is good. Technical Sonology-type engineering focus is good. funded is good. In Europe is good. Some combination of all of these things plus a job and social circle for my gf would be perfect. I’m going to start the University of Les and it will have a campus in either Paris, Amsterdam and/or Prague. Courses will be in French and English. PhDs will be issued based on how well you can improvise. Course work will feature classes on how to get gigs in various locations and how to get grant money.
Tags: , , ,

Tutorials

The world has been crying out for my old SuperCollider tutorial. Well, not crying out, exactly. Some of you may recall that I had the idea of a doing a tutorial as a thesis project. My advisor said it was disorganized and error-riddled, and so the project was abandoned. However, some stranger on the internet convinced me to send it to him.
This stranger was my host for my first two weeks here (the house with no hot water). His name is Jeremiah and he’s cool. Anyway, he told me that he liked the tutorial and I should put it on the internet. So here you go. It’s incomplete and disorganized. The errors aren’t serious. (Lines of code are separated by semicolons, not terminated: that means that the last line in any block doesn’t need a semi colon, but can have one anyway if you want. Blocks are not defined by parenthesis, but rather by curly brackets or by highlighting code with the mouse. These are the two most glaring errors. All the examples should work.)

Edit

Tutorials have moved to http://www.berkeleynoise.com/celesteh/podcast/?page_id=65 . Please update your links.

Bike Woes

The pump was stolen from my bike. It had this shiny black pump that was attached to one of the bars. I had taken the pump off after hearing that it would likely be stolen. Then I decided that it was not doing me any good hidden away and it might as well be put at risk because hidden or stolen, I still don’t have it on my bike. However, this logic failed to account for me being bummed at having lost a pretty good pump. Theft sucks. I wonder if there’s a way I could attach a new one and make it theft proof? I wonder how much the damn pump would cost to replace.
Tags: ,

My 60 second Piece at Mills College Nov 2

60×60 – 60 new works, 60 seconds in length for one hour of new music.

Each year the project grows in artistic and distributive scope. Achieving
its initiative, the 60×60 promotes contemporary composition across the
globe. This year we are having our 3rd annual Pacific Rim Mix. Our premier
will be at Mills College in their Ensemble Room at 8:00 PM this Thursday
November 2nd.

60×60 is a project containing 60 compositions from 60 different composers,
each composition 60 seconds or less in duration. These 60 recorded pieces
are performed in succession without pause for a 1 hour concert. The mission
of the 60×60 project and its presenter, Vox Novus, is to expose the greatest
number of composers and their works to the largest audience possible. 60×60
combines grassroots ideology with cutting-edge methods of presentation and
distribution. Each year the project grows in artistic and distributive
scope. Achieving its initiative, the 60×60 promotes contemporary composition
across the globe.

“60×60 showcases a wealth of brief, contemporary compositions. There are no
live performances, so you can’t really call it a concert. Maybe it would
better be described as a listening party. … It’s like a Whitman’s sampler
of the contemporary new music scene. “
– Sound Sampler Greg Haymes, Times Union, Albany New York February 9, 2006

“60×60 features 60 back-to-back pieces that are each under 60 seconds long,
each by a different modern composer. … It’s like channel surfing through
experimental music.”
Geeta Dayal, Village Voice, New York, New York March 16-22, 2005 Vol. L NO.
11

“… The idea of commissioning sixty pieces each a minute long has elements
of both ingenuity combined with madness: … A minute can be ample time to
express a whole gamut of imaginative sounds, or it can be a constraint which
forces an artist to isolate what is the most important element of a work.
The point of the project is that it enables an audience to take in and enjoy
a cross section of different approaches to new music within a reasonable
duration. And the purpose of Robert Voisey is to promote new music …”
– Ingenuity and madness? Malcolm Miller, Music & Vision, London UK December
24, 2005

60 Composer in this year’s Pacific Rim Mix include:
Nicholas Baldwin, Marc Barreca, Lembit Beecher, John Biggs, Betty Breath,
Darren Buhr, Brigid Burke, Rosalinda Carlson, Sharon Cheslow, Lut Yun
(Lucinda) Chiu, Foster Clark, Jared Commerer, Cindy Cox, Michael Dawson,
A.L. Dentel, Aaron Drake, Alex Eddington, Jessica Gardiner, Kara Gibbs,
David Hahn, Yuko Hamura, Jason Heald, Sungji Hong, Jeffrey Hunkin, Celeste
Hutchins, David Evan Jones, Yasushi Kamata, Koji Kawai, Donald Kepple, Anton
Killin, Nicole Kim, Tuan Hung Le, Cheryl Leonard, James Mason, Beryl Matete,
Deeann Mathews, Dylan Mattingly, Polly Moller, Julia Norton, Rodney Oakes,
Robert Parker, Maggi Payne, Peggy Polias, Carlos Rafael Rivera, Stephen C
Ruppenthal, Simon Munro Rycroft, Margaret Schedel, Jacky Schreiber, Alex
Shapiro, Frank Sprague, Phillip Stearns, Sarah Taylor, Kubilay Uner, John
Villec, Robert Voisey, Shane Watters, Katrina Wreede, Hajime Yabe, Carolyn
Yarnell, and Ivan Zavada

The concert program can be found at the following link:
http://www.voxnovus.com/60×60/2006_Pacific_Rim_Concert_Program.htm

Tag:

I used to have a dog

I miss my dog. A lot. I want to get her in December and bring her here, but that requires some logistical work. For starters, if I bring the dog, that’s a commitment on my part to stay (at least) another year. How will I do that? Can I get a residency someplace? Should I do the MA program at the conservatory? Would they let me in?
Does The Netherlands quarantine pets? If so, can I just take her via France? (France does not quarantine.) Would it be easier on her to rent a car, drive to NYC and fly from there rather than flying from Los Angeles or San Francisco? (If I drive to the East Coast, can I get some gigs on the way?) How much would such a car trip cost?
Can I give her drugs that will make the flight less terrifying? What are the chances the drugs would harm her? What are the chances the trip would harm her? How loud is it in the cargo hold? How often do they forget to heat it? How often do dogs die in transit? Is there a way I can mess with her walking schedule (for example) to make the trip less traumatic? How many hours will she have to spend in a little box?
Will The Netherlands require her health certificate to be diplomatically certified? Can I use the same one that I will use to get her on the plane? (France needs a specific form which must be translated, and the airline needs to have one that’s 3 days old or less, so if I take her via NYC to France I need to first get a certificate from a west coast vet, get that translated, then go to NYC and get another certificate to fly.)
Do dogs need visas?
I didn’t take her last time because I thought the trip would be too traumatic and anyway, I was only going to be gone for a year. Having a dog in a big city can be something of a hassle. She needs to run and there’s not a good place in Paris (except the park where the Eifel Tower is has a lot of running dogs in the evening). On the other hand, there’s places here and I can take her just about everywhere with me: cafés, bookstores, etc, although maybe not to class. Maybe I can get a biiiiiig basket for the front of my bike and take her around with me on the bike, even though she’s a bit too large for the tram.
I think of her alone and terrified in the dark, loud cargo hold of the plane and it makes me sad. So I think about getting another dog here, maybe a small one that would fit in a duffel bag that I really could bring everywhere (even to class if s/he could stay quiet in a bag). A dog small enough to carry on a plane if I need to fly home at the end of the year. But I have a dog! (sorta) The best dog! I just don’t want her to get hurt or too scared. And I don’t want to go to all that trouble of cross country driving plus vet certificates, shipping case and blah blah blah just to have her here until June and then go back to the US.
I wish I could just buy a seat for her.Tags: ,