week4



RTcmix beta documentation

In this class, we moved from dealing with coding 'inside' an RTcmix instrument to working with ways of running RTcmix from 'outside', or within another program. Just for fun, we hacked up several simple cellular automata programs. cellauto.c prints out a series of "0"s and "1"s following a very crude automata rule. cellauto1.c uses the same code as cellauto.c, but writes an RTcmix scorefile that maps the "0"s and "1"s onto differing notes for the STRUM plucked-string instrument.

Finally, cellautoG.c does an X11-windows graphics realization of the simple automata and schedule RTcmix notes -- in real-time...wheee! -- and makes a real purty picture.




An older course web page that describes the evolution of these programs in more detail is here, but be aware that the cellautoG.c program discussed on that page uses an older RTcmix-communications system (a "socket" connection). We used the newer ("imbedded") RTcmix object, with calling code that looked like this (the following is from a very basic RTcmix 'imbed' demo):
#define MAIN
#include 
#include 

#include 
#include "RTcmix.h"

int
main(int argc, char *argv[])
{
        RTcmix *rrr;

        rrr = new RTcmix();
        rrr->printOn();
        sleep(1); // give the thread time to initialized

        rrr->cmd("load", 1, "METAFLUTE");
        rrr->cmd("makegen", 7, 1.0, 24.0, 1000.0, 0.0, 1.0, 1.0, 1.0);
        rrr->cmd("makegen", 11, 2.0, 24.0, 1000.0,
                0.0, 0.0, 0.05, 1.0, 0.95, 1.0, 1.0, 0.0);

        rrr->cmd("SFLUTE", 7, 0.0, 1.0, 0.1, 106.0, 25.0, 5000.0, 0.5);
        rrr->cmd("SFLUTE", 7, 1.0, 1.0, 0.1, 95.0, 21.0, 5000.0, 0.5);
        rrr->cmd("SFLUTE", 7, 2.0, 1.0, 0.1, 89.0, 19.0, 5000.0, 0.5);
        rrr->cmd("SFLUTE", 7, 3.0, 1.0, 0.1, 75.0, 19.0, 5000.0, 0.5);
        rrr->cmd("SFLUTE", 7, 4.0, 1.0, 0.1, 70.0, 15.0, 5000.0, 0.5);
        rrr->cmd("SFLUTE", 7, 5.0, 1.0, 0.1, 67.0, 16.0, 5000.0, 0.5);
        rrr->cmd("SFLUTE", 7, 6.0, 1.0, 0.1, 56.0, 17.0, 5000.0, 0.5);
        rrr->cmd("SFLUTE", 7, 7.0, 1.0, 0.1, 53.0, 25.0, 5000.0, 0.5);

        sleep(8);
}
Obviously, the notes don't have to be schedule "by hand", you can use all the power and niftiness of C++ to do fun things like:
        int i;
        float start;
        float l1,l2;
        start = 0.0;
        for (i = 0; i < 100; i++)
        {
                l1 = rrr->cmd("random") * 25.0+5.0;
                l2 = rrr->cmd("random") * 25.0+5.0;
                rrr->cmd("SFLUTE", 7, start, 0.5, 0.1, l1, l2, 5000.0, 0.5);
                start += 0.2;
        }


If you really enjoy this CA stuff, you might want to fool around with some of the programs in this package:




I modified the Makefile so that they can be compiled on Mac OS X (again using Apple's X11 server app) -- the original programs came from here and use CA-like progams to model physical systems (a bunch of good links on that page, also).