View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

Cottle Chapter 11 - Time Variant Control Sources, Offset and Scaling with Mul and Add

Home   How To   Code Pool   Public Library   Theory   Events
[Cottle examples]

11. Time Variant Control Sources, Offset and Scaling with Mul and Add


//11.1 add and mul; offset and scale

// No plot examples!
// see the text for the examples and plots

//11.2 confusing; mul: 300, add: 100, range: 200 to 400

//11.3 less confusing?

// here I am correcting an error in Cottle's code.
// It is not necessary to do (h - l) / 2 + l
// (h - l) / 2 + l = (h - l + (2*l)) / 2 = (h + l) / 2
// Fewer operators, faster operation.

//var low, high;
//low = 200;
//high = 400;
//{SinOsc.ar(mul: (high - low)/2, add: (high + low)/2 )}.scope;

// If you do it this way, bear in mind that if high and low are constants as here,
// the arithmetic will be done when the synthdef is compiled, resulting in the bare
// minimum number of UGens. If they're synth arguments or other UGens,
// each math operation will result in a BinaryOpUGen, which takes server time
// to calculate. BinaryOpUGens are pretty fast but not cost-free. This is why
// for static values, it's better to calculate them on the client side and pass them
// already calculated into synth args.

// 11.4 SinOsc as vibrato

// Cottle says to use audio rate for the SinOsc as frequency control, but 
// this wastes processor cycles.
// LFO's can almost always be .kr (control rate), so I change it here.

SinOsc.kr(freq: 5, mul: 5, add: 440)

//11.5 vibrato

s = Server.internal.boot;

(
{	var vibrato;
	vibrato = SinOsc.kr(freq: 5, mul: 5, add: 440);
	SinOsc.ar(vibrato, mul: 0.5)
}.scope;
)

//11.6 Line.kr

//Vibrato
(
{
var vibrato;
vibrato = 	SinOsc.kr(freq: 5, 	mul: Line.kr(0, 5, 3), add: 440); 
SinOsc.ar(
	vibrato, 
	mul: 0.5)
}.scope
)


Link to this Page