Buffer, files and wavetables

New to SC I am trying to get a grip on the language.
My objective is to create a wavetable synth loading the wavetables from files ( single cycle adventure kid wavetables) .

I am struggling with this little piece of code adapted from there : https://gist.github.com/xavriley/ce1becd7f2d97d93aced74e88ae7ba54

NB : all single cycle wav file have been turned into wavetables (see link above) and saved to disk.
When loading the wavetables into buffers one by one, this works but the following routine does not.

~myPath = PathName.new("/home/pi/SuperCollider_JM/WavTableSelection/");

b= Buffer.allocConsecutive(64,s,2048,1,{
	var i;
	i = idx;
	("/home/pi/SuperCollider_JM/WavTableSelection/" ++ ~myPath.entries[idx].fileName).postln;
	buf.read("/home/pi/SuperCollider_JM/WavTableSelection/" ++ ~myPath.entries[idx].fileName);

a = { VOsc.ar(SinOsc.kr(0.5, 0).range(b.first.bufnum + 0.1, b.last.bufnum - 0.1),
    220, 0, 0.2) }.play;

Could someone explain me why ? and show me how it should be?

Many thanks for your help

1 Like

It’s subtle: here, it should be buf.readMsg and not buf.read.

The function argument to allocConsecutive should return a message, but not perform the message.


Thank you a lot! This works like charm now.