Created
October 22, 2019 06:29
-
-
Save peterkirn/c2e4e55fccfdc70a37318614e7912e7a to your computer and use it in GitHub Desktop.
Simple SuperCollider tutorial: effects processing and input tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The impromptu Manila Kirn Audio Input Mangling Guide, version 0.1 | |
// https://twitter.com/peterkirn * http://instagram.com/pkirn * peter@cdm.link | |
// Boot the server | |
s.boot; | |
s.quit; | |
// Where to put those extensions | |
Platform.userExtensionDir; | |
// s.options.device = "ASIO : Maschine MK3"; etc. | |
s.options.numOutputBusChannels = 2; | |
s.options.numInputBusChannels = 1; | |
Server.local.meter; | |
/* | |
Keyboard shortcuts | |
Stop: Cmd/Ctrl + . | |
Look up help (documentation): Cmd/Ctrl + D | |
Line only: Shift + ENTER | |
Whole region: Ctrl/Cmd + ENTER | |
*/ | |
"Hello World!".postln; | |
// Test sound, simple UGen oscillator | |
{ SinOsc.ar(440, 0, 0.2) }.play; | |
// Try that in stereo | |
{ [SinOsc.ar(440, 0, 0.2), SinOsc.ar(442, 0, 0.2)] }.play; | |
// Inputs at control rate | |
{ SinOsc.ar(MouseY.kr(40, 10000, 1), 0, 0.1) }.play; | |
// Test an input; see what you can see | |
{ Amplitude.kr(SoundIn.ar(0)); }.scope; | |
// Imagine patching analog signals | |
{ Pan2.ar(PinkNoise.ar(0.2), SinOsc.kr(0.5)) }.play; | |
// First install a Quark - Language > Quarks > PithShiftPA | |
// Do you believe in life after love? | |
( | |
{ | |
var in = SoundIn.ar(0); | |
PitchShiftPA.ar( | |
in, | |
Pitch.kr(in)[0], //pitch tracking - we take just the frequency | |
MouseX.kr(0.5, 2), //pitchRatio | |
MouseY.kr(0.5, 2), //formantRatio | |
) | |
}.play | |
) | |
// You can track a synthesizer with pitch, too | |
{Saw.ar(Tartini.kr(SoundIn.ar)[0],0.2)}.play | |
// Multichannel expansion makes this stereo! | |
{Saw.ar([ Tartini.kr(SoundIn.ar)[0], Tartini.kr(SoundIn.ar)[0]],0.2)}.play | |
// Add dynamic control | |
{SinOsc.ar(440, 0, 3*Amplitude.ar(SoundIn.ar(0), 0.05, 0.05))}.play; | |
// and back to stereo | |
{SinOsc.ar([ Tartini.kr(SoundIn.ar)[0], Tartini.kr(SoundIn.ar)[0]], 0, 3*Amplitude.ar(SoundIn.ar(0), 0.05, 0.05))}.play; | |
// Try fancier examples in Tartini, Pitch, and if you feel advanced Qitch | |
// Here is the above as a SynthDef | |
( | |
SynthDef(\Dynamic, { arg out = 0; | |
var in; | |
in = Limiter.ar(SoundIn.ar(0)); | |
Out.ar(out, SinOsc.ar(220, 0, Amplitude.ar(in, 0.05, 0.05))); | |
}).add; | |
) | |
~dyn = Synth(\Dynamic); | |
// Simple octaver - also shows how to add and remove synths from the graph | |
( | |
SynthDef(\RmOctaver, { arg out = 0; | |
var in, freq, hasFreq; | |
in = Limiter.ar(SoundIn.ar(0),0.9); | |
# freq, hasFreq = Pitch.kr(in); | |
Out.ar(out, SinOsc.ar(freq: freq * 0.5) * in + in); | |
}).add; | |
) | |
~octaver = Synth(\RmOctaver); | |
// Try it in stereo | |
Synth.new(\RmOctaver); | |
// Wave folder distortion | |
( | |
SynthDef(\Wavefolder, { arg out = 0, amp = 0.5; | |
var output; | |
output = Limiter.ar(SoundIn.ar(0), amp); | |
Out.ar(out, output.fold2(MouseY.kr(0.1,0.5,0))); | |
}).add; | |
) | |
~folder = Synth(\Wavefolder); | |
( | |
SynthDef(\Decimate, { arg out = 0, amp = 0.5; | |
var output; | |
output = Limiter.ar(SoundIn.ar(0), amp); | |
Out.ar(out, Decimator.ar(output, MouseX.kr(1000,44100,1), MouseY.kr(1,24,0) )); | |
}).add; | |
) | |
~decky = Synth(\Decimate, ["out", [0, 1] ]); | |
// Fake an Eventide | |
( | |
SynthDef(\Evinrude, { arg out = 0, amp = 0.5; | |
var output; | |
output = Limiter.ar(SoundIn.ar(0), amp); | |
Out.ar(out,Pan2.ar( | |
Greyhole.ar( | |
output, | |
\delayTime.kr(0.1), | |
\damp.kr(0.1), | |
\size.kr(1), | |
\diff.kr(0.707), | |
\fb.kr(0.1), | |
\modDepth.kr(0.01), | |
\modFreq.kr(2) | |
); | |
); | |
); | |
}).add; | |
) | |
~evinrude = Synth(\Evinrude, ["out", [0, 1] ]); | |
~evinrude.set(\size, 1); | |
~evinrude.set(\fb, 0.9); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment