Friday, December 12, 2014

Some Notes for Students Today

Note: This is literally for some students I have today. It will appear on Moodle some time soon and then disappear from this space.


/*

Extra Things!



Q: How do you make a Pmono stop?

A: A Pmono stops when it runs out of values, to send, just like a Pbind. However, unless we tell a synth to stop, it will keep going forever.



Q: How do you tell a synth to stop?

A: Envelopes!  We've seen this already with fixed duration envelopes. But if we don't know from the start how long we want the synth to go for, when need to use a different kind of envelope.

For example, and ASR.

ASR stands for 'attack, sustain, release and is a very common envelope in electronic music.  It uses a 'gate' to know when to start and stop. When the gate is 1, the envelope starts doing the attack, then it sustains indefinitely. As soon as the gate changes to 0, it immeditately stops whaever its doing to do the release portion.

Ex:

*/
(
SynthDef(\blipGate, {|freq, amp, gate=1, pan|  // the vertical bars are equvalent to using the keyword arg
 var blip, panner, env;
 blip = Blip.ar(freq, 10, 0.2);
 env = EnvGen.kr(Env.asr, gate, doneAction:2); // look at the helpfile for Env for more
 panner = Pan2.ar(blip, pan, env);
 Out.ar(0, panner * amp);
}).add
)

(
Pmono(
 \blipGate,
 \pan, Pwhite(0.0, 1.0, 5),
 \degree, Pwhite(1, 4, 5)
).play
)


// gates also work with Pbinds

(
Pbind(
 \instrument, \blipGate,
 \pan, Pwhite(0.0, 1.0, 5),
 \degree, Pwhite(1, 4, 5)
).play
)

/*

Q: How can I make frequency changes less abrupt?

A:  Add in some lag:

*/

(
SynthDef(\blipLag, {|freq, amp, gate=1, pan|  // the vertical bars are equvalent to using the keyword arg
 var lag, blip, panner, env;
 lag = Lag.kr(freq);
 blip = Blip.ar(lag, 10, 0.2);
 env = EnvGen.kr(Env.asr, gate, doneAction:2); // look at the helpfile for Env for more
 panner = Pan2.ar(blip, pan, env);
 Out.ar(0, panner * amp);
}).add
)

(
Pmono(
 \blipLag,
 \pan, Pwhite(0.0, 1.0, 5),
 \degree, Pwhite(1, 4, 5)
).play
)




/*

Q: If you're live coding and want to change a pbind without stopping it, can you do that?

A: Yes, with Pdef

*/

(
Pdef(\blips,
 Pbind(
  \instrument, \blipGate,
  \pan, Pwhite(0.0, 1.0, inf),
  \degree, Pwhite(1, 4, inf),
  \dur, 0.4
 )
).play
)

// just put a Pdef around the pbind



// now, let's change without stopping

(
Pdef(\blips,
 Pbind(
  \instrument, \blipGate,
  \pan, Pwhite(0.0, 1.0, inf),
  \degree, Pwhite(1, 4, inf),
  \dur, Prand([0.4, 0.2, 0.2, 0.8], inf)
 )
).play
)


// another change

(
Pdef(\blips,
 Pbind(
  \instrument, \blipGate,
  \pan, Pwhite(0.0, 1.0, inf),
  \degree, Pwhite(1, 4, inf) * Pwhite(1, 2),
  \dur, Prand([0.4, 0.2, 0.2, 0.8], inf)
 )
).play
)



Pdef(\blips).fadeTime = 5; // tell it to fade changes in and out over 5 seconds

Pdef(\blips).stop; // tell it to stop (but don't stop anything else, including other Pdefs)


/*

Q: what are some good oscillators?

A:

SinOsc
Blip
Formant
Pulse
Saw
Klank

// look at the help files for those


Ok, now I want you folks to get to work making some sounds and patterns. I'll come around to answer questions, or you can pair up if you want.

*/



No comments: