Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////// Dynamic Amplitude, Part 4 //////////////////////////
- // You can find a YouTube demonstration here: https://youtu.be/D4klks4sbwU
- s.boot;
- s.meter;
- s.scope;
- s.plotTree;
- s.reboot;
- s.quit;
- // Drum Loop (Or Any Sound File)
- ~drums = Buffer.read(s, "insertdrumloophere"); // (Or any other kind of sound file.)
- // I use "~drums" for my drum loop file, but you can use any name with "~".
- ~drums.play;
- ~drums.free; // Be sure to free synths as much as possible to free up CPU.
- ~drums.duration; // If you would like to see the sound file's duration.
- ~drums.numChannels; // If you would like to see how many channels it has.
- // Explore loopNode
- // Release node is node 2. Loop node is node 0.
- // So it loops around nodes 0 (levels 0 to 1, dur 4) and 1 (levels 1 to 0.1, dur 0.5) until released after 12 seconds.
- (
- Env([0, 1, 0.1, 0] * 0.25,
- // This mono sine tone may be high in volume.
- // Scale it back by a value, like 0.25 (25% the given amplitude)
- [4, 0.5, 2],
- 'lin',
- 2,
- 0
- ).test(10).plot; // I chose a value of 10, as my drum loop for this demo is 10 seconds.
- )
- // Here's a different way of writing it.
- (
- Env(
- [0, 1, 0.1, 0] * 0.25,
- [1, 0.1, 2],
- // Notice my first two time levels are shorter. This is more effective for my own drums. Explore different values for different sound files.
- 'linear',
- 2,
- loopNode: 0
- ).test(10).plot
- )
- //////////// Apply To Drum Loop ////////////
- (
- ~tortoDrums = SynthDef(\play, {
- arg amp=1, atk=1, sus=0.1, rel=2, buf=0, rate=1,
- spos=0, pan=0, out=0;
- var sig, env;
- env = Env(
- [0, 1, 0.1, 0],
- [atk, sus, rel],
- curve: 'linear',
- releaseNode: 2,
- loopNode: 0
- ).kr(2);
- sig = PlayBuf.ar(
- 2,
- buf,
- BufRateScale.ir(buf) * rate,
- spos
- );
- sig = sig * env;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~tortoDrums = Synth(\play, [\buf, ~drums]);
- ~tortoDrums.free; // Free the synth if you don't have an Env or doneAction value.
- (
- Env(
- [0, 1, 0.2, 0.3, 0] * 0.25, // Be sure to use low amplitude for this test.
- [2, 3, 1, 4] * 0.25, // Here's quick way to shorten time levels.
- 8, // Explore both positive and negative values for different effects.
- releaseNode: 2,
- loopNode: 0
- ).test(10).plot;
- )
- (
- ~tortoDrums = SynthDef(\play, {
- arg amp=1, atk=2, sus=3, decay=1, rel=4,
- buf=0, rate=1, spos=0, pan=0, out=0;
- var sig, env;
- env = Env(
- [0, 0.3, 0.2, 1, 0] * 0.75,
- // Use a multiplier less than 1 for a lower output (if necessary).
- [atk, sus, decay, rel] * 0.25,
- 8, // Always explore different curve values!
- releaseNode: 3
- ).kr(2);
- sig = PlayBuf.ar(
- 2,
- buf,
- rate: BufRateScale.ir(buf) * rate,
- startPos: spos
- );
- sig = sig * env;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~tortoDrums = Synth(\play, [\buf, ~drums]);
- ~tortoDrums.free; // Free the synth if you don't have an Env or doneAction value.
- (
- Env(
- [0, 1, 0.01, 0.5, 0.05, 0.8, 0] * 0.25,
- [1, 1, 1, 1, 1, 1],
- 2,
- releaseNode: 3,
- loopNode: 1
- ).test(10).plot;
- )
- // If you like arguments spelled out...
- (
- ~tortoDrums = SynthDef(\play, {
- arg atk=1, sus1=3, sus2=1, sus3=1, decay=1, rel=1,
- buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
- var sig, env;
- env = Env(
- [0, 1, 0.01, 0.5, 0.05, 0.8, 0],
- [atk, sus1, sus2, sus3, decay, rel],
- 5,
- releaseNode: 3,
- loopNode: 1,
- ).kr(2);
- sig = PlayBuf.ar(
- numChannels: 2,
- bufnum: buf,
- rate: BufRateScale.ir(buf),
- startPos: spos
- );
- sig = sig * env;
- pan = Pan2.ar(sig, pan, amp);
- Out.ar(out, sig);
- }).add;
- )
- ~tortoDrums = Synth(\play, [\buf, ~drums]);
- ~tortoDrums.free; // Free the synth if you don't have an Env or doneAction value.
- // To release the synth with a doneAction value, you need one in the PlayBuf.
- // The Envelope in this scenario is for the amplitude. It does not release the synth.
- // For a further explanation, stay tuned for Part 5.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement