There are two ways to run AppleScripts from within SuperCollider. One is to construct a string with osascript -e and a unixCmd, the other is creating a cocoa NSAppleScript object with the SCNSObject cocoa binding class. The later method is slightly more involved but runs way faster.
"osascript -e 'tell application \"Finder\" to activate'".unixCmd;
"osascript -e 'tell application \"TextEdit\" to activate'".unixCmd;
//--NSObject version - this only work on old OSX SuperCollider versions
a= SCNSObject("NSAppleScript", "initWithSource:", ["tell application \"Finder\" to activate"]);
a.invoke("executeAndReturnError:", [nil], true);
SCNSObject.dumpPool; //should be 0
SCNSObject.freePool; //free stray objects if any left
Also, I've attached a simple class that wraps the functionality. It's called RedEarth.
If e has three or more neighbours that are plants, then e will become a plant at the next time step (assuming it isn't trampled by a herbivore or carnivore).
For every herbivore, h (in random order):
Decrease energy reserves of h by a fixed amount.
If h has no more energy, then h dies and becomes an empty space.
Else, if there is a plant next to h, then h moves on top of the plant, eats it, and gains the plant's energy.
If h has sufficient energy reserves, then it will spawn a baby herbivore on the space that it just exited.
Else, h will move into a randomly selected empty space, if one exists, that is next to h's current location.
For every carnivore, c (in random order):
Decrease energy reserves of c by a fixed amount.
If c has no more energy, then c dies and becomes an empty space.
Else, if there is a herbivore next to c, then c moves on top of the herbivore, eats it, and gains the herbivore's energy.
If c has sufficient energy reserves, then it will spawn a baby carnivore on the space that it just exited.
Else, c will move into a randomly selected empty space that is next to c's current location. If there are no empty spaces, then c will move through plants.
The rules are fairly simple but the result is complex. Carnivores feed on herbivores that in turn feed on plants. Populations grow, get overpopulated and die out just like in nature. The SuperCollider code is a bit cryptic using a lot of nested arrays for efficiency reasons but near the top, there are user settings to play with.
This is something I originally wrote for the article Audiovisuals with SC and now rewrote as separate classes. There are four classes all implementing the same system slightly differently. Two for graphics (Whitney, Whitney2) and the other two for patterns (Pwhitney, Pwhitney2).
The principle for this system is described by John Whitney in his book Digital Harmony (1980) and reimplemented musically by Jim Bumgardner in his Whitney Music Box (2006). The idea is simple but complex patterns arise - both in graphics and in harmony/rhythm. The innermost ball moves at a certain speed, the ball next to it doubles that speed and the ball next to that triples the speed etc. There's a sound played for each ball as it passes through 0. Each ball's sound plays at a different frequency mapped to some scale, overtone series or something else.
Another very old SuperCollider class I never got around to publish. It's called Pfork and makes it possible to blend or fade out patterns in other ways than plain [volume] crossfading. It was originally written for the installation Intelligent Street (in SC2) where it was used as a way of creating new music styles from a mix of multiple other styles.
Here's one example of slowly zeroing out amplitudes in a 16 step pattern. frac is a value slowly changing from 1.0 to 0.0 and indicates how many values to zero out. The fork pattern is [3, 1, 2, 0]. This pattern decides which indices to zero out and in which order. So here index 3 is first in the fork pattern and will thereby be seen as the least important in the original pattern. All indices 3 will be zeroed out first. After that all indices 1 and so on. The last indices zeroed out (i.e. kept until frac is almost 0.0) are the indices 0 - ie the first beat out of 4 in the original amplitude step pattern.
This ASCII printout should help visualise what is happening...
My latest controller. I'll premiere it this Friday (23 July 2010) at the bring-your-own-laptop event at staalplaat. It includes a light sensor, 2 touch sensors, some big switches and lots of knobs for control. It is also wireless and runs off either a 9V battery or a 9-14V wall adapter. The controller data is picked up by redWirelessMaster and is then read by the computer via a serial port.
Firmware, parts list and schematics attached below. A SuperCollider class for interpreting the data is also included.
Flickr photostream from the build process. I took out most of these beautiful old electronics and replaced it with my own circuit board. Only kept the front end interface with the nice knobs.
101109: minor updates
130122: SuperCollider GUI class updated and new help files and MIDI control (via a nanoKontroll).