Debugging a SAOL Orchestra

From: Michael J McGonagle (fndsnd@earthlink.net)
Date: Thu Feb 24 2000 - 19:33:14 EST


Hello all,

I am currently trying to figure out how to dispatch an instr call from
within another instr. I have no trouble doing this, but in trying to
figure this out, I stumbled on another trouble. The SAOL orchestra is
made up of a simple "grain" instrument that is called from other complex
instr's. My first complex instr creates random grains by looping thru
the entire duration of the event, and generating sine_grain events based
on random data. I have included the code below, as it is more
explainitory.

My difficulty here is three-fold.
    1. The first is in determining exactly what data is being passed to
the "random" grains. It would appear that SAOL makes no provisions for
showing data in any way, I would think that a printf-like opcode would
be fairly simple to implement. It would also be useful to, on compiling,
tell sfront (or whatever program) to ignore these calls (not compiling
the opcodes into the output).

    2. Also, how many times will the "while" loop be executed? I am
trying to get it to execute on the first pass only of the call to the
instr. Is the while loop getting executed on every k-cycle for the
duration of a sine_grainer1 event? Is there a means of implementing this
using i-rate variables or do I need to use an init flag? (if (flag == 0)
{ flag = 1; do_init_things_here(); })

    3. After reading a few passages in the spec, it would appear that
calls to any opcode only change at the start of a cycle (ie a k-rate
opcode will only be called once per k-cycle, subsequent calls in the
same k-cycle will return the same values). If this is the case is there
a simple way to get random values en masse? Do I need to fill a table
with random values, and read them using tableread() while incrementing
an index?

global {
    srate 44100;
    krate 4410;

    outchannels 2;

    table sine(harm, 8192, 1);
}

// freq in hz
// amp in db
// pan (0..1)
instr sine_grain(freq, amp, pan) {
    ksig amplitude, grainshape;
    asig gen;
    imports table sine;

    // k-rate
    grainshape = kline(0, .25 * dur, 1, .5 * dur, 1, .25 * dur, 0) *
ampdb(amp);

    // a-rate
    gen = oscil(sine, freq) * grainshape;

    output(gen * pan, gen * (1 - pan));
}

instr sine_grainer1(density) {
    ksig count, mytime, freq, amp, pan, duration;

    while(count < density) {
        mytime = 0;
        while(mytime < dur) {
            freq = (krand(1) * 825) + 55;
            amp = (krand(1) * 50) + 40;
            pan = krand(1);
            duration = krand(1);

            instr sine_grain(mytime, duration, freq, amp, pan);
            mytime = mytime + krand(1);
        }
        count = count + 1;
    }
}

Thanks for your help.

Mike



This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 12:03:52 EST