Osc interpolating wavetable oscillator


Osc.ar(table, freq, phase, mul, add)


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 acheived by creating a Buffer object and sending it one of the "b_gen" messages ( sine1, sine2, sine3 ) with the wavetable flag set to true.  


This can also be acheived by creating a Signal object and sending it the 'asWavetable' message, saving it to disk, and having the server load it from there.


table - buffer index

freq - frequency in Hertz

phase - phase offset or modulator in radians


note about wavetables:

OscN requires the b_gen sine1 wavetable flag to be OFF.

Osc requires the b_gen sine1 wavetable flag to be ON.


(

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]);

)


(

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]);

)



(

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]);

)



(

// 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]);

)




(

// 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]);

)


(

fork {

var n = 32;

50.do {

b.sine1(Array.rand(n,0,1).cubed, true, true, true);

0.25.wait;

};

};

)