s = Server.internal.boot;
Server.default = s;
s.scope;
(
var score, noteObj, options;
// create a CtkScore to fill with notes
score = CtkScore.new;
noteObj = CtkSynthDef(\oscili, {arg freq, amp, envDur;
var osc, osc2, env;
osc = SinOsc.ar(freq, 0, amp);
env = Line.kr(1, 0, envDur, doneAction: 0);
Out.ar(0, osc * env)
});
score.add(noteObj.new(1.0, 2.0).freq_(440).envDur_(2).amp_(0.5));
score.add(noteObj.new(3.0, 2.0).freq_(440).envDur_(2).amp_(0.2));
score.add(noteObj.new(3.1, 2.0).freq_(548).envDur_(2).amp_(0.2));
score.add(noteObj.new(3.2, 2.0).freq_(332).envDur_(2).amp_(0.2));
score.add(noteObj.new(3.3, 2.0).freq_(656).envDur_(2).amp_(0.2));
score.add(noteObj.new(3.4, 2.0).freq_(424).envDur_(2).amp_(0.2));
score.add(noteObj.new(3.5, 2.0).freq_(564).envDur_(2).amp_(0.2));
score.add(noteObj.new(3.6, 2.0).freq_(816).envDur_(2).amp_(0.2));
score.add(noteObj.new(2.1, 2.0).freq_(300).envDur_(2).amp_(0.2));
score.add(noteObj.new(5.1, 2.0).freq_(412).envDur_(2).amp_(0.2));
score.add(noteObj.new(5.1, 2.0).freq_(524).envDur_(2).amp_(0.2));
score.add(noteObj.new(5.1, 2.0).freq_(916).envDur_(2).amp_(0.2));
score.add(noteObj.new(1.3, 2.0).freq_(450).envDur_(2).amp_(0.2));
// we have two options... uncomment the line below to play in real-time
//score.play;
/* or uncomment the following two lines to write a soundfile out to your Desktop. One additional step is needed here... we need to tell the NRT scsynth to write out a mono file. We use the ServerOptions object to do this. */
options = ServerOptions.new.numOutputBusChannels_(1);
/* the path to where we want a file written to is UNIX path, using the '~' shortcut. We need to tell SC to expand this to the full path. On lab machines, this path will be HUGE since your account exists on a server. We can access the argument to the CtkScore:write method called 'options' by using the name of the arg plus a colon. This lets you skip arguments to a function */
score.write("~/Desktop/test.aif".standardizePath, options: options);
)
// SFPlayer can be used to play your sounds back
a = SFPlayer("~/Desktop/test.aif".standardizePath);
a.gui;
a.play