(

Server.default = s = Server.internal.boot;

s.waitForBoot({

s.scope;

});

)


// create a block of memory that an oscillator can play off of.

a = CtkBuffer.buffer(size);

// then, you can fill the buffer / table with different kinds of data

// the sine1 method

a.sine1(time, normalize, wavetable, clear .... args)

// time should be 0.0, 

// normalize is a 0 or 1. If 1, make the largest value 1 or -1

// wavetable is a 0 or 1. If 1, make the data use the Wavetable format (

// some UGens require this, like Osc)

// clear is 0 or 1. This will clear any previous data in the buffer. For

// now, use 1!

// args are values that correspond to partial strength, and can be any size

// a single '1' means you will have a single partial for a sin tone

// a '1, 0.5' means two partials are created, the second being half the

// strength of the first. a '1, 0.2, 0.5' creates three partials... etc.


(

var note, noteObject, score, oscex, oscnex, buffer1, buffer2, buffer3,

buffer4;


oscex = CtkSynthDef(\oscex, {arg buffer, freq = 440, dur = 1;

var osc, env, envgen;

// a more 'general use' Env object. Takes an array of values,

// an array of times, and a curve

env = Env([0, 1, 1, 0], [0.01, dur - 0.02, 0.01], \lin);

envgen = EnvGen.kr(env);

osc = Osc.ar(buffer, freq, 0, 0.3);

Out.ar(0, osc * envgen);

});

oscnex = CtkSynthDef(\oscnex, {arg buffer, freq = 440, dur = 1;

var osc, env, envgen;

env = Env([0, 1, 1, 0], [0.01, dur - 0.02, 0.01], \lin);

envgen = EnvGen.kr(env);

osc = OscN.ar(buffer, freq, 0, 0.3);

Out.ar(0, osc * envgen);

});


score = CtkScore.new;

// size of 16, normalize, wavetable and clear. Use for Osc

buffer1 = CtkBuffer.buffer(16).sine1(0.0, 1, 1, 1, 1);

// size of 16, normalize, NOT a wavetable and clear. Use of OscN

buffer2 = CtkBuffer.buffer(16).sine1(0.0, 1, 0, 1, 1);

// size of 8192, normalize, wavetable and clear. Use for Osc

buffer3 = CtkBuffer.buffer(8192).sine1(0.0, 1, 1, 1, 1);

// size of 8192, normalize, NOT a wavetable and clear. Use of OscN

buffer4 = CtkBuffer.buffer(8192).sine1(0.0, 1, 0, 1, 1);

// add them all to the score

score.add(buffer1, buffer2, buffer3, buffer4);


// create three notes that play each buffer at 440 Hz, for 3 seconds!

score.add(

oscex.new(1.0, 3.0).buffer_(buffer1).freq_(440).dur_(3),

oscnex.new(5.0, 3.0).buffer_(buffer2).freq_(440).dur_(3),

oscex.new(9.0, 3.0).buffer_(buffer3).freq_(440).dur_(3),

oscnex.new(13.0, 3.0).buffer_(buffer4).freq_(440).dur_(3)

);

score.play;

)



(


var note, noteObject, score, oscex, oscnex, buffer1, buffer2, buffer3,

buffer4;


oscex = CtkSynthDef(\oscex, {arg buffer, freq = 440, dur = 1;

var osc, env, envgen;

env = Env([0, 1, 1, 0], [0.01, dur - 0.02, 0.01], \lin);

envgen = EnvGen.kr(env);

osc = Osc.ar(buffer, freq, 0, 0.3);

Out.ar(0, osc * envgen);

});


score = CtkScore.new;

// size of 8192, normalize, wavetable and clear. Use for Osc. One partial

buffer1 = CtkBuffer.buffer(8192).sine1(0.0, 1, 1, 1, 1);

// size of 8192, normalize, wavetable and clear.

// Two partials, same strength

buffer2 = CtkBuffer.buffer(8192).sine1(0.0, 1, 1, 1, 1, 1);

// size of 8192, normalize, wavetable and clear.

// Four partials, different strengths. The values do NOT need to add up to

// 1.0 if the normalize flag is set

buffer3 = CtkBuffer.buffer(8192).sine1(0.0, 1, 1, 1, 0.1, 0.5, 0.3, 2.0);

// size of 8192, normalize, wavetable and clear. 

// Sound familiar?

buffer4 = CtkBuffer.buffer(8192)

.sine1(0.0, 1, 1, 1, 1, 0.2, 0.5, 0.0, 0.4, 0.0, 0.1, 0.0, 0.05);

// add them all to the score

score.add(buffer1, buffer2, buffer3, buffer4);


// create three notes that play each buffer at 220 Hz, for 3 seconds!

score.add(

oscex.new(1.0, 3.0).buffer_(buffer1).freq_(220).dur_(3),

oscex.new(5.0, 3.0).buffer_(buffer2).freq_(220).dur_(3),

oscex.new(9.0, 3.0).buffer_(buffer3).freq_(220).dur_(3),

oscex.new(13.0, 3.0).buffer_(buffer4).freq_(220).dur_(3)

);

score.play;


)