Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
supercollider [2021/11/05 18:25] juliensupercollider [2021/11/06 13:17] (current) julien
Line 1: Line 1:
 +====== supercollider=code=share ======
 +
 +https://supercollider.github.io/
 +
 +https://toplap.org/
 +
 +https://github.com/toplap/awesome-livecoding
 +
 +
 +===== basics =====
 +
 +Oscillator Stereo basics
 +<code>
 +(
 +{
 + // 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);
 +)
 +</code>
 +
 +Great Theremin with your mouse
 +
 +<code>
 +#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
 +)
 +</code>
 +
 +funny crazy bells
 +<code>
 +#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;
 +)
 +</code>
 +
 +===== Live coding =====
 +
 +Bases of live coding: 
 +
 +<code>
 +p = ProxySpace.push; //
 +</code>
 +
 +
 +some simple live code to get in
 +
 +<code>
 +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;
 +::
 +</code>
 +
 +
 +===== Music with beats =====
 +
 +basic techno (nice)
 +
 +<code>
 +(
 +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)
 +    )
 +}
 +)
 +</code>
 +
 +