Session slack_1740123456789012
Practice Journal
Understood. Let’s begin with a SuperCollider audio piece. I’ll generate a sclang code snippet that creates a generative pattern using oscillators and envelopes.
// Define a SynthDef for a simple plucked string sound
SynthDef(\pluckedString, { |freq = 440, amp = 0.5, dur = 1|
var env = EnvGen.ar(Env.perc(0.01, dur), doneAction: 2);
var sig = SinOsc.ar(freq) * env * amp;
Out.ar(0, sig ! 2);
}).store;
// Create a pattern that sequences notes using a pentatonic scale
p = Pbind(
\instrument, \pluckedString,
\dur, 0.25,
\degree, Pseq([0, 2, 4, 7, 9], inf),
\amp, 0.6,
\scale, Scale.pentatonic,
\root, 60,
\octave, 5
);
// Render the pattern to a WAV file
p.asScore(16).recordNRT(
outputFilePath: "~/output.wav".standardizePath,
headerFormat: "WAV",
sampleFormat: "int16",
sampleRate: 44100,
duration: 16
);
Let’s create a more complex piece with layered sounds and evolving patterns. Here’s a sclang code snippet that generates a textural soundscape:
// Define a SynthDef for a resonant filter with an evolving envelope
SynthDef(\resonantFilter, { |freq = 440, amp = 0.5, dur = 1, cutoff = 800, resonance = 2|
var env = EnvGen.ar(Env.asr(0.1, dur * 0.8, 0.1), doneAction: 2);
var sig = SinOsc.ar(freq) * env * amp;
var filtered = MoogFF.ar(sig, cutoff, resonance);
Out.ar(0, filtered ! 2);
}).store;
// Define a SynthDef for a granular texture
SynthDef(\granularTexture, { |freq = 440, amp = 0.5, dur = 1, grainDur = 0.05, numGrains = 50|
var env = EnvGen.ar(Env.perc(0.01, dur), doneAction: 2);
var sig = Dust.ar(numGrains / dur) * amp;
var grains = PlayBuf.ar(
2,
BufRd.ar(2, Phasor.ar(0, grainDur.inv, 0, BufRateScale.kr(2)), leave: grainDur),
grainDur,
doneAction: 2
) * env;
Out.ar(0, grains ! 2);
}).store;
// Create a complex pattern with layered sounds
p = Pbind(
\instrument, Pseq([\resonantFilter, \granularTexture], inf),
\dur, 0.5,
\degree, Pwhite(-12, 12),
\amp, 0.4,
\cutoff, Pwhite(300, 1500),
\resonance, Pwhite(1, 5),
\grainDur, Pwhite(0.03, 0.1),
\numGrains, Pwhite(30, 100)
).layer(
Pbind(
\instrument, \resonantFilter,
\dur, 2,
\degree, Pseq([0, 2, 4, 5, 7], inf),
\amp, 0.3,
\cutoff, Pwhite(500, 2000),
\resonance, Pwhite(2, 4)
)
);
// Render the pattern to a WAV file
p.asScore(24).recordNRT(
outputFilePath: "~/output.wav".standardizePath,
headerFormat: "WAV",
sampleFormat: "int16",
sampleRate: 44100,
duration: 24
);