Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////// Dynamic Amplitude, Part 2 //////////////////////////
- s.boot;
- s.meter;
- s.scope;
- s.plotTree;
- s.reboot;
- s.quit;
- (
- ~triAmp = {
- var sig;
- sig = LFTri.ar(300, 0, 0.01)!2;
- }.play;
- )
- ~triAmp.free;
- // Adding arguments.
- (
- ~triAmp = {
- arg freq=300, amp=0.03;
- var sig;
- sig = LFTri.ar(freq, 0, amp)!2;
- }.play;
- )
- ~triAmp.free;
- // Adding variables to control the frequency modulation in the sawtooth wave.
- (
- ~triAmp = {
- arg freq=300, amp=0.03;
- var sig, freqNoise;
- freqNoise = LFNoise0.kr(8).range(100, 1000);
- sig = LFTri.ar(freqNoise, 0, amp)!2;
- }.play;
- )
- ~triAmp.free;
- // Add another variable for amplitude modulation.
- (
- ~triAmp = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.3);
- freqNoise = LFNoise0.kr(noise).range(100, 1000);
- sig = LFTri.ar(freqNoise, 0, modAmp)!2;
- }.play
- )
- ~triAmp.set(\sine, 1/8);
- ~triAmp.set(\noise, 9);
- ~triAmp.free;
- (
- ~triAmp = {
- arg sine=1, noise=4, modMin=0.001, modMax=0.3,
- freqMin=100, freqMax=1000;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(modMin, modMax);
- freqNoise = LFNoise0.kr(noise).range(freqMin, freqMax);
- sig = LFTri.ar(freqNoise, 0, modAmp)!2;
- }.play
- )
- ~triAmp.set(\sine, 1/4);
- ~triAmp.set(\noise, 18);
- ~triAmp.set(\modMin, 0.01);
- ~triAmp.set(\modMax, 0.2);
- ~triAmp.free;
- // CAUTION: Be very careful using an amplitude modulator using things other than SinOsc. Pulse.ar, for example, stacks amplitude instances one after the other when you use a width modulation.
- // Same with Saw.
- // SinOsc
- (
- ~sineAmp = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = SinOsc.ar(freqNoise, 0, modAmp)!2;
- }.play
- )
- ~sineAmp.set(\sine, 6);
- ~sineAmp.set(\noise, 2);
- ~sineAmp.free;
- // LFSaw
- (
- ~sawAmp = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = LFSaw.ar(freqNoise, 0, modAmp)!2;
- }.play
- )
- ~sawAmp.set(\sine, 1/8);
- ~sawAmp.set(\noise, 7);
- ~sawAmp.free;
- // LFTri
- (
- ~triAmp = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = LFTri.ar(freqNoise, 0, modAmp)!2;
- }.play
- )
- ~triAmp.set(\sine, 8);
- ~triAmp.set(\noise, 20);
- ~triAmp.free;
- // LFPar
- (
- ~parAmp = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = LFPar.ar(freqNoise, 0, modAmp)!2;
- }.play
- )
- ~parAmp.set(\sine, 1/4);
- ~parAmp.set(\noise, 12);
- ~parAmp.free;
- // Pulse
- (
- ~pulseTest = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = Pulse.ar(freqNoise, 0.5, modAmp)!2;
- }.play
- )
- ~pulseTest.set(\sine, 1/8);
- ~pulseTest.set(\noise, 1);
- ~pulseTest.free;
- // LFPulse
- (
- ~pulseAmp = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = LFPulse.ar(freqNoise, 0, 0.5, modAmp)!2;
- }.play
- )
- ~pulseAmp.set(\sine, 8);
- ~pulseAmp.set(\noise, 20);
- ~pulseAmp.free;
- // LFCub
- (
- ~cubAmp = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = LFCub.ar(freqNoise, 0, modAmp)!2;
- }.play
- )
- ~cubAmp.set(\sine, 12);
- ~cubAmp.set(\noise, 1);
- ~cubAmp.free;
- // Saw
- (
- ~sawTest = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = Saw.ar(freqNoise, modAmp)!2;
- }.play
- )
- ~sawTest.set(\sine, 8);
- ~sawTest.set(\noise, 1/2);
- ~sawTest.free;
- // VarSaw
- (
- ~varAmp = {
- arg sine=1, noise=4;
- var sig, freqNoise, modAmp;
- modAmp = SinOsc.kr(sine).exprange(0.001, 0.1);
- freqNoise = SinOsc.kr(noise).range(100, 1000);
- sig = VarSaw.ar(freqNoise, 0, 0.5, modAmp)!2; // Don't forget the width argument!
- }.play
- )
- ~varAmp.set(\sine, 1/2);
- ~varAmp.set(\noise, 1/16);
- ~varAmp.free;
- // Apply this to noise.
- (
- ~pinkNoise = {
- arg freq=0.25, amp=0.2;
- var sig, mod;
- mod = SinOsc.ar(freq: freq, phase: pi, mul: 0.5, add: 0.5);
- sig = PinkNoise.ar(amp)!2; // Go between PinkNoise and BrownNoise.
- sig = sig * mod;
- };
- )
- x = ~pinkNoise.play;
- x.release(8);
- (
- ~pinkNoiseCtrl = {
- arg sine=4, amp=1;
- var sig, modAmp;
- modAmp = LFPar.kr(sine).exprange(0.001, 0.1);
- // Change waveform (e.g, LFTri, LFSaw, etc.)
- sig = PinkNoise.ar(amp)!2;
- sig = sig * modAmp;
- }.play
- )
- ~pinkNoiseCtrl.set(\sine, 3);
- ~pinkNoiseCtrl.free;
- // Add Sound File
- ~ice = Buffer.read(s, "insertaudiofilehere");
- // My original audio file is an icy synth. Hence the name ~ice.
- // You can name a sound anything with "~".
- ~ice.play;
- ~ice.free;
- ~ice.duration;
- ~ice.numChannels;
- // Play Synth
- (
- ~ice = SynthDef.new(\play, {
- arg amp=1, atk=0.001, rel=3, c1=1, c2(-1),
- buf=0, rate=1, spos=0, pan=0, out=0;
- var sig, env;
- env = Env([0, 1, 0], [atk, rel], [c1, c2]).kr(2);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf),
- spos
- );
- sig = sig * env;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~ice.play;
- // Replace the Envelope variable with a modulator.
- // SinOsc
- (
- ~iceSine = SynthDef.new(\play, {
- arg sine=1, minAmp=0.001, maxAmp=1,
- buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
- var sig, modAmp;
- modAmp = SinOsc.kr(sine).exprange(minAmp, maxAmp);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf),
- spos
- );
- sig = sig * modAmp;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~iceSine = Synth(\play, [\buf, ~ice]);
- ~iceSine.set(\sine, 1/4);
- ~iceSine.free;
- // Saw (I like this one!)
- (
- ~iceSaw = SynthDef.new(\play, {
- arg saw=1, minAmp=0.001, maxAmp=1,
- buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
- var sig, modAmp;
- modAmp = Saw.kr(saw).exprange(minAmp, maxAmp);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf),
- spos
- );
- sig = sig * modAmp;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~iceSaw = Synth(\play, [\buf, ~ice]);
- ~iceSaw.set(\saw, 15);
- ~iceSaw.free;
- // LFSaw
- (
- ~iceLFSaw = SynthDef.new(\play, {
- arg lowSaw=1, minAmp=0.001, maxAmp=0.8,
- buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
- var sig, modAmp;
- modAmp = LFSaw.kr(lowSaw).exprange(minAmp, maxAmp);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf),
- spos
- );
- sig = sig * modAmp;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~iceLFSaw = Synth(\play, [\buf, ~ice]);
- ~iceLFSaw.set(\lowSaw, 32);
- ~iceLFSaw.free;
- // LFTri
- (
- ~iceTri = SynthDef.new(\play, {
- arg tri=1, minAmp=0.001, maxAmp=0.8,
- buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
- var sig, modAmp;
- modAmp = LFTri.kr(tri).exprange(minAmp, maxAmp);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf),
- spos
- );
- sig = sig * modAmp;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~iceTri = Synth(\play, [\buf, ~ice]);
- ~iceTri.set(\tri, 8);
- ~iceTri.free;
- // LFCub
- (
- ~iceCube = SynthDef.new(\play, {
- arg cube=1, minAmp=0.001, maxAmp=0.8,
- buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
- var sig, modAmp;
- modAmp = LFCub.kr(cube).exprange(minAmp, maxAmp);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf),
- spos
- );
- sig = sig * modAmp;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~iceCube = Synth(\play, [\buf, ~ice]);
- ~iceCube.set(\cube, 2);
- ~iceCube.free;
- // VarSaw
- (
- ~iceVarSaw = SynthDef.new(\play, {
- arg varSaw=1, minAmp=0.001, maxAmp=0.8,
- buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
- var sig, modAmp;
- modAmp = VarSaw.kr(varSaw).exprange(minAmp, maxAmp);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf),
- spos
- );
- sig = sig * modAmp;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~iceVarSaw = Synth(\play, [\buf, ~ice]);
- ~iceVarSaw.set(\varSaw, 1/16);
- ~iceVarSaw.free;
- // LFPulse
- (
- ~icePulse = SynthDef.new(\play, {
- arg pulse=1, minAmp=0.001, maxAmp=0.1,
- buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
- var sig, modAmp;
- modAmp = LFPulse.kr(pulse).exprange(minAmp, maxAmp);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf),
- spos
- );
- sig = sig * modAmp;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~icePulse = Synth(\play, [\buf, ~ice]);
- ~icePulse.set(\pulse, 4); // an idea for bypassing?
- ~icePulse.free;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement