Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // How To Dynamically Change Amplitude
- // This could be a great expression for sound.
- // Control variables will function like an Envelope.
- // For a demonstration, here's my YouTube video: https://youtu.be/FDiig0taAwM
- s.boot;
- s.meter;
- s.scope;
- s.plotTree;
- s.reboot;
- s.quit;
- // Here's a Function for a simple synth.
- {SinOsc.ar(300, 0, 0.2)}.play;
- // Cmd Period for a hard stop.
- // Give this Function a name.
- // Change mono to stereo, by using shortcut "!2"
- (
- ~mySine = {
- var sig;
- sig = SinOsc.ar(300, 0, 0.05)!2;
- }.play;
- )
- ~mySine.free;
- // Use arguments to change values in real time. SC won't keep stacking synths this way.
- (
- ~mySine = {
- arg freq=300, amp=0.1;
- var sig;
- sig = SinOsc.ar(freq, 0, amp)!2;
- }.play;
- )
- ~mySine.set(\freq, rrand(300, 1000));
- ~mySine.set(\amp, rand(0.1, 1));
- ~mySine.free;
- // Let's control the signal with other variables.
- // For testing, I recommend low amplitude.
- (
- ~myNoise = {
- arg amp=0.1;
- var sig, freqNoise;
- freqNoise = LFNoise0.kr(8).range(200, 1000); // step noise osc to control sine wave
- sig = SinOsc.ar(freqNoise, 0, amp)!2;
- }.play;
- )
- ~myNoise.set(\amp, rrand(0.05, 0.3));
- ~myNoise.free;
- // Let's modulate the amplitude.
- (
- ~myAmp = { // Notice, we don't need an arg for amplitude.
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(1).exprange(0.01, 0.5); // Suggestion: Go between SinOsc values, 1/8 and 1.
- freqNoise = LFNoise0.kr(8).range(200, 1000);
- sig = SinOsc.ar(freqNoise, 0, modAmp)!2;
- }.play;
- )
- ~myAmp.free;
- // Let's randomize the amplitude.
- (
- ~myAmp = {
- var sig, freqNoise, ampNoise;
- ampNoise = LFNoise0.kr(4).exprange(0.05, 0.5);
- freqNoise = LFNoise0.kr(4).range(200, 1000);
- sig = SinOsc.ar(freqNoise, 0, ampNoise)!2;
- }.play;
- )
- ~myAmp.free;
- // Let's add more arguments to change values in real time.
- (
- ~myAmp = {
- arg ampCtrl=8, minAmp=0.05, maxAmp=0.5,
- freqCtrl=8, minFreq=200, maxFreq=1000;
- var sig, freqNoise, ampNoise;
- ampNoise = LFNoise0.kr(ampCtrl).exprange(minAmp, maxAmp);
- freqNoise = LFNoise0.kr(freqCtrl).range(minFreq, maxFreq);
- sig = SinOsc.ar(freqNoise, 0, ampNoise)!2;
- }.play;
- )
- ~myAmp.set(\ampCtrl, rrand(1, 4), \freqCtrl, rrand(4, 8));
- ~myAmp.set(\minAmp, rrand(0.01, 0.01), \maxAmp, rrand(0.1, 0.3));
- ~myAmp.set(\minFreq, rrand(100, 1000), \maxFreq, rrand(1000, 3000));
- ~myAmp.free;
- // Let's play with other UGens for the same amplitude modulator, starting with this model below.
- //////////////////////////////////////////////////////////////////////////////
- // Plot the different control UGens to see the cycles' default phase.
- {SinOsc.ar(10)}.plot(1);
- {LFSaw.ar(10)}.plot(1);
- {LFTri.ar(10)}.plot(1);
- {LFPar.ar(10)}.plot(1);
- {LFCub.ar(10)}.plot(1);
- {LFPulse.ar(10)}.plot(1);
- {Saw.ar(10)}.plot(1); // there's no phase argument.
- {Pulse.ar(10)}.plot(1); // don't forget the width argument!
- {VarSaw.ar(10)}.plot(1); // there's a phase AND width argument!
- {[SinOsc.ar(10), LFSaw.ar(10)]}.plot(1);
- {[SinOsc.ar(10), LFTri.ar(10)]}.plot(1);
- {[SinOsc.ar(10), LFPar.ar(10)]}.plot(1); // NOTE: LFPar.ar(10) is SinOsc.ar(10, pi/2)
- {[SinOsc.ar(10), LFCub.ar(10)]}.plot(1); // Default phase value creates the same result.
- {[SinOsc.ar(10), LFPulse.ar(10, width: 0.5, mul: 2, add: -1)]}.plot(1); // Try Lag UGen for this.
- {[SinOsc.ar(10), VarSaw.ar(10)]}.plot(1);
- // Mix and match. Don't forget to change the phase values.
- // Phase value types (refer to the Pink Noise doc): 0, pi, 3pi/2, pi/2
- // Mul and add values will help keep the bipolarity (-1 to 1, crossing 0).
- {[LFPar.ar(10), LFCub.ar(10)]}.plot(1);
- {[LFTri.ar(10), LFSaw.ar(10)]}.plot(1);
- {[LFSaw.ar(10), VarSaw.ar(10)]}.plot(1);
- {[LFTri.ar(10), VarSaw.ar(10)]}.plot(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement