work with mark: supercollider sampler

for my work together with mark d'inverno i coded a few tools. one of the things that came up was a need for a neutral but nice sounding way to test aspects of our musical agents systems. so we got hold of a grand-piano sample library and i wrote a 'giga sampler' like class for supercollider. this allowed us to use this massive sample library (2.5gig) and let the agents play high quality samples instead of cheap midi or boring synthesised sounds. so for testing melodies, harmonies and such this was a good thing.

the trick with the giga sampler is that it preloads a bit from each soundfile into ram memory and then streams the rest from disk when needed. or at least this is how i understands it. so using this technique, one can get quick access to a lot more samples than normally would fit in the memory of a sampler. a massive library like ours with full 88keys range, sampled in many different velocities, would occupy ~5gig of ram (supercollider uses 32bit internally), nor could it be streamed from disk (the harddrive would be too slow to access and load the headers to play fast chords progressions without staggering etc).

i spent some time to make my class all round useful and it can be downloaded _here. it is called RedDiskInSampler.

and here is some testcode for it...

d= ();                                          /*for mapping midinote to filename*/
r= RedDiskInSamplerGiga(s);             /*sampler*/
var velocities= #[40, 96];              /*velocities to load*/
var octavesToLoad= #[2, 3];             /*how many octaves to load*/
var scale= #['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
/*so number of samples to load is octavesToLoad.size*12*velocities.size*/
/*lowest note C2= midi 36*/{|x, i|
        var tempDict= ();
        d.put(x, tempDict);{|y, j|
      {|z, k|
                        var midinote, pathname, key;
                        midinote= y*12+12+k;
                        key= z++y;
                        pathname= "sounds/bosen44100/"++x++"/"++key++".aif";
                        key= (key++"_"++x).asSymbol;
                        tempDict.put(midinote, key);            /*like (45 : A2_96)*/
                        r.preload(key, pathname);
)\C2_96, 0, 3, 1)\D2_40, 0, 3, 1)
a= r.loadedKeys;
(Tdef(\test, {{|i|
      , 0, 0.45, 0.1);
(Tdef(\test, {
        b= a.asArray.scramble;{|i|
      {|x, j|
              , 0, 0.35, 0.1);
(Tdef(\test, {
        b= a.asArray.sort;{|i|
      {|x, j|
              , 0, 0.25, 0.08, amp: 0.6);