SuperCollider CLASSES (extension)

BufferSystem

A System for Buffer Allocation
Inherits from: Radicles : Object

Description

A System for Buffer allocation and bookkeeping.

Class Methods

Inherited class methods

Undocumented class methods

*add (arg1, arg2, function)

*addAll (arr, path, function)

*addAllPaths (arr, path, function)

*addDir (path, function)

*addPairs (arr, function, readChansArr)

*addSubDirs (path, function)

*alloc (numFrames, numChannels, function)

*allocAll (argArr, function)

*arrDir

*bufAlloc

*bufferArray

*bufferByDir

*bufferCount

*bufferInfo

*bufferPaths

*cue (pathName, startFrame: 0, bufSize: 1, function)

*cueAll (arr, function)

*cueDir (path, startFrame: 0, bufSize: 1, function)

*defaultPath

*defaultPath = value

*dirDialog

*dirTags (path)

*fileNames

*fileNumChannels (path)

*free (tag)

*freeAll (tagArr)

*freeAt (index, action)

*freeAtAll (indexArr, action)

*get (tag)

*getFile (string)

*getFromPath (string)

*getGlobVar (buf)

*getGlobVarArr (bufArr)

*getPath (fileName: 'test', pathDir)

*globVarArray

*pathToTag (path)

*postWin

*postWin = value

*read (pathName, function, channels)

*readAll (pathArr, function, channelsArr)

*readDir (path, function, channelsArr)

*readSubDirs (path, function, readChansArr)

*setDefaultPath

*tags

Instance Methods

Inherited instance methods

Examples

s.boot;
//buffer alloc
//args: numFrames, numChannels, function
BufferSystem.add(44100*3, 2, {|item| item.numFrames.postln});

BufferSystem.add(44100*3, 2, {|item| item.numChannels.postln});

BufferSystem.tags.dopostln;

~path = "/Users/federicoreuben/Library/Application Support/SuperCollider/Extensions/Radicles/SoundFiles/Play/0/";

BufferSystem.dirTags(~path).dopostln; //find tags for files in this directory

//buffer read
//args: tag, path, function
BufferSystem.add('marilyn1', ~path, {|item| item.play});
BufferSystem.add('SinedPink', ~path, {|item| item.play});

BufferSystem.defaultPath;
BufferSystem.defaultPath = ~path; //assign this path to defaultPath

//no need to define path
BufferSystem.add('marilyn1', function: {|item| item.play});

//alloc all
BufferSystem.addAll([[1234,2], [2342, 1], [35424,1]], function: {|item| item.do{|buf| buf.numFrames.postln } });
//read all
BufferSystem.addAll(['marilyn1', 'SinedPink'], ~path, {|item| item.do{|buf| buf.play } });

//add in "pairs"
BufferSystem.addPairs(['marilyn1',~path, 'SinedPink',~path], {|item| item.do{|buf| buf.play } });
BufferSystem.addPairs([1234,2, 2342, 1, 35424,1], {|item| item.do{|buf| buf.numFrames.postln } });

//add any type
BufferSystem.addAll(['marilyn1', [1234,2], 'SinedPink'], ~path, function: {|item| a = item; });
a.postin(\ide, \doln);

(
BufferSystem.addAll([[35424,1], 'marilyn1', [1234,2], 'SinedPink',  [2342, 1]],
    ~path, {|item| a = item.postln});
)
a.postin(\ide, \doln);

//Info about buffers: [tag, numChannels, bufnum,    numFrames, sampleRate, path]
BufferSystem.bufferInfo.postin(\ide, \doln);

BufferSystem.tags;
BufferSystem.globVarArray;
BufferSystem.fileNames;

//get buffer with tag
BufferSystem.get(\marilyn1);
BufferSystem.get(\alloc0);
BufferSystem.get(\alloc3);
BufferSystem.get(\marilyn1).play;

//get getGlobVar with tag
BufferSystem.getGlobVar(BufferSystem.get(\marilyn1););
BufferSystem.getGlobVar(BufferSystem.get(\alloc0);).postln.interpret;

BufferSystem.getGlobVarArr(BufferSystem.bufferArray.copyRange(0,1));

//get buffer with fileName
BufferSystem.getFile("marilyn1.wav");

//array of buffers
BufferSystem.bufferArray.postin(\ide, \doln);
BufferSystem.tags
//free buffer by index
BufferSystem.freeAt(0);
BufferSystem.tags

//free buffer by tag
BufferSystem.free(\marilyn1);
BufferSystem.tags

//free tag arr
BufferSystem.freeAll([\alloc2, \SinedPink]);
BufferSystem.tags;

//free index arr
BufferSystem.freeAtAll([0,3]);
BufferSystem.tags;

BufferSystem.bufferArray.postin(\ide, \doln);

//free all buffers in system
BufferSystem.freeAll;
BufferSystem.tags;

//load whole directory
BufferSystem.readDir(~path, {|bufArr| bufArr.do{|buf| buf.play} });

//post tags and path for a Directory
BufferSystem.dirDialog;


//set default path from Dialog
BufferSystem.setDefaultPath;
BufferSystem.dirTags.dopostln;


BufferSystem.bufferArray;
BufferSystem.bufferArray.dopostln;
BufferSystem.bufferInfo.dopostln;

//add full directory into system
~dirPath = "/Users/federicoreuben/Music/Sounds/radiohead_tracks/";
BufferSystem.addDir(~dirPath, {|item| item.postln });
BufferSystem.freeAll;

//add subDirectories in multidimentional array
~path = "/Users/federicoreuben/Music/Sketches/ImprovMaterial/"
BufferSystem.addSubDirs(~path, {|item| a =item});

a[0].postin(\ide, \doln);
a[1].postin(\ide, \doln);

BufferSystem.freeAll;

//cueSoundFile buffers for DiskIn
~path = "/Users/federicoreuben/Library/Application Support/SuperCollider/Extensions/Radicles/SoundFiles/Play/0/";

//args: [file,[start,bufSize]], path, function
BufferSystem.add(['marilyn1','cue',[0,2]], ~path, {|item| item.numFrames.postln });
BufferSystem.tags;

BufferSystem.get(\disk0_marilyn1);
BufferSystem.free(\disk0_marilyn1);

//readChannels
BufferSystem.add(['marilyn1',[0]], ~path, {|item| item.play });

BufferSystem.add('marilyn1', ~path, {|item| item.play});

BufferSystem.addAll([['marilyn1','cue',[0,1]], ['SinedPink','cue',[0,1]]], ~path, {|item| item.postln });

~arr = [['marilyn1',[0]], 'marilyn1', [1234,2], [2342, 1], [35424,1], ['marilyn1','cue',[0,1]]]

~path = "/Users/federicoreuben/Library/Application Support/SuperCollider/Extensions/Radicles/SoundFiles/Play/0/";

BufferSystem.addAll(~arr, ~path, {|item| item.postln });


BufferSystem.addAll([[1234*2,4], 'marilyn1', [1234,2], [1234,1], ['SinedPink', 'cue', [0,1]] ], ~path, function: {|item| a = item; });

BufferSystem.tags


BufferSystem.tags;


BufferSystem.freeAll;

//mix of alloc, read and cue
BufferSystem.addAll([[1234*2,4], 'marilyn1', [1234,2], [1234,1], ['SinedPink', [0,1]] ], ~path, function: {|item| a = item; });
a.postin(\ide, \doln);

BufferSystem.freeAll;

//cue full directory
~dirPath = "/Users/federicoreuben/Music/Sounds/radiohead_tracks/";

BufferSystem.cueDir(~dirPath, 0, 1, {|item| item.postln });
BufferSystem.freeAll;

//access to more basic funtionality (not recommended in practice)

~path = "/Users/federicoreuben/Library/Application Support/SuperCollider/Extensions/Radicles/SoundFiles/Play/0/marilyn1.wav";

BufferSystem.read(~path, {|item| item.play});

BufferSystem.tags;

BufferSystem.alloc(function: {|item| item.numChannels.postln});

BufferSystem.bufferArray;

BufferSystem.bufferInfo.postin(\ide, \doln);

BufferSystem.alloc(44100*8, 2, {|item| item.numChannels.postln});

BufferSystem.allocAll([[1234,2], [2342, 1], [35424,1]], {|item| item.do{|buf| buf.numFrames.postln } });

BufferSystem.bufferInfo.dopostln;

BufferSystem.bufferInfo.flop[0].dopostln;

~path = [
"/Users/federicoreuben/Music/Sounds/radiohead_tracks/radiohead_bass.aif",
"/Users/federicoreuben/Music/Sounds/radiohead_tracks/radiohead_drums.aif",
"/Users/federicoreuben/Music/Sounds/radiohead_tracks/radiohead_FX.aif",
"/Users/federicoreuben/Music/Sounds/radiohead_tracks/radiohead_guitar.aif",
"/Users/federicoreuben/Music/Sounds/radiohead_tracks/radiohead_voice.aif"
];

BufferSystem.readAll(~path, {|item| item.do{|buf| buf.play} });

BufferSystem.freeAll;