SuperCollider CLASSES (extension)

ProcEvents

A real-time control structure
Inherits from: Object

Description

A structure for controlling modular processes.

Class Methods

*buildFromFile (procdict, tolerance ... paths)

Arguments:

procdict
tolerance
 ... paths

*initClass

*new (events, amp, initmod, killmod, id, server, lag: 0.1)

Arguments:

events

An array of events (ProcMods or a function) to play / release in the following format: [ProcMod, ProcMod.id to release]. Both the events to play and release may also be arrays, or nil. If the event is a function, realize that it is best to be a single shot type of thing, you won't be able to access it later (to stop a loop, for instance). So, make sure it is something that you set to run or execute, then can forget about completely.

amp

An amplitude scaler for everything running in the ProcEvents instance.

initmod

A ProcMod to be evaluated when the first event is called, regardless of event number. Useful for allocating buffers or persistant synths.

killmod

A ProcMod to be evaluated when this instance of ProcEvents is killed. Useful for freeing buffers and killing persistant synths.

id

A \symbol or "string" to identify this instance of ProcEvents server - an instance of Server to run this ProcMod on. Useful for remote servers. Defaults to Server.default.

server
lag

Inherited class methods

Instance Methods

-reset

Releases all running ProcMods and resets the system to evaluate initmod again.

-pracwindow

-pedalin

-eventDict

-releaseAll (rel: true)

Releases all running ProcMods EXCEPT the initmod.

Arguments:

rel

-now (id)

Returns the current time in reference to the starttime of 'id'. 'id' should be a \symbol or "string". If 'id' is nil, the reference will be the ProcEvents starttime itself.

Arguments:

id

-recordTimeLine

-pracGUI

Creates a GUI with basic ProcMod controls and a perfGUI for rehearsal purposes.

-timeArray

-stamp (idx: 0)

Arguments:

idx

-eventArray

-preKill

-preKill = value

-next

Will play and release the next event is the events array. Starts at 0. If initmod has not been executed, it will be.

-scope

-timeLine

-timeLine = timeLineArray

Arguments:

timeLineArray

-clock

-clock =

-procampsynth

-pedal

-timeStamp

-timeStamp = value

-stopRecord

-index

-index = nextIdx

Arguments:

nextIdx

-bigNum

-currentTime

-saveTimeLine (path)

Arguments:

path

-server

-triglevel

-id

-buttonWidth

-playTimeLine (wait)

Arguments:

wait

-amp

-amp_ (newamp, newlag: 0.1)

Arguments:

newamp
newlag

-recordPM

-isPlaying

-stopRecordTimeLine

-initProcEvents (events, argamp, arginitmod, argkillmod, argid, argserver, arglag)

Arguments:

events
argamp
arginitmod
argkillmod
argid
argserver
arglag

-pedalnode

-timeOffset

-timeOffset = value

-releaseButton

-pedalTrig (pedalbus, trigwindow: 0.5, testdur: 2, guiBounds, addAction: 1, target: 0)

listens to pedalbus for Amplitude triggers. This is fairly specialized. I use a quater inch keyboard sustain pedal (a ground switch). When pedalTrig is invoked, an OSCresponderNode is started that listens for a noise floor for testdur seconds. An average reading is taken and is stored as a basevalue. When the pedal is pressed, a spike in amplitude is created. If the spike is within basevalue * headroom, the next event is called. Some tuning should be done to find a headroom value that will work reliably. Triggers are limited to one trigger in every trigwindow seconds.

NOTE: The server MUST be booted before .pedalTrig is called.

TO DO: create a way to store values from the pracGUI to be re-used for later performances.

Arguments:

pedalbus
trigwindow
testdur
guiBounds
addAction
target

-killAll

Kill this instance of ProcEvents. Frees everything.

-pracmode

-stopTimeLine

-headerFormat

-headerFormat = value

-sampleFormat

-sampleFormat = value

-pedrespsetup

-pedalgui

-eventButton

-withTimeLine (timeLineArray, timeLineStart: 0)

Arguments:

timeLineArray
timeLineStart

-play (event)

Plays and releases the events at index in the events array. If initmod has not been executed, it will be.

Arguments:

event

-showPMGUIs

-showPMGUIs = value

-onEvent

-onEvent = value

-ampDict

-perfGUI (guiBounds, buttonColor)

Creates a GUI with basic ProcEvents controls to perform an instance of ProcEvents.

Arguments:

guiBounds
buttonColor

-loadTimeLine (path)

Arguments:

path

-releaseArray

-lag

-lag = newlag

Arguments:

newlag

-record (path, argTimeStamp: true, argHeaderFormat: 'aiff', argSampleFormat: 'int16')

Arguments:

path
argTimeStamp
argHeaderFormat
argSampleFormat

-bigNumGUI (bigNumBounds, fontSize: 96)

Arguments:

bigNumBounds
fontSize

-window

-starttime

-starttime = newtime

Returns the starttime of the ProcMod with 'id' in relation to the starttime of ProcEvents' first event. Id should be a \symbol or "string". If 'id' is nil, the time of the first event of this instance of ProcEvents (according to Main.elapsedTime) is returned.

Arguments:

newtime

-killButton

-pedresp

-buttonHeight

Inherited instance methods

Examples

(
SynthDef(\singrain, {arg freq, amp, dur, procbus, outbus = 0;
    Out.ar(outbus,
        Pan2.ar(
            SinOsc.ar(freq, 0, amp) *
                EnvGen.kr(Env.sine(dur, amp), doneAction: 2) *
                In.kr(procbus), // read off the overall env control of the ProcMod
            Rand(-1.0, 1.0)
        )
    )
}).add;
)

(
// create a ProcMod... feed the function in at init time
a = ProcMod.new(Env([0, 1, 0], [1, 1], \sin, 1), 0.02,
        function: {arg group, envbus, server;
            Task({
                inf.do({
                    s.sendMsg(\s_new, \singrain, s.nextNodeID, 0, group,
                        \freq, 440.rrand(880), \amp, 1, \dur, 0.2,
                        \procbus, envbus);
                    0.05.wait;
                    })
                });
            }
        );

// create a ProcMod... set the function after init time
b = ProcMod.new(Env([0, 1, 0], [1, 1], \sin, 1), 0.02)
    .function_({arg group, envbus;
        Task({
            inf.do({
                s.sendMsg(\s_new, \singrain, s.nextNodeID, 0, group,
                    \freq, 4400.rrand(8800), \amp, 1, \dur, 0.2,
                    \procbus, envbus);
                0.05.wait;
                })
            });
        });

// create the ProcEvents to run the above ProcMods
e = ProcEvents.new(
    // an array of event / release arrays
    [
        // run 'a'
/* 0 */        [a, nil],
        // run 'b'
/* 1 */        [b, nil],
        // kill ev1 and ev2
/* 2 */        [nil, [a, b]]
    ], 1);

)

// open a GUI to perform the above events
e.perfGUI;

// a more complex example, using function to create ProcMods, and feeding the
// evaluated form of those functions into ProcEvents.
(
a = {arg id, amp, env, high, low, winsize, overlaps;
    var proc;
    proc = ProcMod.new(env, amp, id: id);
    proc.function_({arg group, envbus, server;
        Task({
            inf.do({
                // start a new synth... run it inside this ProcMod's group,
                // and read control values off the envbus
                server.sendMsg(\s_new, \singrain, server.nextNodeID, 0, group,
                    \freq, high.rrand(low), \amp, 1, \dur, winsize,
                    \procbus, envbus);
                (winsize / overlaps).wait;
                })
            });
        });
    };

e = ProcEvents.new([
/* 0 */        [a.value(\ev1, 0.1, Env([0, 1, 0], [2, 10], \sin, 1), 440, 880, 0.3, 8),
            nil], // create \ev1, release nothing
/* 1 */        [a.value(\ev2, 0.1, Env([0, 1, 0], [1, 10], \sin, 1), 2200, 4400, 0.2, 8),
            nil],
/* 2 */        [a.value(\ev3, 0.1, Env([0, 1, 0.5, 2, 0], [1, 1, 1, 1], \sin, 1), 100,
                10000, 1, 4),
            [\ev1, \ev2]], // release ev1 and ev2
/* 3 */        [nil, \ev3]
            ], 0.dbamp, id: "test");

)

e.perfGUI;

/* A simple example showing the pedalTrig function. The headroom value is high so you
can see how it works with an internval mic ... snap your fingers and the GUI should advance */

(
s.boot;
s.waitForBoot({
    a = ProcEvents.new([
        [{"event1".postln}, nil],
        [{"event2".postln}, nil],
        [{"event3".postln}, nil],
        [{"event4".postln}, nil],
        [{"event5".postln}, nil],
        [{"event6".postln}, nil],
        [{"event7".postln}, nil],
        [{"event8".postln}, nil],
        [{"event9".postln}, nil]
        ], 1, nil, nil, "test", s);

    // .pedalTrig(pedalbus, tolerance, testdur)
    // we'll make the pedalbus the inbus of the pedal
    // pedalTrig will listen for the average amount of noise on the bus
    // then looks for triggers above noise * headroom
    // 5 might be high... but it is handy for using the internal mic for a test
    // this really depends on the noise floor of your pedal (I've used values in
    // the hundreds even)
    a.pedalTrig(s.options.numOutputBusChannels, 10, 2);

    a.perfGUI;
    })
)

s.scope