Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////// FM Basics | Part 1 //////////////////////////////
- //////////////////////////// WAVEFORMS AND CONTROL VALUES ///////////////////////////
- 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;
- /////////////////////// 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.
- Values presented in purple can be changed. Only remember to NEVER cross 0, when using an exponential method.
- */
- // Types of Waveforms
- {SinOsc.ar(300, 0, 0.2)!2}.play;
- {Saw.ar(300, 0.2)!2}.play;
- {LFSaw.ar(300, 0, 0.2)!2}.play;
- {LFTri.ar(300, 0, 0.2)!2}.play;
- {LFCub.ar(300, 0, 0.2)!2}.play;
- {LFPar.ar(300, 0, 0.2)!2}.play;
- {Pulse.ar(300, 0.5, 0.2)!2}.play;
- {LFPulse.ar(300, 0, 0.5, 0.2)!2}.play; // Don't forget the width argument!
- // SinOsc
- {SinOsc.ar(200, 0, 0.2)!2}.play;
- // Using a SinOsc with a Control Parameter (in this case, with XLine)
- {SinOsc.ar(XLine.kr(2000, 200), 0, 0.2)!2}.play; // default dur value is 1 second
- {SinOsc.ar(XLine.kr(2000, 200, 8), 0, 0.2)!2}.play; // going from 2000Hz to 200Hz in 8 seconds
- // What's going here?
- {SinOsc.ar(SinOsc.ar(XLine.kr(1, 20, 10), 0, 200, 400), 0, 0.2)!2}.play;
- /* You have a sine tone at 400Hz, with a modulatory value of 200, meaning it will rise to 600Hz (400+200) and fall to 200Hz (400-200). Simultaneously, you have another control value with XLine, which traverses from 1 to 20 cycles per second over the course of 10 seconds. */
- {SinOsc.ar(LFSaw.ar(XLine.kr(1, 20, 10), 0, 200, 400), 0, 0.2)!2}.play; // Same applies to sawtooth wave.
- {SinOsc.ar(LFTri.ar(XLine.kr(1, 20, 10), 0, 200, 400), 0, 0.2)!2}.play; // Same applies to triangle wave.
- // Try having the sine tone at 800Hz for a perceptible difference.
- // The sine tone rises from its starting point at 800Hz to 1000Hz, before falling to 600Hz.
- {SinOsc.ar(LFCub.ar(XLine.kr(1, 20, 10), 0, 200, 800), 0, 0.2)!2}.play;
- {SinOsc.ar(LFPar.ar(XLine.kr(1, 20, 10), 0, 200, 800), 0, 0.2)!2}.play;
- // Explore a larger ascending line, as seen here, from 1 to 100:
- {SinOsc.ar(SinOsc.ar(XLine.kr(1, 100, 10), 0, 200, 400), 0, 0.2)!2}.play;
- // Note, this new tonal color still rests at 400.
- // Please consult this website seen below:
- // https://pages.mtu.edu/~suits/notefreqs.html
- // Saw
- {Saw.ar(XLine.kr(20, 200, 8), 0.1)!2}.play;
- {Saw.ar(SinOsc.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.1)!2}.play; // no phase arg
- {Saw.ar(Saw.ar(XLine.kr(1, 20, 4), 200, 400), 0.1)!2}.play; // no phase arg for both Saw and XLine
- // At this point, I don't know what makes that perceivable descent in pitch. Notice this is exclusive to using two sawtooth waveforms.
- {Saw.ar(LFSaw.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.1)!2}.play; // include phase arg for LFSaw
- {Saw.ar(LFTri.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.1)!2}.play; // include phase arg for LFTri
- {Saw.ar(LFCub.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.1)!2}.play; // include phase arg for LFCub
- {Saw.ar(LFPar.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.1)!2}.play; // include phase arg for LFPar
- // Please note: All arguments used for waveforms and XLine can be changed to your liking.
- // Don't change the 2 on "!2" unless you're working with multi-channel expansion. "!2" changes the mono signal to a stereo signal.
- // LFSaw
- {LFSaw.ar(XLine.kr(1, 100, 8), 0, 0.1)!2}.play; // needs phase arg
- {LFSaw.ar(Saw.ar(XLine.kr(1, 40, 8), 200, 400), 0, 0.1)!2}.play; // Remember, no phase for Saw, though we do see a phase value for LFSaw.
- {LFSaw.ar(SinOsc.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFSaw.ar(LFSaw.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFSaw.ar(LFTri.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFSaw.ar(LFCub.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFSaw.ar(LFPar.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- // LFTri
- {LFTri.ar(XLine.kr(100, 1000, 8), 0, 0.1)!2}.play;
- {LFTri.ar(SinOsc.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFTri.ar(LFSaw.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFTri.ar(LFTri.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFTri.ar(LFCub.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFTri.ar(LFPar.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- // Adding a control rate (".kr") to the control variable outputs the same.
- // For example:
- {LFTri.ar(SinOsc.kr(XLine.kr(1, 20, 8), 0, 200, 400), 0, 0.1)!2}.play;
- // That said, I would advise using the audio rate for higher frequencies and better resolution.
- // LFCub
- {LFCub.ar(XLine.kr(100, 1000, 8), 0, 0.1)!2}.play;
- {LFCub.ar(SinOsc.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFCub.ar(LFSaw.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFCub.ar(LFTri.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFCub.ar(LFCub.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFCub.ar(LFPar.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- // LFPar
- {LFPar.ar(XLine.kr(100, 1000, 8), 0, 0.1)!2}.play;
- {LFPar.ar(SinOsc.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFPar.ar(LFSaw.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFPar.ar(LFTri.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFPar.ar(LFCub.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- {LFPar.ar(LFPar.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.1)!2}.play;
- // Pulse (0.5 width value causes a square wave)
- {Pulse.ar(XLine.kr(1, 100, 10), 0.5, 0.1)!2}.play; // Careful with the instigation of this. It clips.
- {Pulse.ar(XLine.kr(1, 1000, 10), 0.5, 0.1)!2}.play;
- {Pulse.ar(SinOsc.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.5, 0.1)!2}.play;
- {Pulse.ar(LFSaw.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.5, 0.1)!2}.play;
- {Pulse.ar(LFTri.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.5, 0.1)!2}.play;
- {Pulse.ar(LFCub.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.5, 0.1)!2}.play;
- {Pulse.ar(LFPar.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0.5, 0.1)!2}.play;
- // LFPulse with Pulse...I'd probably not want to mess with this.
- // Sounds like R2-D2 before he's about to explode.
- // ...But LFPulse with other waveforms is good.
- // Remember: It needs a width argument!
- {LFPulse.ar(XLine.kr(1, 100, 10), 0, 0.5, 0.1)!2}.play;
- {LFPulse.ar(XLine.kr(1, 1000, 10), 0, 0.5, 0.1)!2}.play;
- {LFPulse.ar(SinOsc.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.5, 0.1)!2}.play;
- {LFPulse.ar(LFSaw.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.5, 0.1)!2}.play;
- {LFPulse.ar(LFTri.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.5, 0.1)!2}.play;
- {LFPulse.ar(LFCub.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.5, 0.1)!2}.play;
- {LFPulse.ar(LFPar.ar(XLine.kr(1, 20, 4), 0, 200, 400), 0, 0.5, 0.1)!2}.play;
- // A couple things to note:
- // LFSaw outputs at a higher amplitude than Saw.
- /////////////////////////////////////////////////////////////////////////
- // More examples: (Here's the motion I personally had looked for.)
- // Replace XLine with a Wavetype.
- {LFPar.ar(800, 0, 0.1)!2}.play;
- {LFPar.ar(LFPar.kr(LFPar.kr(0.2, 0, 7, 10), 0, 200, 800), 0, 0.1)!2}.play;
- // Sine tone at 800Hz travels from 1000Hz to 600Hz, in the course of 5 seconds.
- // Simultaneously, you have a modulatory fluctuation from 10 to 3 cycles every 5 seconds.
- // 10-7 = 3. The integer 7 determines the lowest cycle value of the innermost parabolic oscillation.
- // Change values for a more dynamic motion.
- {LFPar.ar(LFPar.kr(LFPar.kr(0.125, 0, 9.8, 10), 0, 200, 800), 0, 0.1)!2}.play;
- // Here, you have a dramatic change over the course of 8 seconds.
- // Remember: 1/0.125 = 8
- // Oscillator will modulate from 10 cycles to 0.2 cycles per second.
- // 10-9.8 = 0.2
- {LFPar.ar(LFPar.kr(LFPar.kr(0.2, 0, 3, 10), 0, 200, 800), 0, 0.1)!2}.play;
- // Based on the change to 3, can you guess what's going on?
- // Note how the difference isn't that dynamic.
- {LFPar.ar(LFPar.kr(0.2, 0, 400, 800), 0, 0.1)!2}.play; // begins on the highest frequency (1200Hz)
- // This is a sine tone at 800Hz traveling from 1200Hz to 400Hz in the course of 5 seconds.
- // Remember: 1/0.2 = 5
- // 800+400 = 1200; 800-400 = 400.
- // Compare:
- {LFCub.ar(800, 0, 0.1)!2}.play;
- {LFCub.ar(LFCub.kr(LFCub.kr(0.2, 0, 8, 10), 0, 400, 800), 0, 0.1)!2}.play;
- {LFCub.ar(LFCub.kr(0.2, 0, 400, 800), 0, 0.1)!2}.play; // LFCub begins at 800Hz before ascending to 1200Hz.
- {SinOsc.ar(800, 0, 0.1)!2}.play;
- {SinOsc.ar(SinOsc.kr(SinOsc.kr(0.2, 0, 8, 10), 0, 400, 800), 0, 0.1)!2}.play;
- {SinOsc.ar(SinOsc.kr(0.2, 0, 400, 800), 0, 0.1)!2}.play;
- {LFTri.ar(800, 0, 0.1)!2}.play;
- {LFTri.ar(LFTri.kr(LFTri.kr(0.2, 0, 8, 10), 0, 400, 800), 0, 0.1)!2}.play;
- {LFTri.ar(LFTri.kr(0.2, 0, 400, 800), 0, 0.1)!2}.play;
- {LFPar.ar(LFPar.kr(LFPar.kr(0.2, 0, 8, 10), 0, 400, 800), 0, 0.1)!2}.play;
- {LFPar.ar(LFPar.kr(0.2, 0, 400, 800), 0, 0.1)!2}.play; // Notice how LFPar starts the signal at the highest frequency (1200Hz). Compare it to other waveforms again.
- // Note: Mixing these waveforms in the syntax above doesn't output a huge perceptible difference. This may change with audio files of varying frequencies and their respective overtones. (See example below.)
- {LFPar.ar(SinOsc.kr(LFTri.kr(0.2, 0, 8, 10), 0, 400, 800), 0, 0.1)!2}.play;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement