Wavetable files index - Playbuf

Simple question, I have a folder with 36 .wav files in wavetable format, I just want to be able to choose wich one I want to play with PlayBuf. ( note: i am using an already made piece of code of pulsar synthesis that use PlayBuf, I don’t want to use VOsc ). So far I get

~myPath = PathName.new("mywavetablefolder");

b= Buffer.allocConsecutive(36,s,2048,1,{
	var i;
	i = idx;
	("mywavetablefolder" ++ ~myPath.entries[idx].fileName).postln;
	buf.readMsg("mywavetablefolder" ++ ~myPath.entries[idx].fileName);

Everything seems to be loaded properly in the post window.
And then, I just would like to know the syntax for let’s say, call the 7th wave of the folder

a = { PlayBuf.ar(1,...?)}.play;

I know it should be simple, sorry :wink:


You’ll need to simply add the buffer name (b) and a file/wavetable number. It should look something like this:

a = {PlayBuf.ar(1, b[0])}.play; // Add your buffer number you want to hear.

Since I’m not sure what’s in your wavetable folder, you might need to add in a rate and a trigger to hear something (if the file is very short, you’d just a get a ‘click’ without the re-triggering):

a = {PlayBuf.ar(1, b[0], rate:1, trigger:SinOsc.kr(440))}.play;

After that, you might want to build a synthdef so you can change the buffer numbers without retyping.

1 Like

That’s it, thanks Joesh