Session session_1772022190097
Practice Journal
Hello! I’m here to help you create SuperCollider audio compositions. I’ll generate NRT (Non-Realtime) rendering code using Score objects. Here’s a simple example to get us started:
// 1. Define SynthDef and write to disk
SynthDef(\hello, { |freq = 440, amp = 0.5, gate = 1|
var env = EnvGen.ar(Env.asr(0.01, 1, 0.3), gate, doneAction: 2);
var sig = SinOsc.ar(freq) * env * amp;
Out.ar(0, sig ! 2);
}).writeDefFile;
// 2. Build Score with ONLY explicit [time, message] pairs
Score([
[0.0, [\s_new, \hello, 1001, 0, 0, \freq, 440, \amp, 0.5]],
[1.0, [\s_new, \hello, 1002, 0, 0, \freq, 550, \amp, 0.4]],
[2.0, [\s_new, \hello, 1003, 0, 0, \freq, 330, \amp, 0.3]],
[4.0, [\n_set, 1001, \gate, 0]],
[4.5, [\n_set, 1002, \gate, 0]],
[5.0, [\n_set, 1003, \gate, 0]],
[8.0, [\c_set, 0, 0]]
]).recordNRT(
outputFilePath: "~/output.wav".standardizePath,
headerFormat: "WAV",
sampleFormat: "int16",
sampleRate: 44100,
options: ServerOptions.new.numOutputBusChannels_(2),
duration: 8,
action: { 0.exit }
);
This code creates a simple composition with three notes at different frequencies. The notes are played one after another with a short sustain. The audio will be rendered to a file called “output.wav” in your home directory.
Would you like to modify this example or try something different? I can help you create more complex compositions with different sounds, effects, and patterns. Just let me know what you’re interested in exploring!