supercollider=code=share

basics

Oscillator Stereo basics

(
{
 // mixing sine oscillators in parallel
    var n = 16; // number of structures to make
    // mix together  parallel structures
    Mix.fill(n,
            // this function creates an oscillator at a random frequency
            { FSinOsc.ar(200 + 1000.0.rand) }
    ) / (2*n)            // scale amplitude
}.scope(1);
)

Great Theremin with your mouse

#theremin nice sound (ghosty)
(
{
 SinOsc.ar(
  freq: MouseY.kr(3200, 200, lag: 0.5, warp: 1) *
  SinOsc.kr(6, mul: 0.02, add: 1), //Vibrato
  mul: abs(MouseX.kr(0.02, 1)) //Amplitude
 )
}.play
)

funny crazy bells

#bells funny

(
//frequency linked to envelope length
  //high notes short, low long
{
var frequency;
Mix.ar(
 {
  frequency = rrand(100, 5000);
  Pan2.ar(
   SinOsc.ar(
    frequency,
    mul: EnvGen.kr(
     Env.perc(0.001, 500/frequency),
     Dust.kr(0.05),
     0.2
    )
   ),
   rrand(-1.0, 1.0)
  )
 }.dup(100)
)
}.play
)
</code

===== composition =====

Found codes to glitch it!

<code>
#HarhNoiseGlitchmusic


(
{
	var  h, n, m, k, trig;
 		trig = Dust.kr( 7 ** LFNoise1.kr(0.3) );
		h = ToggleFF.kr(CoinGate.kr(0.4,trig)) *
			RLPF.ar(LFPulse.ar(50, 0, 0.5, 1, LFNoise1.kr(2, 0.5, -0.5)), 6000, 0.15);
		n =  Trig.ar(trig, TRand.kr(0, 0.01, CoinGate.kr(0.4,trig))) * WhiteNoise.ar;
		m =  Trig.ar(trig, TRand.kr(0, 0.01, CoinGate.kr(0.4,trig))) * BrownNoise.ar;
		k = Trig.ar(trig, LFNoise1.kr([ 4, 4.2 ], 0.1, 0.11)) *
			LFClipNoise.ar(LFNoise0.kr(7, 30, 40));
		LeakDC.ar(h + n + k + m * 10).distort;
}.play;
)

Live coding

Bases of live coding:

p = ProxySpace.push; //

some simple live code to get in

code::
d = (); // create a new environment
d.push; // push it to current

// this synthdef can be changed on the fly, but the synth will
// not change from this. use expression [1] for replacing a given synth
(
SynthDef(\x, { |out, freq = 440|
	Out.ar(out,
		Ringz.ar(Dust.ar(40), freq, 0.1)
	)
}).send(s)
)

// send a first synth:
~s1 = Synth(\x);

// [1]
// now you can play around with these lines, as well as with the synth def above
~s1 = Synth.replace(~s1, \x, [\freq, 200000]);
~s1.set(\freq, 8000);

// add a bus:

~b1 = Bus.control(s);
~b1.set(350);
~s1.map(\freq, ~b1);

// set the bus to different values:

~b1.set(100);
~b1.xline(800, 5);

~s3 = { Out.kr(~b1, MouseX.kr(300, 900, 1)) }; // add some mouse control on the fly
~s3.free; // remove it again.



// finish:

~b1.free;
d.clear;
d.pop;
::

Music with beats

basic techno (nice)

(
play{
    i=Impulse.ar(_);
    h = LPF.ar(WhiteNoise.ar(Decay.ar(Impulse.ar([1,1/7],[0.5,0.75]).sum,0.1)!2),12000);
    Limiter.ar(
    (z=Pluck.ar(Saw.ar(4),i.(1),1,1,6/7,SinOsc.ar(PulseCount.ar(i.(11),i.(5)).cos%[3,4]*12),2.5).sin)
    + LPF.ar(HPF.ar(FreeVerb.ar(z.mean,1,0.999,0.2)*0.3,750)*Line.kr(0,1,16),2500)
    + HPF.ar(Ringz.ar(LPF.ar(Impulse.ar([0.5,1],[1/6,0]).sum,3000),40,0.8,3).sin*3,40).tanh.madd(0.6)
    + h + RHPF.ar(CombL.ar(h*0.4,1,5/8,10)*Line.kr(0,1,8),10000,0.5)
    )
}
)

supercollider.txt · Last modified: 2021/11/06 13:17 by julien
GNU Free Documentation License 1.3 Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3