I'm working on a simple Supercollider patch (my first), designed to swap samples in a file to get a stuttering, granular synthesis sort of sound.
What I'm trying to do is make a new audio file that's the length of the input file. It should run a loop that will swap the place of samples in a file with the sample at the scrambled indexes.
I haven't been able to find a way to get it to compile and write an audio file.
var indexa, indexb, frames, count, j, aa, ab;
j = 0;
s.boot;
b = Buffer.read(s, "/Users/admin/Desktop/10counter.aiff"); //my test file
"Frames: " + b.numFrames.postln;
"Channels: " + b.numChannels.postln;
count = b.numFrames * b.numChannels;
"Count: " + count.postln;
b.write("/Users/admin/Desktop/rbs.aiff", "aiff", "int16", 0, 0, true);
opCount.do ({
temp1 = Buffer.alloc(s, 1, 2);
temp2 = Buffer.alloc(s, 1, 2);
aa = Array.fill(frames, {arg i; i});
ab = a1.scramble;
})
//do the swaps
{j < count}.while ({
indexa = aa[j];
indexb = ab[j];
temp1 = b.get(indexa);
temp2 = b.get(indexb);
b.set(indexb, temp1);
b.set(indexa, temp2);
j.increment;
})
//write to file here?
b.close;