yeah itās a definite pain point.
once you have a 2^N-sample soundfile, itās doable. but it is pretty silly:
s = Server.default;
s.waitForBoot { Routine {
// path to some mono buffer
~path = "/home/emb/snd/AKWF-FREE/AKWF/AKWF_vgame/AKWF_vgame_0134.wav";
// allocate memory on the server and fill it from the file
~buf = Buffer.read(s, ~path);
s.sync;
{ ~buf.plot; }.defer;
// stream the buffer to a FloatArray in the client using multiple `getn` messages
// this is async, so the array is returned in a callback!
~buf.getToFloatArray(action: { arg arr;
// serious gotcha: wavetables must be a power of two!
// the only way to deal with this is with resampling...
// (would be nice if Signal had an in-place resampling method!)
// for now, this waveform will have silence at the end! so it's not good.
~size= arr.size.nextPowerOfTwo;
~size.postln;
~sig = Signal.newClear(~size);
arr.do({|val, idx| ~sig[idx] = val; });
// finally, convert to wrapped value-delta form for `Osc` &c...
~wt = ~sig.asWavetable;
//... and stream it back to the server!
Buffer.loadCollection(s, ~wt, action: {
arg wtbuf;
// notice that this is now weird looking
{ wtbuf.plot; }.defer;
/// now you can finally do stuff with `wtbuf`
});
});
}.play; };
one nice thing: in looking at Signal helpfile i found that the class includes in-place fft and ifft methods! so brickwall filtering for a multisampled synth could easily be done right there.
anyways, i think this proposed tool will help. it would take a soundfile of arbitrary length and end with another soundfile resampled to 2^N, and i guess already converted to SCās wavetable format, so it can just be loaded directly to a Buffer on the server side. (itās totally weird that SCās Buffer canāt do the conversion directly and the data has to be streamed twice.)