Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////// FM SYNTHESIS | FM Basics (Part 4) ///////////////////////
- s.boot;
- // Run these methods below for visual cues.
- s.meter;
- s.scope;
- s.plotTree;
- // I use the following only when necessary.
- s.reboot;
- s.quit;
- // In Part 2, I cover Amplitude Modulation (AM). In Part 3, I continue with FM.
- // Here, in Part 4, we cover more divergent uses for FM.
- ////////////////// Things To Know Before Running Code //////////////////
- /*
- All my original SC documents are in the "dracula" color.
- To find or change this, go To SuperCollider ––> Preferences ––> Editor ––> Font & Colors.
- ––> Select under Color, dracula.
- Arguments in Synths are represented with a backslash, "\", in green under the "dracula" color font. Values presented with these arguments can be changed. Only remember to NEVER cross 0, when using an exponential method like "exprand."
- Arguments also precede a colon ":", as seen in a list of a UGen following a variable, "var."
- Example: sig = PlayBuf.ar(2, buf, rate, startPos: spos);
- Argument and variable names can be changed to your liking.
- Please be careful with volume output. Always have SuperCollider run through headphones. If you're unsure what the output will be, keep headphones away, with your main volume all the way down. Check your level meter and Stethoscope for visual cues. If everything looks safe (e.g. level meter is NOT in the red), proceed.
- You can always execute a hard stop with Command Period.
- */
- // SynthDefs
- Env([0, 1, 0], [0.1, 3], [1, -5]).plot; // Envelope shape to reference.
- // First array, [0, 1, 0], are levels.
- // Second array, [0.1, 3], are times traversing between levels.
- // Third array, [1, -5], are curve values.
- // What's happening here? (Hint: We've covered this line of code in FM Basics, Part 1.)
- {LFPar.ar(LFPar.kr(LFPar.kr(0.2, 0, 8, 10), 0, 200, 800), 0, 0.1)!2}.play;
- // Execute a hard stop with Command Period.
- // You have two Parabolic Oscillators working as controls for a Parabolic signal.
- // {LFPar.ar(), 0, 0.1)}, the outermost part of the Function, is the signal.
- // I keep the innermost LFPar's at a control rate ("LFPar.kr"), and the main signal at audio rate ("LFPar.ar"). If I remember correctly, this is less CPU expensive than applying audio rate to every control UGen.
- // The two innermost oscillators perform the following:
- // Sine tone at 800Hz travels to 1000Hz, then to 600Hz, in the course of 5 seconds.
- // Simultaneously, you have a modulatory fluctuation from 10 to 2 cycles every 5 seconds.
- // 10-8 = 2. The integer 8 determines the lowest cycle value of the innermost parabolic oscillator.
- // Integrate this into a SynthDef. (The code below isn't covered in Part 1.)
- (
- SynthDef.new(\parSine, {
- arg out=0;
- var sig;
- sig = LFPar.ar(LFPar.kr(LFPar.kr(0.25, 0, 8, 10), 0, 200, 800), 0, 0.1);
- sig = sig!2;
- Out.ar(out, sig);
- }).add;
- )
- Synth(\parSine);
- // Execute hard stop with Command Period. (You may need to reevaluate the SynthDef.)
- // Add an Envelope
- Env([0, 1, 0], [0.1, 8], [1, -5]).plot;
- (
- SynthDef.new(\parSine1, {
- arg atk=0.1, rel=8, c1=1, c2=(-5), out=0;
- var sig, par, env;
- env = Env([0, 1, 0], [atk, rel], [c1, c2]).kr(2);
- par = LFPar.ar(LFPar.kr(LFPar.kr(0.25, 0, 8, 10), 0, 200, 800), 0, 0.1);
- sig = par * env;
- sig = sig!2;
- Out.ar(out, sig);
- }).add;
- )
- Synth(\parSine1);
- // Add argument names to change argument values in real time.
- (
- SynthDef.new(\parSine1, {
- arg atk=0.1, rel=8, c1=1, c2=(-5),
- parCtrl=0.25, parMin=8, parMax=10, addCtrl=200, parFreq=800,
- parAmp=0.1, out=0;
- var sig, par, env;
- env = Env([0, 1, 0], [atk, rel], [c1, c2]).kr(2);
- par = LFPar.ar(
- LFPar.kr(
- LFPar.kr(parCtrl, 0, parMin, parMax), 0, addCtrl, parFreq),
- 0,
- parAmp);
- sig = par * env;
- sig = sig!2;
- Out.ar(out, sig);
- }).add;
- )
- Synth(\parSine1);
- // Don't run this too many times at once.
- (
- Synth(\parSine1, [
- \atk, rrand(0.1, 1),
- \rel, rrand(2, 8),
- \c1, rrand(1, 4),
- \c2, rrand(-1, -5),
- \parCtrl, rrand(0.125, 4),
- \parMin, rrand(3, 8),
- \parMax, rrand(9, 10),
- \addCtrl, rrand(20, 200),
- \parFreq, rrand(400, 1000),
- \parAmp, rrand(0.1, 0.3) // I'd keep the amp down for these.
- ]);
- )
- // Slower Motion
- {LFPar.ar(LFPar.kr(0.2, 0, 400, 800), 0, 0.1)!2}.play;
- // Execute hard stop with Command Period.
- // SynthDef Version
- (
- SynthDef.new(\slowSine, {
- arg out=0;
- var sig;
- sig = LFPar.ar(LFPar.kr(0.2, 0, 400, 800), 0, 0.1);
- sig = sig!2;
- Out.ar(out, sig);
- }).add;
- )
- Synth(\slowSine);
- // Add an Envelope
- (
- SynthDef.new(\slowSine, {
- arg atk=0.1, rel=8, c1=1, c2=(-5), out=0;
- var sig, par, env;
- env = Env([0, 1, 0], [atk, rel], [c1, c2]).kr(2);
- par = LFPar.ar(LFPar.kr(0.2, 0, 400, 800), 0, 0.1);
- sig = par * env;
- sig = sig!2;
- Out.ar(out, sig);
- }).add;
- )
- Synth(\slowSine); // Notice the softer attack (atk value: 0.1).
- // Add Arguments Names
- (
- SynthDef.new(\mySine, {
- arg atk=0.1, rel=8, c1=1, c2=(-5),
- parCtrl=0.2, parMin=400, parMax=800, parAmp=0.1, out=0;
- var sig, par, env;
- env = Env([0, 1, 0], [atk, rel], [c1, c2]).kr(2);
- par = LFPar.ar(LFPar.kr(parCtrl, 0, parMin, parMax), 0, parAmp);
- sig = par * env;
- sig = sig!2;
- Out.ar(out, sig);
- }).add;
- )
- Synth(\mySine);
- // Don't run this too many times at once.
- (
- Synth(\mySine, [
- \atk, rrand(0.1, 1),
- \rel, rrand(4, 12),
- \c1, rrand(1, 4),
- \c2, rrand(-1, -5),
- \parCtrl, rrand(0.125, 8),
- \parMin, rrand(20, 200),
- \parMax, rrand(400, 2000),
- \parFreq, rrand(0.125, 8),
- \parAmp, rrand(0.05, 0.1) // I'd keep the amp down for these.
- ]);
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement