Skip to content

Instantly share code, notes, and snippets.

@vinzdef
Created January 20, 2018 15:49
Show Gist options
  • Save vinzdef/43c9e3c67be47028ba97da11f65ff6bb to your computer and use it in GitHub Desktop.
Save vinzdef/43c9e3c67be47028ba97da11f65ff6bb to your computer and use it in GitHub Desktop.
SuperCollider 34C3 Assembly Intro
{
SinOsc.ar(
Line.kr(440, 220, 1), 0, 1
);
}.scope
SynthDef(\env_synth,{
Out.ar(0, SinOsc.ar(440));
}).add;
SynthDef(\env_synth_stereo,{
Out.ar(0, [SinOsc.ar(440),SinOsc.ar(440)] );
}).add;
Synth(\env_synth_stereo);
//_____
//declaration
SynthDef(\stereo_vars,{arg freq, phase;
Out.ar(0, [SinOsc.ar(freq, phase),SinOsc.ar(freq, phase)] );
}).add;
//shorter
SynthDef(\stereo_vars_short,{|freq=440, phase=0|
Out.ar(0, SinOsc.ar(freq, phase) ! 2);
}).add;
//instance
Synth(\stereo_vars_short);
//instance with vars
Synth(\stereo_vars_short, [freq:220, phase:0.75pi])
//Envelopes (this stays in memory!!!)
{
var env = Env([0, 1, 0], [2, 2]);
SinOsc.ar(440, 0, EnvGen.kr(env))
}.scope
//Looping env
{
var env = Env([0, 0.5, 0.7, 1, 0.2], [2, 2, 2], 'lin', 3, 0);
SinOsc.ar(440, 0, EnvGen.kr(env))
}.scope
//Envelopes (this does not)
{
var env = Env([0, 1, 0], [2, 2]);
SinOsc.ar(440, 0, EnvGen.kr(env, doneAction: 2));
}.scope
//ASR Envelope
SynthDef(\asr_gate, {|gate=1|
var env = Env.asr(0.2, 0.9, 0.9);
Out.ar(0, SinOsc.ar(440, 0, EnvGen.kr(env, gate, doneAction: 2)));
}).add
~asr = Synth(\asr_gate);
~asr.set("gate", 0);
//Simple env for sequence
SynthDef(\sin_env, {
var env = Env([0,1,0], [0.3, 0.3]);
Out.ar(0, SinOsc.ar(440, 0, EnvGen.kr(env, doneAction: 2)));
}).add
//Simple sequence
{
Synth(\sin_env);
1.wait;
Synth(\sin_env);
1.wait;
Synth(\sin_env);
1.wait;
Synth(\sin_env);
}.fork
//same
{
4.do {
Synth(\sin_env);
1.wait;
}
}.fork
//180bpm anonymous routine (env is too long)
(
var clock = TempoClock(3);
~routine = {
4.do {
Synth(\sin_env);
3.wait;
}
}.fork(clock);
~routine.stop;
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment