# Using functions to create wavetables for VOsc

Hi everyone,

I’m trying to use VOsc to sweep between 2 wavetables. Here I’m trying to do a sine & a square. What am I doing wrong? Neither are sines or squares. I’d like to be able to define whats in the wavetable using a func like below.

(
{
b = Buffer.allocConsecutive(2, s, 1024, 1, {});
0.1.wait;

``````b[0].setn(0, {|n| n.linlin(0,1024,0,2pi).sin } ! 1024 ); // my sine
b[1].setn(0, {|n| (n<512).if(1,-1)           } ! 1024 ); // my square

SynthDef("help-VOsc",{|out=0, bufnum|
var x = MouseX.kr(0,1);
Out.ar(out,
VOsc.ar(bufnum + x, 120, 0, 0.3).dup
)
}).play(s,[\out, 0, \bufnum, b[0].bufnum ]);
``````

}.fork
)

regards
Neil

``````(
{
b = Buffer.allocConsecutive(2, s, 1024, 1, {});
0.1.wait;

b[0].setn(0, Signal.fill(512, { |n| n.linlin(0,512,0,2pi).sin }).asWavetable ); // my sine
b[1].setn(0, Signal.fill(512, { |n| (n<256).if(1,-1)          }).asWavetable ); // my square

SynthDef("help-VOsc",{|out=0, bufnum|
var x = MouseX.kr(0,0.999);  // should be 0 <= x < numbufs
Out.ar(out,
VOsc.ar(bufnum + x, 120, 0, 0.3).dup
)
}).play(s,[\out, 0, \bufnum, b[0].bufnum ]);
}.fork
)
``````

hjh

1 Like