CtkProtoNotes / CtkNoteObject a note prototyping system

Part of the CompositionToolKit (Ctk) system. See Ctk help for more details

CtkProtoNotes - A dictionary of CtkNoteObjetcs created from SynthDefs

Class Methods

*new(SynthDefs) - an instance or many instances of SynthDef. These SynthDefs will be loaded to the default

server for use in NRT and RT use. Instances of CtkNoteObject are created from the SynthDefs to be

used for creating instances of CtkNotes. SynthDefs can also be a SynthDescLib.

add(SynthDefs) - add additional SynthDefs to an instance of CtkProtoNotes.

at(id) - access an instance of CtkNoteObject stored within an instance of CtkProtoNotes. 'id' is the name of a

SynthDef loaded into an instance of CtkProtoNotes

Examples:

// add nodes at init time ...

a = CtkProtoNotes(

SynthDef(\test, {arg gate = 1, freq, amp;

var env, envgen, src;

env = Control.names([\env]).kr(Env.newClear(8));

envgen = EnvGen.kr(env, gate, doneAction: 2);

src = SinOsc.ar(freq, 0, amp * envgen);

Out.ar(0, Pan2.ar(src, Rand(-1.0, 1.0)));

}),

SynthDef(\control, {arg outbus, rate, low, hi;

Out.kr(outbus, LFNoise2.kr(rate).range(low, hi))

})

);

// ... or add them later

a.add(

SynthDef(\test2, {arg gate = 1, freq, amp;

var env, envgen, src;

env = Control.names([\env]).kr(Env.newClear(8));

envgen = EnvGen.kr(env, gate, doneAction: 2);

src = BPF.ar(WhiteNoise.ar(amp), freq, 0.01, amp * envgen);

Out.ar(0, Pan2.ar(src, Rand(-1.0, 1.0)));

})

);

// access the CtkNoteObject prototype

a[\test];

a[\test].args;

a[\control];

a[\control].args;

a[\test2];

a[\test2].args;

// or, create a CtkProtoNotes from a SynthDescLib

a = CtkProtoNotes(SynthDescLib.global);

a[\default]; // returns the CtkNoteObject from the SynthDef \default

a[\default].args;

CtkNoteObject - A prototyping system based on SynthDefs.

In general, you will not need to create instances of CtkNoteObj. CtkProtoNotes will do it for you. The main purpose of this class is the creation of new instances of CtkNote based on a CtkNoteObject prototype.

Class Methods

*new(SynthDef) - an instance of SynthDef.

new(starttime, duration, addAction, target, server) - create a new instance of CtkNote based on the

SynthDef contained in this instances of CtkNoteObject. See the CtkNote helpfile for a description of

parameter uses for both real-time and non-real-time uses.

args - post a list of controls and defaults to the post window. The Dictionary containing the argument names

as keys and default values is returned.

Examples:

a = CtkNoteObject.new(

SynthDef(\test2, {arg gate = 1, freq, amp;

var env, envgen, src;

env = Control.names([\env]).kr(Env.newClear(8));

envgen = EnvGen.kr(env, gate, doneAction: 2);

src = BPF.ar(WhiteNoise.ar(amp), freq, 0.01, amp * envgen);

Out.ar(0, Pan2.ar(src, Rand(-1.0, 1.0)));

})

);

// show the args

a.args;

// create a new instance of CtkNote based on this prototype

b = a.new;

// set values for its arguments. See the CtkNote helpfile for more info on arguments

b.freq_(440).amp_(1.0).env_(Env([0, 1, 0], [0.5, 0.5], \sin, 1));

// play it

b.play;

// create a second instance with different args ...

c = a.new.freq_(660).amp_(1.0).env_(Env([0, 1, 0], [5, 5], \sin, 1)).play;

// release both

b.release; c.release;

Examples that create new instances of a SynthDef directly from CtkProtoNotes:

s = Server.internal.boot;

Server.default = s;

a = CtkProtoNotes(

SynthDef(\test, {arg gate = 1, freq, amp;

var env, envgen, src;

env = Control.names([\env]).kr(Env.newClear(8));

envgen = EnvGen.kr(env, gate, doneAction: 2);

src = SinOsc.ar(freq, 0, amp * envgen);

Out.ar(0, Pan2.ar(src, Rand(-1.0, 1.0)));

}),

SynthDef(\control, {arg outbus, rate, low, hi;

Out.kr(outbus, LFNoise2.kr(rate).range(low, hi))

}),

SynthDef(\test2, {arg gate = 1, freq, amp;

var env, envgen, src;

env = Control.names([\env]).kr(Env.newClear(8));

envgen = EnvGen.kr(env, gate, doneAction: 2);

src = BPF.ar(WhiteNoise.ar(amp), freq, 0.01, amp * envgen);

Out.ar(0, Pan2.ar(src, Rand(-1.0, 1.0)));

})

);

b = a[\test2].new.freq_(440).amp_(1.0).env_(Env([0, 1, 0], [0.5, 0.5], \sin, 1)).play;

c = a[\test].new.freq_(440).amp_(0.1).env_(Env([0, 1, 0], [0.5, 0.5], \sin, 1)).play;

c.release;

b.release;