Last active
December 31, 2015 14:49
-
-
Save iani/8002967 to your computer and use it in GitHub Desktop.
Notes about using buffers and about SynthDefs, in SuperCollider.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Session of Tue Dec 17 12:33:56 2013 | |
| // Loading buffers | |
| Server.default.boot; | |
| //: Test how to open a dialog window for choosing the path of the buffer to load: | |
| // Here we just post the path. | |
| Dialog.openPanel({ | path | | |
| path.postln; | |
| }) | |
| //: Next step: Load the chosen audio file into a buffer. | |
| Dialog.openPanel({ | path | | |
| Server.default.waitForBoot({ // optional: Just making sure that the buffer is running | |
| ~buffer = Buffer.read(Server.default, path); | |
| ~buffer.postln; | |
| }) | |
| }) | |
| //: Listen to the buffer | |
| ~synth = ~buffer.play; | |
| //: When we want to stop the buffer playing, we can do this: | |
| ~synth.free; | |
| //: Play the buffer, but adding rate and amp control: | |
| ~synth = { | rate = 1, amp = 1 | | |
| PlayBuf.ar(1, ~buffer, rate, loop: 1) * amp; | |
| }.play; | |
| //: Try changing the rate: | |
| ~synth.set(\rate, 10); | |
| //: Add continuous control to the rate via a bus. | |
| ~rate = Bus.control; | |
| ~rate.set(1); // set the value to 1 before binding to rate | |
| //: Connect the bus to the control input \rate of the synth | |
| ~synth.map(\rate, ~rate.index); // back to rate 1; | |
| //: Modify the bus value through another synth. | |
| ~mouseX = { Out.kr(~rate.index, MouseX.kr(-10, 10)) }.play; | |
| //: Do the same with amplitude: Connect to a bus | |
| // First create the bus | |
| ~amp = Bus.control; | |
| ~amp.set(1); | |
| //: Then connect the amp bus to the amp control input of synth | |
| ~synth.map(\amp, ~amp.index); | |
| //: Create a synth to control the amp via the bus | |
| ~mouseY = { Out.kr(~amp.index, MouseY.kr(0, 3)) }.play; | |
| //: unmap the amp and quieten the synth | |
| ~synth.set(\amp, 0.1); | |
| //: make the sound louder - we want to try out some things | |
| ~synth.set(\amp, 2); | |
| //: Stop mouseX input | |
| ~mouseX.free; | |
| //: Control rate with a synth | |
| ~rate.set(1); // re-initialize rate bus first; | |
| ~synth.map(\rate, ~rate.index); | |
| //: Start the synth that will control the rate; | |
| ~sinRate = { | freq = 0.1, lo = -10, hi = 10 | | |
| Out.kr(~rate.index, SinOsc.kr(freq).range(lo, hi)); | |
| }.play; | |
| //: Make the rate of change of the rate modulation smaller | |
| ~sinRate.set(\freq, 0.025); | |
| //: Add more variation to the rate modulation with another synth | |
| ~jitterRate = { | freq = 10, lo = -0.1, hi = 0.1 | | |
| Out.kr(~rate.index, LFNoise0.kr(freq).range(lo, hi)); | |
| }.play; | |
| //: Can you hear the jitter? | |
| ~jitterRate.set(\lo, -1, \hi, 1); | |
| ~jitterRate.set(\freq, 20); | |
| //: | |
| ~synth.set(\amp, 5); | |
| //: keep the buffer playing only forwards | |
| ~sinRate.set(\lo, 0.1, \hi, 5); | |
| ////////////////////////////////////////////// | |
| /* | |
| End of version 1 | |
| The next version will introduce control of the looping positions. | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment