| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 
 | class:: Osc
summary:: Interpolating wavetable oscillator.
related:: Classes/COsc, Classes/OscN, Classes/VOsc, Classes/VOsc3, Classes/Wavetable
categories::  UGens>Generators>Deterministic
Description::
Linear interpolating wavetable lookup oscillator with frequency and
phase modulation inputs.
This oscillator requires a buffer to be filled with a wavetable format
signal. This preprocesses the Signal into a form which can be used
efficiently by the Oscillator. The buffer size must be a power of 2.
This can be achieved by creating a Buffer object and sending it one of
the "b_gen" messages ( link::Classes/Buffer#-sine1::, link::Classes/Buffer#-sine2::, link::Classes/Buffer#-sine3:: ) with the wavetable flag set
to true.
This can also be achieved by creating a link::Classes/Signal:: object and sending it
the 'asWavetable' message, thereby creating a Wavetable object in the required format. Then, the wavetable data may be transmitted to the server using the link::Classes/Buffer#*sendCollection:: or link::Classes/Buffer#*loadCollection:: methods.
classmethods::
method::ar, kr
argument::bufnum
Buffer index.
argument::freq
Frequency in Hertz.
argument::phase
Phase offset or modulator in radians.
(Note: phase values should be within the range +-8pi. If your phase values are larger then simply use code::.mod(2pi):: to wrap them.)
argument::mul
Output will be multiplied by this value.
argument::add
This value will be added to the output.
Examples::
code::
(
s = Server.local;
b = Buffer.alloc(s, 512, 1);
b.sine1(1.0/[1,2,3,4,5,6], true, true, true);
SynthDef("help-Osc",{ arg out=0,bufnum=0;
	Out.ar(out,
		Osc.ar(bufnum, 200, 0, 0.5)
	)
}).play(s,[\out, 0, \bufnum, b.bufnum]);
)
(
s = Server.local;
b = Buffer.alloc(s, 512, 1);
b.sine1(1.0/[1,2,3,4,5,6], true, true, true);
SynthDef("help-Osc",{ arg out=0,bufnum=0;
	Out.ar(out,
		Osc.ar(bufnum, XLine.kr(2000,200), 0, 0.5)// modulate freq
	)
}).play(s,[\out, 0, \bufnum, b.bufnum]);
)
(
s = Server.local;
b = Buffer.alloc(s, 512, 1);
b.sine1([1.0], true, true, true);
SynthDef("help-Osc",{ arg out=0,bufnum=0;
	Out.ar(out,
		Osc.ar(bufnum,
			Osc.ar(bufnum,
				XLine.kr(1,1000,9),
				0,
				200,
				800),
			0,
			0.25)
	)
}).play(s,[\out, 0, \bufnum, b.bufnum]);
)
(
// modulate phase
s = Server.local;
b = Buffer.alloc(s, 512, 1);
b.sine1([1.0], true, true, true);
SynthDef("help-Osc",{ arg out=0,bufnum=0;
	Out.ar(out,
		Osc.ar(bufnum,
				800,
				Osc.ar(bufnum,
						XLine.kr(20,8000,10),
						0,
						2pi),
				0.25)
	)
}).play(s,[\out, 0, \bufnum, b.bufnum]);
)
(
// change the buffer while its playing
s = Server.local;
b = Buffer.alloc(s, 4096, 1);
b.sine1(1.0/[1,2,3,4,5,6], true, true, true);
SynthDef("help-Osc",{ arg out=0,bufnum=0;
	Out.ar(out,
		Osc.ar(bufnum, [80,80.2], 0, 0.2)
	)
}).play(s,[\out, 0, \bufnum, b.bufnum]);
)
(
fork {
	var n = 32;
	50.do {
		b.sine1(Array.rand(n,0,1).cubed, true, true, true);
		0.25.wait;
	};
};
)
::
 |