Borderlands Supercollider Code

Transcription

Borderlands Supercollider Code
//Borderlands - Supercollider Patch
//by Nick Sibicky 2009-2010
//Un-comment the following text and execte to set buffer size BEFORE running patch
/*s.options.hardwareBufferSize = 64;
s.boot; // */
//Global Patch + settings
(
var latencycomp = 0.065, xmouse, ymouse, fshift1, fshift1mod, fshift1freq,
fftbuffersize, sr, fftresolution, mix = 0.9, wavbuffers = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], schedule,
ringmod1, cbuffer, susbuffer, graineng, graindelbuf, grainenvbuf, shiftfreq, pshift, pshiftgui, patdelaygui, patdelaywr,
patdelayonoff, patdelayread, delaybuf, reverbgen, reverbgui, routingmatrix, masterout, synthcall, synthnodes, fxstore,
clist, presetLink, presetOscLabel, fx25list, fx25store, matrixstore, matrixlist, presetdirectory, p2directory, globallagtime,
globalkrate, wavlist, wavstore, midic, learnslot, learnnum, automate, clearclock, globaldelaycomp;
//Global Settings
fftbuffersize = 4096;
sr = s.sampleRate;
fftresolution = sr/fftbuffersize;
sr.post;
" SR".postln;
fftbuffersize.post;
" FFT Size".postln;
schedule = Scheduler(SystemClock);
automate = 0; //to determine when automation should be read or be allowed to be manually adjusted
//Global Preset Manager
presetdirectory = "./mysounds/presets/"; //the location where presets will be stored
p2directory = "matrix25/";
fxstore = Array2D.new(14, 10);
clist = Array2D.new(14, 10);
matrixstore = Array2D.new(30, 15);
matrixlist = Array2D.new(30, 15);
fx25store = Array.fill(290, 0);
fx25list = Array.fill(290,0);
wavstore = Array.fill(50, 0);
wavlist = Array.fill(50,0);
globallagtime = 2;
globalkrate = 90;
globaldelaycomp = 0.06;
//GLOBAL DELAY COMPENSATION (for FX25)
for(0,29, {arg county;
//fill the matrix 2D array with "0"
for(0,14, {arg countx;
matrixstore[county, countx] = 0;
});
});
presetLink = ["presetBufferL", "presetBufferR", "presetFX25", "presetFX26", "presetFX27", "presetFX28",
"presetFX29",
"presetFX30", "presetFX31", "presetFX32", "presetmatrixtop", "presetmatrixbottom", "presetpantop",
"presetpanbottom"];
presetOscLabel = ["25matrix", "WavPlayer", "fx25", "fx26", "fx27", "fx28", "fx29", "fx30", "fx31", "fx32",
"matrixtop",
"matrixbottom", "pantop", "panbottom"];
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------clearclock = SynthDef("clear app clock", {arg foobar;
AppClock.clear;
Out.ar(0, SinOsc(440, 0, 0.5));
});
//--------------------------------------------------------------------------------------------------for(0,13, { arg count;
SynthDef(presetLink[count].asString, {arg temp, value1, value2, value3, value4, value5, value6, value7, value8,
value9, value10, value11, value12, value13, value14, value15, value16, krate=0, lagtime=1; var foo;
//foo = EnvGen.kr(Env([0,1],[1]), doneAction: 2);
SendReply.kr(Impulse.kr(krate), presetOscLabel[count].asSymbol, [Lag.kr(value1, lagtime),
Lag.kr(value2,lagtime),
Lag.kr(value3, lagtime), Lag.kr(value4,lagtime), Lag.kr(value5, lagtime),
Lag.kr(value6,lagtime),Lag.kr(value7, lagtime),
Lag.kr(value8,lagtime),Lag.kr(value9, lagtime), Lag.kr(value10,lagtime)]);
}).send(s);
});
SynthDef("matrixLink", {arg temp; var foo;
foo = EnvGen.kr(Env([0,1],[1]), doneAction: 2);
SendReply.kr(Impulse.kr(0.3), \matrixset);
SendReply.kr(Impulse.kr(0.3), \matrix25);
SendReply.kr(Impulse.kr(0.3), \wavplay);
}).send(s);
AppClock.sched(2, {
SynthDef("Preset Manager", {arg preset, out, inmidi, cnumber, cvalue; var temp, mywindow, testbutton, red, green,
blue,
testbutton2, savebutton, deletebutton, fxnum=0, newname, namingbox, presetlist, presetselect, phoffset,
pmypath,
pmyfiles,pfiles, pnames, pnumfiles, pcount, itemlist, rereadlist, resetbutton, blankbutton, directoryselect,
directorylist,
directorylabel, latchbutton, lagslider, lagnumbox, maxPresetsPerMenu;
mywindow = GUI.window.new("Preset Manager", Rect(260, 500, 255, 255)).front; //set back to "58" instead of
"258"
mywindow.view.background = Color(0,0,0);
red = 50; green = 135; blue = 185;
phoffset = 100;
maxPresetsPerMenu = 45;
pfiles = Array.newClear(maxPresetsPerMenu+1);
rereadlist = { //WILL NEED TO INCREASE LIST BELOW TO MATCH ITEMLIST ARRAY SIZE
pfiles = pmypath.files;
//presetlist = Object.readArchive(presetdirectory.asString++p2directory.asString++"Preset List");
//pfiles.writeArchive(presetdirectory.asString++p2directory.asString++"Preset List");
for(0, maxPresetsPerMenu, {arg count;
itemlist[count] = ((pfiles[count].asString).replace("PathName(", "").replace(presetdirectory.asString,
"").replace(")",""));
if(itemlist[count] == "nil", {itemlist[count] = ""}, {});
});
presetselect.items = [itemlist[0].asString, //the ".items" method does not support arrays so items are
individualized
itemlist[1].asString, itemlist[2].asString, itemlist[3].asString,
itemlist[4].asString, itemlist[5].asString, itemlist[6].asString, itemlist[7].asString, itemlist[8].asString,
itemlist[9].asString, itemlist[10].asString, itemlist[11].asString, itemlist[12].asString,
itemlist[13].asString,
itemlist[14].asString, itemlist[15].asString, itemlist[16].asString, itemlist[17].asString,
itemlist[18].asString,
itemlist[19].asString, itemlist[20].asString, itemlist[21].asString, itemlist[22].asString,
itemlist[23].asString,
itemlist[24].asString, itemlist[25].asString, itemlist[26].asString, itemlist[27].asString,
itemlist[28].asString,
itemlist[29].asString, itemlist[30].asString, itemlist[31].asString, itemlist[32].asString,
itemlist[33].asString,
itemlist[34].asString, itemlist[35].asString, itemlist[36].asString, itemlist[37].asString,
itemlist[38].asString,
itemlist[39].asString, itemlist[40].asString, itemlist[41].asString, itemlist[42].asString,
itemlist[43].asString,
itemlist[44].asString, itemlist[45].asString];
}; // end rereadlist function
StaticText(mywindow, Rect(50, 230, 200, 20)).background_(Color.new255(255,255,255));
StaticText(mywindow, Rect(51, 231, 48, 18)).background_(Color.new255(red-15, green-35, blue35)).string_(" Ramp");
lagnumbox= NumberBox(mywindow, Rect(211, 231, 39, 18)).background_(Color.new255(red-15,green-
35,blue-35));
lagslider = SCSlider(mywindow, Rect(100, 231, 110, 18)).background_(Color.new255(red-15,green35,blue-35))
.thumbSize_(10).step_(1/96);
lagslider.action = {arg test; var slidval;
fx25store[289] = lagslider.value; //STORES LAG VALUES TO LAST SLOT IN FX25STORE!
slidval = (lagslider.value)*(lagslider.value)*10;
lagnumbox.value = slidval;
globallagtime = slidval;
};
lagslider.valueAction = 0.5;
directorylabel = StaticText(mywindow, Rect(5,5, 100, 220)).background_(Color.new255(255,255,255));
directorylabel = StaticText(mywindow, Rect(6,6, 98, 18)).background_(Color.new255(red,green,blue)).string_
(" Directory Select");
//IF NEED TO ADD MORE DIRECTORIES TO MENU....THIS IS THE PLACE!
directorylist = ["Testing", "1st Movement", "2nd Movement", "3rd Movement", "4th Movement", "5th Movement",
"6th Movement", "7th Movement", "General Use"];
directoryselect = ListView(mywindow, Rect(6, 26, 98, 198));
directoryselect.items = [directorylist[0], directorylist[1], directorylist[2], directorylist[3], directorylist[4],
directorylist[5], directorylist[6], directorylist[7], directorylist[8]];
directoryselect.background = Gradient(Color.new255(red,green,blue), Color.new255(red-25,green-55,blue-55),
\v);
directoryselect.action = {arg menu;
presetdirectory = "./mysounds/"++directorylist[menu.value].asString++"/"; //the location where presets will
be stored
pmypath = PathName.new(presetdirectory.asString);// Read the directory
rereadlist.value;
}; //end directoryselect.action
latchbutton = Button(mywindow, Rect(5, 230, 40, 20)).states_([ // Latch Mode Button
["OFF", Color.black, Color.new255(red,green,blue)],
["ON", Color.black, Color.new255(255,0,0)]]);
latchbutton.action = {arg choice; var list, temptext;
automate = 1;
if(choice.value == 1, {
for(1,13, {arg count;
s.sendMsg(\n_set, 1990+count, \krate, globalkrate); });},
{for(1,13, {arg count;
s.sendMsg(\n_set, 1990+count, \krate, 0); });});
};
StaticText(mywindow, Rect(110,5, 140, 220)).background_(Color.new255(255,255,255)); //border for preset
select
savebutton = Button(mywindow, Rect(109+phoffset, 6, 40, 20)).states_([ // "SAVE" button for presets
["Save", Color.black, Color.new255(red,green,blue)]]);
savebutton.action = {arg choice; var list, temptext;
newname = namingbox.value;
fxstore.writeArchive(presetdirectory.asString++newname.asString);
fx25store.writeArchive(presetdirectory.asString++p2directory.asString++newname.asString++"25");
matrixstore.writeArchive(presetdirectory.asString++p2directory.asString++newname.asString++"matrix");
wavstore.writeArchive(presetdirectory.asString++p2directory.asString++newname.asString++"wav");
//update the directory
pfiles = pmypath.files;
//presetlist = Object.readArchive(presetdirectory.asString++p2directory.asString++"Preset List");
//pfiles.writeArchive(presetdirectory.asString++p2directory.asString++"Preset List");
while({pcount < maxPresetsPerMenu},
{
if(pfiles[pcount].asString == "nil", {pnumfiles = pcount; pcount=maxPresetsPerMenu;},
{pnames[pcount] = (pfiles[pcount].asString).replace("PathName(",
"").replace(presetdirectory.asString,
pcount.post; " ".post; pnames[pcount].asString.postln; });
pcount = pcount+1;
});
"").replace(")","");
for(0, maxPresetsPerMenu, {arg count;
if(count < pnumfiles, {itemlist[count] = pnames[count];},
{itemlist[count] = "";});
itemlist.writeArchive(presetdirectory.asString++p2directory.asString++"Preset List");
});
rereadlist.value;
}; //end "Save" button
deletebutton = Button(mywindow, Rect(109+phoffset, 26, 40, 20)).states_([ // "delete" button for presets
["Delete", Color.black, Color.new255(red,green,blue)]]);
deletebutton.action = {arg choice; var list, temptext;
newname = namingbox.value;
File.delete(presetdirectory.asString++newname.asString);
File.delete(presetdirectory.asString++p2directory.asString++newname.asString++"25");
File.delete(presetdirectory.asString++p2directory.asString++newname.asString++"matrix");
File.delete(presetdirectory.asString++p2directory.asString++newname.asString++"wav");
//update the directory
pfiles = pmypath.files;
while({pcount < maxPresetsPerMenu},
{
if(pfiles[pcount].asString == "nil", {pnumfiles = pcount; pcount=maxPresetsPerMenu;},
{pnames[pcount] =
(pfiles[pcount].asString).replace("PathName(./mysounds/presets/", "").replace(")","");
});
pcount = pcount+1;
});
for(0, maxPresetsPerMenu, {arg count;
if(count < pnumfiles, {itemlist[count] = pnames[count];},
{itemlist[count] = "";});
itemlist[count].postln;
});
rereadlist.value;
}; //end "delete" button action
//initialization
clist = Object.readArchive("./mysounds/presets/matrix25/reset"); // HARD CODED RESET LOCATION FOR
PRESET INIT
for(1,13, {arg count; var temp;
s.sendMsg(\s_new, presetLink[count].asSymbol, (1990+count),1,1, \value1,
clist[count,0],
\value2, clist[count,1], \value3, clist[count,2],\value4, clist[count,3],\value5,
clist[count,4],
\value6, clist[count,5], \value7, clist[count,6], \value8, clist[count,7],\value9,
clist[count,8],
\value10, clist[count,9]);
});
//NOTE!!! Currently the reset button is reading the reset, reset25, and resetmatrix files from a variable directory
resetbutton = Button(mywindow, Rect(109+phoffset, 46, 40, 20)).states_([ // "delete" button for presets
["Reset", Color.black, Color.new255(red,green,blue)]]);
resetbutton.action = {arg choice; var list, temptext;
fx25list = Object.readArchive("./mysounds/presets/matrix25/reset25");
lagslider.valueAction = 0;
AppClock.clear;
latchbutton.valueAction = 1;
AppClock.sched((0.1), {latchbutton.valueAction = 0});
clist = Object.readArchive("./mysounds/presets/matrix25/reset"); // HARD CODED RESET LOCATION
matrixlist = Object.readArchive("./mysounds/presets/matrix25/resetmatrix");
wavlist = Object.readArchive("./mysounds/presets/matrix25/resetwav");
for(1,13, {arg count; var temp;
s.sendMsg(\n_set, 1990+count, \value1, clist[count,0],
\value2, clist[count,1], \value3, clist[count,2],\value4, clist[count,3],\value5,
clist[count,4],
\value6, clist[count,5], \value7, clist[count,6], \value8, clist[count,7],\value9,
clist[count,8],
\value10, clist[count,9], \lagtime, ((fx25list[289]*fx25list[289])*10));
});
s.sendMsg(\s_new, "matrixLink", s.nextNodeID,1,1);
}; //end "reset" button action
blankbutton = Button(mywindow, Rect(109+phoffset, 66, 40, 158)).states_([ // dummy button
["", Color.black, Color.new255(red-25,green-55,blue-55)]]);
namingbox = TextField(mywindow, Rect(11+phoffset, 6, 96, 20));
namingbox.stringColor_(Color.new255(120,120,120));
namingbox.value = "new preset";
namingbox.action = {arg field;
newname = field.value;
newname.postln; "".postln;
};
presetselect = ListView(mywindow, Rect(111, 26, 98, 198));
pmypath = PathName.new("./mysounds/"++presetdirectory.asString);// Read the directory into buffers and count
# of files
pfiles = pmypath.files;
"".postln;
pnames = Array.newClear(maxPresetsPerMenu);
pcount=0;
while({pcount < maxPresetsPerMenu},
{
if(pfiles[pcount].asString == "nil", {pnumfiles = pcount; pcount=maxPresetsPerMenu;},
{pnames[pcount] = (pfiles[pcount].asString).replace("PathName(./mysounds/presets/",
"").replace(")","");
pnames[pcount].asString.postln; });
pcount = pcount+1;
});
itemlist = Array.newClear(maxPresetsPerMenu+1);
for(0, maxPresetsPerMenu, {arg count;
if(count < pnumfiles, {itemlist[count] = pnames[count];},
{itemlist[count] = "";});
});
rereadlist.value;
presetselect.background = Gradient(Color.new255(red,green,blue), Color.new255(red-25,green-55,blue-55), \v);
presetselect.action = {arg menu; var length;
newname = itemlist[menu.value].asString;
if(newname == "", {}, { //only execute rest of presetselect action if not blank!
AppClock.clear;
latchbutton.valueAction = 1;
fx25list =
Object.readArchive(presetdirectory.asString++p2directory.asString++(itemlist[menu.value].asString)++"25");
length = fx25list[289]*fx25list[289]*10;
AppClock.sched((1.2*length), {latchbutton.valueAction = 0});
namingbox.value = itemlist[menu.value].asString;
lagslider.valueAction = fx25list[289];
clist = Object.readArchive(presetdirectory.asString++(itemlist[menu.value].asString));
matrixlist =
Object.readArchive(presetdirectory.asString++p2directory.asString++(itemlist[menu.value].asString)++"matrix");
wavlist =
Object.readArchive(presetdirectory.asString++p2directory.asString++(itemlist[menu.value].asString)++"wav");
for(1,13, {arg count; var temp;
s.sendMsg(\n_set, 1990+count, \lagtime, length, \value1, clist[count,0],
\value2, clist[count,1], \value3, clist[count,2],\value4, clist[count,3],\value5,
clist[count,4],
\value6, clist[count,5], \value7, clist[count,6], \value8, clist[count,7],\value9,
clist[count,8],
\value10, clist[count,9]); //\lagtime, (fx25list[289]*fx25list[289])*10);
});
s.sendMsg(\s_new, "matrixLink", s.nextNodeID,1,1);
}); //end if(newname ..... to prevent "nil" from being executed
}; //end presetselect.action (list click function)
CmdPeriod.doOnce({mywindow.close});
}).send(s); //end "Preset Manager"
nil;
});//end scheduling initialization
//--------------------------------------------------------------------------------------------------------------------//--------------------------------------------------------------------------------------------------------------------//--------------------------------------------------------------------------------------------------------------------//MIDI assignment
AppClock.sched(2, { //for initialization
SynthDef("MIDI", {arg ccnum, fxslot = 0, fxnum = 0;
var mywindow, ccbox, currentslot, currentnum, temptext, red, green, blue, learnvheight, slotlist, parameterlist,
fx25list, fx26list, fx27list, fx28list, fx29list, fx30list, fx31list, fx32list, matrix1list, matrix2list, matrix1panlist,
matrix2panlist,
learnbutton, ccinput, setlist, linknumlist, linkslotlist, currentcc, cctracker;
red = 80;
green = 160;
blue = 65;
learnvheight = 30;
parameterlist = Array2D.new(12, 30);
slotlist = ["fx25", "fx26", "fx27", "fx28", "fx29", "fx30", "fx31", "fx32", "1-10", "11-18"];
//then list each fx slot's number of controls and then their lables
fx25list = [4, "Coarse Tempo", "Stereo Width", "Fine Tempo", "Beat Emphasis"];
fx26list = [10, "Transpose 1", "Gain 1", "Transpose 2", "Gain 2", "Transpose 3", "Gain 3", "Portamento Time",
"Grain Size", "Random Timing %", "Randomize Pitch"];
fx27list = [2, "Scratch Position", "Scratch Lag"];
fx28list = [6, "Grain Size %", "Grain Frequency", "Grain Density", "Max Grain Delay", "Grain Env Sustain %",
"Grain Symmetry"];
fx29list = [1, "Ring Mod Frequency"];
fx30list = [1, "Freq Shift Frequency"];
fx31list = [13, "Bin Shift %", "Shift Distance", "Update Frequency", "Pitch 1", "Gain 1", "Pitch 2", "Gain 2",
"Pitch 3", "Gain 3", "Pitch 4", "Gain 4", "Pitch 5", "Gain 5"];
fx32list = [4, "Reverb Time", "Damping", "Input Bandwidth", "Stereo Spread"];
matrix1list = [30, "Channel 1 Input Gain", "Channel 1 Panning", "Channel 1 Output Gain",
"Channel 2 Input Gain", "Channel 2 Panning", "Channel 2 Output Gain",
"Channel 3 Input Gain", "Channel 3 Panning", "Channel 3 Output Gain",
"Channel 4 Input Gain", "Channel 4 Panning", "Channel 4 Output Gain",
"Channel 5 Input Gain", "Channel 5 Panning", "Channel 5 Output Gain",
"Channel 6 Input Gain", "Channel 6 Panning", "Channel 6 Output Gain",
"Channel 7 Input Gain", "Channel 7 Panning", "Channel 7 Output Gain",
"Channel 8 Input Gain", "Channel 8 Panning", "Channel 8 Output Gain",
"Wav Player L Input Gain", "Wav Player L Panning", "Wav Player L Output Gain",
"Wav Player R Input Gain", "Wav Player R Panning", "Wav Player R Output Gain"];
matrix2list = [30, "FX Bus 25 Input Gain", "NA", "FX Bus 25 Output Gain",
"FX Bus 26 Input Gain", "FX Bus 26 Panning", "FX Bus 26 Output Gain",
"FX Bus 27 Input Gain", "FX Bus 27 Panning", "FX Bus 27 Output Gain",
"FX Bus 28 Input Gain", "NA", "FX Bus 25 Output Gain",
"FX Bus 29 Input Gain", "FX Bus 29 Panning", "FX Bus 29 Output Gain",
"FX Bus 30 Input Gain", "FX Bus 30 Panning", "FX Bus 30 Output Gain",
"FX Bus 31 Input Gain", "FX Bus 31 Panning", "FX Bus 31 Output Gain",
"FX Bus 32 Input Gain", "FX Bus 32 Panning", "FX Bus 32 Output Gain"];
for(0,9, {arg fxslotcount;
for(1,30, {arg numcount; var lookup;
lookup = case
{fxslotcount == 0} {fx25list[numcount]}
{fxslotcount == 1} {fx26list[numcount]}
{fxslotcount == 2} {fx27list[numcount]}
{fxslotcount == 3} {fx28list[numcount]}
{fxslotcount == 4} {fx29list[numcount]}
{fxslotcount == 5} {fx30list[numcount]}
{fxslotcount == 6} {fx31list[numcount]}
{fxslotcount == 7} {fx32list[numcount]}
{fxslotcount == 8} {matrix1list[numcount]}
{fxslotcount == 9} {matrix2list[numcount]};
parameterlist[fxslotcount, numcount] = lookup;
});
});
mywindow = GUI.window.new("MIDI Control", Rect(62, 500, 195, 255)).front;
mywindow.view.background = Color(0,0,0);
temptext = StaticText(mywindow, Rect(5, learnvheight, 185, 220)).background_(Color.new255(255,255,255));
linkslotlist = Array.newClear(128);
linknumlist = Array.newClear(128);
ccbox = Array.newClear(16);
currentslot = Array.newClear(16);
currentnum = Array.newClear(16);
cctracker = Array.newClear(128);
for(0,10, {arg rownum;
ccbox[rownum] = StaticText(mywindow, Rect(6, learnvheight+1+(rownum*20), 30, 18))
.background_(Color.new255(red-(rownum),green,blue)).string_("CC#");
currentslot[rownum] = StaticText(mywindow, Rect(38, learnvheight+1+(rownum*20), 50, 18))
.background_(Color.new255(red-(rownum),green,blue));
currentnum[rownum] = StaticText(mywindow, Rect(90, learnvheight+1+(rownum*20), 99, 18))
.background_(Color.new255(red-(rownum),green,blue));
}); //end for 0,12
learnbutton = Button(mywindow, Rect( 5, learnvheight-25, 185, 20))
.states_([["Click to learn last used CC", Color.black, Color.new255(red,green,blue)],
["Learning...", Color.black, Color.new255(255,0,0)]]);
learnbutton.action = {arg pressed;
//learnslot.post; " ".post; learnnum.postln;
//(fxslot.value).postln; (fxnum.value).postln;
if(pressed.value == 1, {
if(currentcc == nil, {}, { //makes sure that there is a previous cc registered
linkslotlist[currentcc] = learnslot;
linknumlist[currentcc] = learnnum;
ccbox[0].string_(currentcc.asString);
currentslot[0].string_(slotlist[learnslot-1].asString);
currentnum[0].string_(parameterlist[learnslot-1, learnnum+1].asString);
}); //end if nil
AppClock.sched(0.15, {learnbutton.valueAction = 0;});}, {/*linkslotlist.postln;*/});
//currentslot.string_(slotlist[([1,2,3].choose)].asString);
//currentnum.string_(parameterlist[([0,1,2,3,4].choose), ([0,1,2].choose)].asString);
};
setlist = [\value1, \value2, \value3, \value4, \value5, \value6, \value7, \value8, \value9, \value10];
//MIDI RESPONSE IS GENERATED HERE:
ccinput = CCResponder({ |src, chan, num, value|
if(linknumlist[num] == nil, {/*"no learnslot registered".postln;*/}, {
s.sendMsg(\n_set, 1991+((linkslotlist[num]).value), \lagtime, 0.05, \krate, globalkrate,
(setlist[(linknumlist[num])]).asSymbol, (value/127));
}); //end "if"
currentcc = num;
//(setlist[learnnum].asSymbol).postln; value.postln;
}, nil, nil, nil, nil);
/*currentnum.items_(["(Effect", "Transpose 1", "Gain 1", "Transpose 2", "Gain 2", "Transpose 3", "Gain 3",
"Portamento Time",
"Grain Size", "Random Timing %", "Randomize Pitch"]);*/
/*
OSCresponder(s.addr, "midilearn", {arg temp, value1, value2;
"it's midilearning!".postln;
{currentslot.string_((slotlist[(value2[3])]).asString);
currentnum.string_((parameterlist[(value2[4])]).asString);
temp.post; " ".post; value1.post; " ".post; value2.postln;
}.defer;
temp.post; " ".post; value1.post; " ".post; value2.postln;
}).add;
*/
CmdPeriod.doOnce({mywindow.close; ccinput.remove;});
}).send(s); //end "MIDI"
}); //end scheduling
//midic = Synth("MIDI"); // Don't need to call this? causing redudant node set messages? need to test more
//-----------------------------------------------------------------------------------------------------------------//-----------------------------------------------------------------------------------------------------------------//-----------------------------------------------------------------------------------------------------------------//Actual buffer/.wav player
SynthDef("Buffer Player",{arg buffertrigger=1;
Out.ar([23],
PlayBuf.ar(2, buffertrigger, BufRateScale.kr(buffertrigger), loop: 1)
)
}).send(s);
//-------------------------------------------------------------------------------------------------//Creates the Buffer Player Window
AppClock.sched(1, {
SynthDef("Buffer Window", {arg test=0; var mywindow, harmshiftslid, delaytimeslid, feedbackslid, rootpitchslid,
tempsynth;
var button1 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], text1, mypath,
files,
names = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], exit=0, numfiles,
fxnum=1, displaynames =
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], buttonheight, buttonwidth,
windowheight, windowwidth,
activebuttons, nodenum =
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], wavresponder;
mypath = PathName.new("./mysounds/");
// Read the /mysounds directory into buffers and count # of files
files = mypath.files;
for(0, 45, //if need to load more than 20 files, make sure to make matrices larger!
{arg counter;
if(exit == 0, {
names[counter] = (files[counter].asString).replace("PathName(./", "").replace(")","");
displaynames[counter] = (names[counter].asString).replace(".wav","").replace("mysounds/","");
if(names[counter].asString == "nil", {numfiles = counter; exit=1; counter=24;},{
wavbuffers[counter] = Buffer.read(s, names[counter].asString, bufnum: counter);});
}, {}); //exit
});
/*numfiles.post;
" sound files loaded".postln;
" ".postln;*/
windowheight = 250;
windowwidth = 270;
mywindow = GUI.window.new("Stereo Wave Player", Rect(518, 500, windowwidth, windowheight)).front;
mywindow.view.background = Color(0,0,0);
buttonheight = 16;
buttonwidth = (0.5*windowwidth)-5;
if(numfiles < 16, {activebuttons = numfiles-1}, {activebuttons = 14});
for(0,activebuttons,
{arg buttonnum;
button1[buttonnum] = Button(mywindow, Rect(5,(buttonheight*buttonnum)+5,buttonwidth,buttonheight))
.states_([
[displaynames[buttonnum].asString, Color.black, Color.new255(190+(buttonnum),120(buttonnum*3),190+(buttonnum))],
["! "++displaynames[buttonnum].asString++" !", Color.black, Color.red]
]);
nodenum[buttonnum] = s.nextNodeID;
button1[buttonnum].action = {arg choice;
wavstore[buttonnum] = button1[buttonnum].value; //store status for presets
if (choice.value == 1, {s.sendMsg("/s_new", "Buffer Player", nodenum[buttonnum], 1,
1, "buffertrigger", buttonnum);},
{s.sendMsg("n_free", nodenum[buttonnum]);})
};
//Calls Buffer Player Synth
});
for(activebuttons+1,15,
{arg buttonnum;
if(buttonnum > 14, {}, {button1[buttonnum] = Button(mywindow,
Rect(5,(buttonheight*buttonnum)+5,buttonwidth,buttonheight))
.states_([
["", Color.black, Color.new255(190+(buttonnum),120-(buttonnum*3),190+(buttonnum))]]);
});
});
if(numfiles > 15, {
for(15,numfiles-1, //2nd column
{arg buttonnum;
button1[buttonnum] = Button(mywindow, Rect(5+buttonwidth,(buttonheight*(buttonnum15))+5,buttonwidth,buttonheight))
.states_([
[displaynames[buttonnum].asString, Color.black, Color.new255(190+(buttonnum-15),120((buttonnum-15)*3),
190+(buttonnum-15))],
["! "++displaynames[buttonnum].asString++" !", Color.black, Color.red]
]);
nodenum[buttonnum] = s.nextNodeID;
button1[buttonnum].action = {arg choice;
wavstore[buttonnum] = button1[buttonnum].value; //store status for presets
if (choice.value == 1, {s.sendMsg("/s_new", "Buffer Player", nodenum[buttonnum], 1,
1, "buffertrigger", buttonnum);},
{s.sendMsg("n_free", nodenum[buttonnum]);})
};
//Calls Buffer Player Synth
});
},{}); //end if numfiles > 14
if(numfiles-1 < 16, {activebuttons=15;}, {activebuttons = numfiles-1;});
for(activebuttons, 29, //2nd column
{arg buttonnum;
button1[buttonnum] = Button(mywindow, Rect(5+buttonwidth,(buttonheight*(buttonnum15))+5,buttonwidth,buttonheight))
.states_([
["", Color.black, Color.new255(190+(buttonnum-15),120-((buttonnum-15)*3),190+(buttonnum15))]]);});
wavresponder = OSCresponder(s.addr, "wavplay", {arg temp;
{
for(0,numfiles-1, {arg count; var track;
button1[count].valueAction = wavlist[count];
});
}.defer;
}).add;
/*OSCresponder(s.addr, "WavPlayer", {arg temp, value1, value2;
{for(0,numfiles-1, {arg count; var previousnum = 0;
if((value2[count+3] != previousnum),
{button1[count].valueAction = value2[count+3];
previousnum = value2[count+3];}, {});
});
}.defer;
}).add; */
CmdPeriod.doOnce({wavresponder.remove; mywindow.close});
}).send(s);
nil;
}); //end scheduler
//--------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------//Pattern Delay Processor (FX Slot 25)
delaybuf = Buffer.allocConsecutive(10, s,(sr*15), 1, bufnum: 41); //Use Buffer nums #41-50 for FX 25 delays
// read from buffer to playback
patdelayread = SynthDef("Pattern Delay Read", {arg deltime=0.5, beatnumber=0, beatvelocity=1, channel=0,
panning=0.5, spread=0, emphasis=0.5,
gain=1; var out, sign, delayed=0;
spread = (spread*(-2))+1; // convert to -1 to +1 scale
panning = ((panning*2)-1); //convert panning from 0-1 to -1 to +1 scale
panning = panning - (spread*panning);
panning = (panning+1)*0.5; //convert back to 0-1 scale
emphasis = Lag.kr(emphasis, 0.1);
delayed = DelTapRd.ar((41+channel), In.kr(channel+100), (deltime*beatnumber-globaldelaycomp), 2);
//Is delayed here
delayed = (delayed*(1-emphasis))+(delayed*beatvelocity*(emphasis));
Out.ar([35], delayed);
panning = Lag.kr(panning,0.1);
Out.ar(101, delayed*(1-panning));
Out.ar(102, delayed*(panning));
}).send(s);
// write to buffer
patdelaywr = SynthDef("Pattern Delay Write",{ arg out=0, synthfreq=100; var in, chain, kernel, deltime=0.5, channel=0,
delayed,
delcapture = [0,0,0,0,0,0,0,0,0,0,0,0,0];
in = InFeedback.ar(60); //takes from internal bus 60 for "FX slot 25"
for(0,8, {arg counter; var input=0;
if(counter == 8, {input = 10}, {input = counter});
delcapture[counter] = DelTapWr.ar((41+counter), InFeedback.ar(input+50));
Out.kr(100+counter, delcapture[counter]);
});
}).send(s);
//mute/unute for delayed output
patdelayonoff = SynthDef("Delay On Off", {arg fades = 0, gain=1; var tempL, tempR, masterpulse30;
tempL = Lag.kr(fades,0.1)*InFeedback.ar(101)*gain;
tempR = Lag.kr(fades,0.1)*InFeedback.ar(102)*gain;
masterpulse30 = Impulse.kr(30);
SendReply.kr(masterpulse30, "outlevelL11", Amplitude.ar(tempL,0,1)); //Sets Meter sig, attack time, release time
SendReply.kr(masterpulse30, "outlevelR11", Amplitude.ar(tempR,0,1)); //Sets Meter sig, attack time, release
time
Out.ar(33, tempL);
Out.ar(34, tempR);
}).send(s);
//----------------------(FX Slot 25)
//Creates Pattern Delay Gui
AppClock.sched(1, { //schedule this to initialize after other synthdefs
patdelaygui = SynthDef("Pattern Delay Gui", {arg test=0; var mywindow, dbutton, dbuttonID, red, green, blue, redy,
greeny, bluey,
redx, greenx, bluex, textdesc = [" Input 1", " Input 2", " Input 3", " Input 4", " Input 5", " Input 6", " Input 7", "
Input 8",
" FX Bus 25"], dbox = [0,0,0,0], dslid = [0,0,0,0], coffset, temptext, tempoc=114, tempof=0, newred, newgreen,
newblue, tracker,
delaycoarse, delayfine, delaytotal, beatkey = [1, 0.065, 0.25, 0.065], mod, fxnum=2, fx25responder1,
fx25responder2;
mywindow = GUI.window.new("Pattern Delay Module (25)", Rect(800, 75, 454, 165)).front;
mywindow.view.background = Color(0,0,0);
StaticText(mywindow, Rect(5,4, 55, 109)).background_(Color.new255(255,255,255));
dbutton = Array.newClear(320);
tracker = Array.fill(320, 0);
red = 120;
green = 140;
blue = 160;
redy = -3;
greeny = 0;
bluey = -2;
redx = 0;
greenx = 0;
bluex = 0;
for(0, 8, {arg ychannel;
for(0,31, {arg xpos; var index, highlight, rounded;
rounded = (xpos/4).round(1);
if(rounded == (xpos/4), {highlight = 30},{highlight = 0});
newred = red+(xpos*redx)+(ychannel*redy)+(highlight*1.5);
newgreen = green+(xpos*greenx)+(ychannel*greeny)+highlight;
newblue = blue+(xpos*bluex)+(ychannel*bluey)+(highlight);
index = (ychannel*32)+xpos;
dbutton[index] = Button(mywindow, Rect(65+(xpos*12),5+(ychannel*12),12,12))
.states_([
["", Color.black, Color.new255(newred,newgreen,newblue)],
["", Color.black, Color.red]
]);
dbutton[index].action = {arg choice;
fx25store[index] = dbutton[index].value; //store changes to matrix in fx25store
if (choice.value == 1, {
tracker[index] = 1;
mod = xpos%4;
s.sendMsg("/s_new", "Pattern Delay Read", (index+2000), 1, 1, \beatnumber,
(xpos/4), \channel, ychannel, \spread, dbox[1].value,
\beatvelocity, beatkey[mod], \emphasis, dbox[3].value, \deltime,
60/(dbox[0].value), \panning, rrand(0.0,1.0));},
{tracker[index] = 0;
s.sendMsg("n_free", (index+2000);)});
};
});//end of xpos loop
temptext = StaticText(mywindow, Rect(6, (12*ychannel)+5, 53,
11)).background_(Color.new255(newred+10, newgreen+10,
newblue+10)).string_(textdesc[ychannel].asString);
temptext.font = Font("Helvetica", 9);
}); //end of ychannel loop
StaticText(mywindow, Rect(5, 120, 173, 40)).background_(Color.new255(255,255,255));
StaticText(mywindow, Rect(178, 130, 45, 20)).background_(Color.new255(255,255,255));
StaticText(mywindow, Rect(5, 120, 173, 40)).background_(Color.new255(255,255,255));
red = newred;
green=newgreen;
blue=newblue;
//coarse tempo control
temptext = StaticText(mywindow, Rect(6, 121, 78, 18)).background_(Color.new255(red, green, blue)).string_(" BPM
Coarse");
dbox[0] = NumberBox(mywindow, Rect(179,131, 43, 18)).background_(Color.new255(red, green, blue));
dslid[0] = SCSlider(mywindow, Rect(87, 121, 89, 18)).background_(Color.new255(red, green,
blue)).thumbSize_(10).step_(0.01);
AppClock.sched(3, {
dslid[0].action = {var value;
//value.value.postln;
s.sendMsg(\n_set, 1990+2, \krate, 0);
learnslot = 1; learnnum = 0; //for MIDI learn
//try this: (for using gui while automation is "on")
s.sendMsg(\n_set, 1992, \value1, (dslid[0].value), \lagtime, 0);
fxstore[fxnum, 0] = dslid[0].value;
tempoc = ((dslid[0].value)*100)+64;
dbox[0].value = tempoc+tempof;
for(0, 320, {arg butnum;
if(tracker[butnum] == 1, {s.sendMsg(\n_set, butnum+2000, \deltime, 60/(dbox[0].value));},
{});
}); //end loop
};
}); //end appclock init
//Stereo Width Control
coffset = 226;
StaticText(mywindow, Rect(5+coffset, 120, 217, 40)).background_(Color.new255(255,255,255));
StaticText(mywindow, Rect(6+coffset, 121, 78, 18)).background_(Color.new255(red, green, blue)).string_("
Mono/Stereo");
dbox[1] = NumberBox(mywindow, Rect(190+coffset,121, 31, 18)).background_(Color.new255(red, green, blue));
dslid[1] = SCSlider(mywindow, Rect(87+coffset, 121, 100, 18)).background_(Color.new255(red, green,
blue)).thumbSize_(10);
AppClock.sched(3, {
dslid[1].action = {var value;
s.sendMsg(\n_set, 1990+2, \krate, 0);
learnslot = 1; learnnum = 1; //for MIDI learn
fxstore[fxnum, 1] = dslid[1].value;
value = (dslid[1].value);
dbox[1].value = value;
for(0, 320, {arg butnum;
if(tracker[butnum] == 1, {s.sendMsg(\n_set, butnum+2000, \spread, value);}, {});
}); //end loop
};
}); //end appclock init
//Beat Emphasis Control
StaticText(mywindow, Rect(6+coffset, 141, 78, 18)).background_(Color.new255(red, green, blue)).string_(" Beat
Emph.");
dbox[3] = NumberBox(mywindow, Rect(190+coffset,141, 31, 18)).background_(Color.new255(red, green, blue));
dslid[3] = SCSlider(mywindow, Rect(87+coffset, 141, 100, 18)).background_(Color.new255(red, green,
blue)).thumbSize_(10);
AppClock.sched(3, {
dslid[3].action = {var value;
s.sendMsg(\n_set, 1990+2, \krate, 0);
learnslot = 1; learnnum = 3; //for MIDI learn
fxstore[fxnum, 3] = dslid[3].value;
value = (dslid[3].value);
dbox[3].value = value;
for(0, 320, {arg butnum;
if(tracker[butnum] == 1, {s.sendMsg(\n_set, butnum+2000, \emphasis, value);}, {});
}); //end loop
};
}); //end appclock init
//Tempo Fine Control
coffset = 0;
temptext = StaticText(mywindow, Rect(6, 141, 78, 18)).background_(Color.new255(red, green, blue)).string_("
BPM Fine");
dslid[2] = SCSlider(mywindow, Rect(87, 141, 89, 18)).background_(Color.new255(red, green,
blue)).thumbSize_(10).step_(0.01);
AppClock.sched(3, {
dslid[2].action = {var value;
s.sendMsg(\n_set, 1990+2, \krate, 0);
learnslot = 1; learnnum = 2; //for MIDI learn
fxstore[fxnum, 2] = dslid[2].value;
tempof = (dslid[2].value);
dbox[0].value = tempof+tempoc;
for(0, 320, {arg butnum;
if(tracker[butnum] == 1, {s.sendMsg(\n_set, butnum+2000, \deltime, 60/(dbox[0].value));},
{});
}); //end loop
};
}); //end appclock init
for(0,3, {arg init;
dslid[init].valueAction = 0.5;
});
fx25responder1 = OSCresponder(s.addr, "matrix25", {arg temp;
//"its here!".postln;
{
//fx25list = Object.readArchive(presetdirectory.asString++"fx25 list");
for(0,287, {arg count; var track;
dbutton[count].valueAction = fx25list[count];
//dslid[count].valueAction = value2[count+3];
});
}.defer;
}).add;
fx25responder2 = OSCresponder(s.addr, "fx25", {arg temp, value1, value2;
//"its here!".postln;
{for(0,3, {arg count;
dslid[count].value = value2[count+3];
if(count == 2, {
fxstore[fxnum, 2] = dslid[2].value;
tempof = (dslid[2].value);
dbox[0].value = tempof+tempoc;
for(0, 320, {arg butnum;
if(tracker[butnum] == 1, {s.sendMsg(\n_set, butnum+2000, \deltime,
60/(dbox[0].value));}, {});
}); //end loop
}, {
if(count == 3, {
fxstore[fxnum, 3] = dslid[3].value;
dbox[3].value = dslid[3].value;
for(0, 320, {arg butnum;
if(tracker[butnum] == 1, {s.sendMsg(\n_set, butnum+2000, \emphasis,
dslid[3].value);}, {});
}); //end loop
}, {
if(count == 1, {
fxstore[fxnum, 1] = dslid[1].value;
dbox[1].value = dslid[1].value;
for(0, 320, {arg butnum;
if(tracker[butnum] == 1, {s.sendMsg(\n_set, butnum+2000,
\spread, dslid[1].value);}, {});
}); //end loop
}, {
s.sendMsg(\n_set, 1992, \value1, (dslid[0].value), \lagtime, 0);
fxstore[fxnum, 0] = dslid[0].value;
tempoc = ((dslid[0].value)*100)+64;
dbox[0].value = tempoc+tempof;
for(0, 320, {arg butnum;
if(tracker[butnum] == 1, {s.sendMsg(\n_set, butnum+2000,
\deltime, 60/(dbox[0].value));}, {});
}); //end loop
})})});
});
}.defer;
}).add;
CmdPeriod.doOnce({fx25responder1.remove; fx25responder2.remove; mywindow.close});
}).send(s);
nil;
}); //end scheduling
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//FX Slot 26 Pitch Shifter
pshift = SynthDef("Pitch Shift", {arg out=0, localbufsize = 1024, pshiftratio=1, pshiftratio2=1, pshiftratio3=1,
windowsize=0.1, prandomize=0,
timerandom=0.02, t1gain=1, t2gain=1, t3gain=1, lagtime=0.1; var tempout, tempout2, tempout3, in, supernice,
pout;
in = InFeedback.ar(61);
t1gain=t1gain.dbamp;
t2gain=t2gain.dbamp;
t3gain=t3gain.dbamp;
tempout = PitchShift.ar(in, windowsize, Lag.kr(pshiftratio.midiratio, lagtime), prandomize,
windowsize*timerandom);
tempout2 = PitchShift.ar(in, windowsize, Lag.kr(pshiftratio2.midiratio, lagtime), prandomize,
windowsize*timerandom);//creates 3rd harmony
tempout3 = PitchShift.ar(in, windowsize, Lag.kr(pshiftratio3.midiratio, lagtime), prandomize,
windowsize*timerandom);//creates 4th harmony
tempout = tempout*Lag.kr(t1gain, 0.1);
tempout2 = tempout2*Lag.kr(t2gain, 0.1);
tempout3 = tempout3*Lag.kr(t3gain, 0.1);
pout = tempout+tempout2+tempout3;
Out.ar([36], pout);
}).send(s);
//-------Pshift Gui
-----AppClock.sched(1, {
pshiftgui = SynthDef("Pitch Shifter", {arg out=0; var tempout, mywindow, pbox = [0,0,0,0,0,0,0,0,0,0,0,0,0,0], pslid =
[0,0,0,0,0,0,0,0,0,0,0,0,0],
basered, basegreen, baseblue, border, textdesc = Array.new(13), target = Array.new(13), slidval =
[0,0,0,0,0,0,0,0,0,0,0,0,0,0],
scalefac = [0, 24, 2, 24, 2, 24, 2, 1, 0.3, 0.99, 0.1, 1], scalecons = [99, -12, 0, -12, 0, -12, 0,0,0,0.1,0,0,0],
initialize = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,], horizred, horizgreen, horizblue, hilite, fxnum=3,
presponder;
mywindow = GUI.window.new("Pitch Shifter/Harmonizer (26)", Rect(1001, 535, 260, 210)).front;
mywindow.view.background = Color.new255(0,0,0);
basered=157;
basegreen=122;
baseblue=200;
horizred = -3; //horizred...etc is for a smilght darkening from left to right
horizgreen = -3;
horizblue = -3;
hilite = 10; //hilite is for a vertical highlight on the labels and number box (does not apply to slider)
textdesc = [" ", " Transpose 1", " Gain 1", " Transpose 2", " Gain 2", " Transpose 3", " Gain 3", " Portamento
Time", " Grain Size", " Rand. Timing %", " Randomize Pitch"];
target = [" ", "pshiftratio", "t1gain", "pshiftratio2", "t2gain", "pshiftratio3", "t3gain", "lagtime", "windowsize",
"timerandom", "prandomize"];
border = StaticText(mywindow, Rect(115,5, 140, 200)).background_(Color.new255(255,255,255));
border = StaticText(mywindow, Rect(5,5, 105, 200)).background_(Color.new255(255,255,255));
for(1,10, {arg counter;
StaticText(mywindow, Rect(6, (20*counter)-14, 103,
18)).background_(Gradient(Color.new255(basered+hilite,basegreen+hilite,baseblue+hilite),
Color.new255(basered,basegreen,baseblue), \v)).string_(textdesc[counter].asString);
pbox[counter] = NumberBox(mywindow, Rect(216,(20*counter)-14,38,
18)).background_(Gradient(Color.new255(basered+horizred+hilite,
basegreen+horizgreen+hilite,baseblue+horizblue+hilite),
Color.new255(basered+horizred,basegreen+horizgreen,baseblue+horizblue), \v));
pslid[counter] = SCSlider(mywindow, Rect(116,20*counter-14, 98,
18)).background_(Gradient(Color.new255(basered,basegreen,baseblue),
Color.new255(basered+horizred,basegreen+horizgreen,baseblue+horizblue),
\h)).thumbSize_(10).step_(1/96);
AppClock.sched(3, {
pslid[counter].action = {var susslid, symslid;
s.sendMsg(\n_set, 1990+3, \krate, 0);
learnslot = 2;
learnnum = counter-1;
fxstore[fxnum, counter-1] = pslid[counter].value; //store value for writing to preset array
slidval[counter] = ((pslid[counter].value)*scalefac[counter])+scalecons[counter];
case {counter == 2} {slidval[counter] = slidval[counter].ampdb;} //the following cases convert to dB for
Amp
{counter == 4 } {slidval[counter] = slidval[counter].ampdb;}
{counter == 6 } {slidval[counter] = slidval[counter].ampdb;};
pbox[counter].value = slidval[counter];
s.sendMsg(\n_set, 3026, target[counter].asSymbol, slidval[counter]);
midic.set(\fxslot, 1, \fxnum, counter);
//pshift.setn(target[counter].asSymbol, slidval[counter]);
}; //end slider action
});//end appclock
basered = basered-1;
basegreen = basegreen-1;
baseblue=baseblue+1;
pslid[counter].valueAction = 0.5;
}); // end counter loop
presponder = OSCresponder(s.addr, "fx26", {arg temp, value1, value2;
//"its here!".postln;
{for(1,10, {arg counter;
pslid[counter].value = value2[counter+2];
fxstore[fxnum, counter-1] = pslid[counter].value; //store value for writing to preset array
slidval[counter] = ((pslid[counter].value)*scalefac[counter])+scalecons[counter];
case {counter == 2} {slidval[counter] = slidval[counter].ampdb;} //the following cases
convert to dB for Amp
{counter == 4 } {slidval[counter] = slidval[counter].ampdb;}
{counter == 6 } {slidval[counter] = slidval[counter].ampdb;};
pbox[counter].value = slidval[counter];
s.sendMsg(\n_set, 3026, target[counter].asSymbol, slidval[counter]);
midic.set(\fxslot, 1, \fxnum, counter);
});
}.defer;
}).add;
CmdPeriod.doOnce({presponder.remove; mywindow.close});
}).send(s);
nil;
}); //schedule this synthdef to load after synthdefs are loaded
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//FX Slot 27 - Recorder (Buffer Suspend)
cbuffer = Buffer.alloc(s,(sr*30),1, bufnum: 11); //Use Buffer #11 for cbuff and #12 for cropped buffer!
SynthDef("CBuffer Reset", {arg buffertrigger=1;
//BufWr.ar(DC.ar(0.0), 11, Phasor.ar(0, BufRateScale.kr(0)), 0, BufFrames.kr(0));
cbuffer.sine1(0, false, false, true);
}).send(s);
SynthDef("CBuffer Record",{arg buffertrigger=1; var sig;
sig = InFeedback.ar(62);
RecordBuf.ar(sig, 11);
}).send(s);
//USES BUFFER #100+ for playback (copied/cropped buffer #11)
SynthDef("CBuffer Player",{arg buffertrigger=1, numbuffer=12, speed=1, envelope=0, length=1, startingplace=0;
Out.ar([37],
PlayBuf.ar(1, numbuffer,
BufRateScale.kr(numbuffer)*speed,
loop: 1, startPos: startingplace, doneAction:2)*(1envelope+(envelope*(abs(SinOsc.ar((0.5/length)), 0, 1)))))
}).send(s);
SynthDef("CBuffer Scratch", {arg buffertrigger=1, numbuffer=100, index=0.6, scratchtime=0.25; var fadein;
fadein = EnvGen.kr(Env([0, 0, 1], [0.2, 0.2])); // this synth needs a fade in because of buffer alloc noise
index = BufFrames.kr(numbuffer) * index * DC.ar(1);
Out.ar(37, fadein * BufRd.ar(1, numbuffer, Lag3.ar((index), scratchtime)));
}).send(s);
//---------------------------
//FX Slot 27 Recorder Buffer Gui
AppClock.sched(1, {
SynthDef("Crazy Buffer", {arg out=0; var tempout, buf, recordin, mywindow, startbutton,
playbutton, recnodeid, playnodeid, starttime, stoptime, length=1, count=100,
scratchslid,
scratchtime, scratchbox, scratchtimebox, lagtime, red,green,blue, failureprevent = 0,
fadeb,
envelope=0, isplaying=0, smalltext, fxnum=4, scratchresponder;
red = 127;
green = 142;
blue = 80;
mywindow = GUI.window.new("Recorder (27)", Rect(790, 265, 206, 95)).front;
mywindow.view.background = Color(0,0,0);
StaticText(mywindow, Rect(5,50, 195, 40)).background_(Color.new255(255,255,255));
StaticText(mywindow, Rect(37,30, 132, 20)).background_(Color.new255(255,255,255));
StaticText(mywindow, Rect(38,31, 130, 18)).background_(Color.new255(red,green,blue)).string_("
Scrubber");
StaticText(mywindow, Rect(130,5, 69, 20)).background_(Color.new255(255,255,255));
Buffer
smalltext = StaticText(mywindow, Rect(132,7, 45, 16)).background_(Color.new255(red,green,blue)).string_("
fades?");
smalltext.font = Font("Helvetica", 10);
smalltext = StaticText(mywindow, Rect(7,71, 65, 17)).background_(Color.new255(red,green,blue)).string_("
scratch lag:");
smalltext.font = Font("Helvetica", 10);
startbutton = Button(mywindow, Rect(5,5,60,20))
.states_([
["Record", Color.black, Color.new255(red,green,blue)],
["Stop", Color.black, Color.red]
]);
recnodeid = s.nextNodeID;
startbutton.action = {arg choice;
fxstore[fxnum, 0] = startbutton.value*2;
if (choice.value == 1, {
s.sendMsg(\n_free, 3027);
s.sendMsg("/s_new", "CBuffer Reset", s.nextNodeID, 1, 1);
starttime = Main.elapsedTime;
s.sendMsg("/s_new", "CBuffer Record", recnodeid, 1, 1);
},
{
failureprevent = 1;
stoptime = Main.elapsedTime;
length = stoptime-starttime;
length.postln;
susbuffer.free;
s.sendMsg("n_free", recnodeid);
count=count+1;
susbuffer = Buffer.alloc(s,sr*length, 1, bufnum: count);
cbuffer.copyData(susbuffer);
s.sendMsg("/s_new", "CBuffer Scratch", 3027, 1, 1, \numbuffer, count);
//s.sendMsg(\n_set, 3027, \numbuffer, count);
});
//end of record button actions
};
playbutton = Button(mywindow, Rect(65,5,60,20))
.states_([
["Play", Color.black, Color.new255(red, green, blue)],
["Stop", Color.black, Color.red]
]);
playnodeid = s.nextNodeID;
playbutton.action = {arg choice;
fxstore[fxnum, 1] = playbutton.value;
if (choice.value == 1, {s.sendMsg("/s_new", "CBuffer Player", playnodeid, 1, 1,
\numbuffer, count,
\envelope, envelope, \length, length); isplaying = 1;},
{s.sendMsg("n_free", playnodeid); isplaying = 0;});
};
scratchbox = NumberBox(mywindow, Rect(166, 51, 33, 18)).background_(Color.new255(red,green,blue));
scratchslid = SCSlider(mywindow, Rect(6,51, 158,
18)).background_(Color.new255(red,green,blue)).thumbSize_(10);
scratchslid.action = {arg phase;
learnslot = 3;
learnnum = 3;
fxstore[fxnum, 3] = scratchslid.value;
scratchbox.value = scratchslid.value;
if(failureprevent == 1, {s.sendMsg(\n_set, 3027, \index, scratchslid.value);}, {});
};
scratchslid.valueAction = 0.5;
scratchtimebox = NumberBox(mywindow, Rect(166, 71, 33, 18)).background_(Color.new255(red,green,blue));
scratchtime = SCSlider(mywindow, Rect(74,71, 90,
18)).background_(Color.new255(red,green,blue)).thumbSize_(10);
scratchtime.action = {arg phase;
learnslot = 3;
learnnum = 4;
fxstore[fxnum, 4] = scratchtime.value;
lagtime = scratchtime.value * 0.5;
scratchtimebox.value = lagtime;
if(failureprevent == 1, {s.sendMsg(\n_set, 3027, \scratchtime, lagtime);}, {});
};
scratchtime.valueAction = 0.5;
fadeb = Button(mywindow, Rect(182, 7, 15, 15)).states_([
["", Color.black, Color.new255(red, green, blue)],
["X", Color.black, Color.red]
]);
fadeb.action = {arg choice;
fxstore[fxnum, 2] = fadeb.value;
if (choice.value == 1, {envelope = 1;
if(isplaying == 1, {s.sendMsg(\n_set, playnodeid, \envelope, 1)}, {}); },
{envelope = 0;
if(isplaying == 1, {s.sendMsg(\n_set, playnodeid, \envelope, 0)}, {}); })};
scratchresponder = OSCresponder(s.addr, "fx27", {arg temp, value1, value2;
{if(value2[3] > 0.5, {value2[3] = 1}, {value2[3] = 0}); //to convert lagging values back to 1 or
0
if(value2[4] > 0.5, {value2[4] = 1}, {value2[4] = 0}); //to convert lagging values back to 1 or 0
if(value2[5] > 0.5, {value2[5] = 1}, {value2[5] = 0}); //to convert lagging values back to 1 or 0
startbutton.valueAction = value2[3];
playbutton.valueAction = value2[4];
fadeb.valueAction = value2[5];
scratchslid.valueAction = value2[6];
scratchtime.valueAction = value2[7];
}.defer;
}).add;
CmdPeriod.doOnce({scratchresponder.remove; mywindow.close});
}).send(s);
nil;
}); // end scheduler
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//FX Slot 28 Granulator
graindelbuf = Buffer.alloc(s,(sr*15),1, bufnum: 21); //Use Buffer #21 for all Grains Delay Buffer
grainenvbuf = CtkBuffer.new(bufnum: 22, size: 1024).fillWithEnv(env: Env([0,1,1,0],[0.5,0,0.5], \sin)).load;
//AppClock.sched(0.3, { //for initialization
graineng = SynthDef("Grain Engine", {arg out=0, deltime=0.1, rate=6, density=0.2, graindur=50, fades=0,
fadetime=0.05, gain=1;
var in, delayed = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], grained = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], tempout, tempout2, capture,
masterpulse30, tempL, tempR;
graindur = Lag.kr(graindur*(1/rate), 0.1);
in = InFeedback.ar(63);
capture = DelTapWr.ar(graindelbuf,in);
for(0,15, {arg counter;
delayed[counter] = DelTapRd.ar(graindelbuf, capture, ((counter+1)*Lag.kr(deltime,0.1)), 2);
//THE FOLLOWING LINE OF CODE CAUSES "RESULT = 0" THE FIRST TIME PATCH IS RUN?
grained[counter] = InGrainB.ar(CoinGate.ar(Lag.kr(density, 0.1), Impulse.ar(rate)), Lag.kr(graindur,0.1),
delayed[counter], 22);
});
tempout =
((grained[0]*0.95)+(grained[1]*0.05)+(grained[2]*0.9)+(grained[3]*0.1)+(grained[4]*0.85)+(grained[5]*0.15)+(grained[6]*
0.8)+(grained[7]*0.2)+
(grained[8]*0.75)+(grained[9]*0.25)+(grained[10]*0.7)+(grained[11]*0.3)+(grained[12]*0.65)+(grained[13]*0.35)+(
grained[14]*0.6)+(grained[15]*0.4));
tempout2 =
((grained[0]*0.05)+(grained[1]*0.95)+(grained[2]*0.1)+(grained[3]*0.9)+(grained[5]*0.85)+(grained[4]*0.15)+(grained[7]*
0.8)+(grained[6]*0.2)+
(grained[9]*0.75)+(grained[8]*0.25)+(grained[11]*0.7)+(grained[10]*0.3)+(grained[13]*0.65)+(grained[12]*0.35)+(
grained[15]*0.6)+(grained[14]*0.4));
tempL=tempout*Lag.kr(fades,fadetime)*gain;
tempR=tempout2*Lag.kr(fades,fadetime)*gain;
masterpulse30 = Impulse.kr(30);
SendReply.kr(masterpulse30, "outlevelL14", Amplitude.ar(tempL,0,1)); //Sets Meter sig, attack time, release time
SendReply.kr(masterpulse30, "outlevelR14", Amplitude.ar(tempR,0,1)); //Sets Meter sig, attack time, release
time
Out.ar(33, tempL);
Out.ar(34, tempR);
//Out.ar(0, [tempL, tempR]);
REMOVE WHEN DONE TESTING
Out.ar(38, (tempout+tempout2)*0.5);
}).send(s);
//nil;
//}); //end scheduling
//s.sendMsg("/s_new", "Grain Engine", 3028, 1, 1); // initialize Grain Engine
//------------Granulator Gui ----------------AppClock.sched(1.3, { //for initialization
SynthDef("Grain Gui", {arg out=0; var tempout, mywindow, grainbox = [0,0,0,0,0,0,0,0,0], grainslid = [0,0,0,0,0,0,0,0,0],
basered, basegreen, baseblue, border,
textdesc = Array.new(8), slidval = [0,0,0,0,0,0,0,0], fxnum=5, grainresponder;
mywindow = GUI.window.new("Granulator (28)", Rect(1001, 380, 260, 130)).front;
mywindow.view.background = Color(0,0,0);
basered=120;
basegreen=165;
baseblue=35;
textdesc = [" Grain Size %", " Grain Frequency", " Grain Density", " Max Grain Delay", " Grain Env Sus %", "
Grain Symmetry"];
border = StaticText(mywindow, Rect(115,5, 140, 120)).background_(Color.new255(255,255,255));
border = StaticText(mywindow, Rect(5,5, 105, 120)).background_(Color.new255(255,255,255));
for(1,6, {arg counter;
StaticText(mywindow, Rect(6, (20*counter)-14, 103, 18)).background_(Color.new255(basered, basegreen,
baseblue)).string_(textdesc[counter-1].asString);
grainbox[counter] = NumberBox(mywindow, Rect(216,(20*counter)-14,38,
18)).background_(Color.new255(basered, basegreen, baseblue));
grainslid[counter] = SCSlider(mywindow, Rect(116,20*counter-14, 98, 18)).background_(Color.new255(basered,
basegreen, baseblue)).thumbSize_(10);
grainslid[counter].action = {var susslid, symslid;
learnslot = 4;
learnnum = counter-1;
fxstore[fxnum, counter-1] = grainslid[counter].value; //store values so presets can be saved
slidval[counter] = grainslid[counter].value;
if(counter ==1, {
s.sendMsg(\n_set, 3028, \graindur, slidval[counter]);},{});
if(counter == 2, {
slidval[counter] =slidval[counter]*20; //grains per second
s.sendMsg(\n_set, 3028, \rate, slidval[counter]);},{});
if(counter == 3, {
slidval[counter] = slidval[counter]*slidval[counter]*20; //chance to make a given grain
s.sendMsg(\n_set, 3028, \density, slidval[counter]);},{});
if(counter == 4, {
slidval[counter] = slidval[counter]*slidval[counter]*15; //seconds through last grain delay (max 15)
s.sendMsg(\n_set, 3028, \deltime, (slidval[counter]/15));},{});
if(counter == 5, {
slidval[counter] = slidval[counter]*slidval[counter];
grainenvbuf.fillWithEnv(env: Env([0, 1, 1, 0], [((1-slidval[5].value)*(1-slidval[6].value)),
slidval[5].value, ((1-slidval[5].value)*(slidval[6].value))], \sin));
},{});
if(counter == 6, {
grainenvbuf.fillWithEnv(env: Env([0, 1, 1, 0], [((1-slidval[5].value)*(1-slidval[6].value)),
slidval[5].value, ((1-slidval[5].value)*(slidval[6].value))], \sin));
},{});
grainbox[counter].value = slidval[counter];
};
basered = basered-1;
basegreen = basegreen+2;
baseblue=baseblue+1;
grainslid[counter].valueAction = 0.5;
});
grainresponder = OSCresponder(s.addr, "fx28", {arg temp, value1, value2;
{for(1,6, {arg count;
grainslid[count].valueAction = value2[count+2];
});
}.defer;
}).add;
CmdPeriod.doOnce({grainresponder.remove; mywindow.close});
}).send(s);
nil;
}); // end scheduling
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//FX Slot 29+30 Ring Mod+ Freq Shift
ringmod1 = SynthDef("Ring Mod", {arg newfreq=500, changerate=10, freq=50; var input, tempout, ringfreq,
ringmodprocess;
tempout = InFeedback.ar(64);
tempout = tempout*SinOsc.ar(Lag.kr(freq, 0.1), 0, 1);
Out.ar([39], tempout);
}).send(s);
SynthDef("Freq Shift", {arg newfreq=500, changerate=10, freq=0; var input, tempout, ringfreq, ringmodprocess;
tempout = InFeedback.ar(65);
tempout = FreqShift.ar(tempout, Lag.kr(freq, 0.1));
Out.ar([40], tempout);
}).send(s);
// Ring Mod+Freq Shift Gui
AppClock.sched(1, {
SynthDef("Rind Mod Gui", {arg temp; var freq, ringslid, mywindow, ringnbox, slid, red, green, blue, red2, green2, blue2,
fsslid, fsbox, fs2slid, sign, rfmodresponder;
mywindow = GUI.window.new("Ring Modulator (29) + Freq Shifter (30)", Rect(60, 0, 1200, 50)).front;
mywindow.view.background = Color(0,0,0);
red = 183;
green = 159;
blue = 87;
red2 = 190;
green2 = 190;
blue2 = 60;
StaticText(mywindow, Rect(5, 5, 1190, 40)).background_(Color.new255(255,255,255));
StaticText(mywindow, Rect(6, 6, 78, 18)).background_(Color.new255(red, green, blue)).string_(" Ring Mod ");
StaticText(mywindow, Rect(6, 26, 78, 18)).background_(Color.new255(red2, green2, blue2)).string_(" Freq Shift ");
ringnbox = NumberBox(mywindow, Rect(1135,6,38,18)).background_(Color.new255(red,green,blue));
StaticText(mywindow, Rect(1175, 6, 19, 18)).background_(Color.new255(red, green, blue)).string_("Hz");
ringslid = SCSlider(mywindow,
Rect(86,6,1048,18)).background_(Color.new255(red,green,blue)).thumbSize_(10);
ringslid.action = {var slidfreq;
learnslot = 5;
learnnum = 0;
fxstore[6, 0] = ringslid.value; //store value for writing to preset array
slidfreq = (ringslid.value).squared*1500; //implement scaling function here
ringnbox.value = slidfreq;
s.sendMsg(\n_set, 3029, \freq, slidfreq);
};
ringslid.valueAction = 0.5;
fsbox = NumberBox(mywindow, Rect(1135,26,38,18)).background_(Color.new255(red2,green2,blue2));
StaticText(mywindow, Rect(1175, 26, 19, 18)).background_(Color.new255(red2, green2, blue2)).string_("Hz");
fsslid = SCSlider(mywindow,
Rect(86,26,1048,18)).background_(Color.new255(red2,green2,blue2)).thumbSize_(10);
fsslid.action = {var slidfreq;
learnslot = 5;
learnnum = 1;
fxstore[6, 1] = fsslid.value; //store value for writing to preset array
if(fsslid.value < 0.5, {sign = -1}, {sign = 1});
slidfreq = (fsslid.value-0.5).squared*4000*sign; //implement scaling function here
fsbox.value = slidfreq;
s.sendMsg(\n_set, 3030, \freq, slidfreq);
};
fsslid.valueAction = 0.5;
rfmodresponder = OSCresponder(s.addr, "fx29", {arg temp, value1, value2;
{ringslid.valueAction = value2[3];
fsslid.valueAction = value2[4];
}.defer;
}).add;
CmdPeriod.doOnce({rfmodresponder.remove; mywindow.close});
}).send(s);
nil;
}); //end scheduled initialization
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//FX Slot 31 Frequency Scrambling and Synth Convolution (uses BUS 68 internally)
SynthDef("Bin Scramble", {arg out=0, binpercentage=0.5, bindistance=0.1, changespeed=2; var chain, in;
in = InFeedback.ar(66);
chain = FFT(LocalBuf(fftbuffersize), in);
chain = PV_BinScramble(chain, binpercentage, bindistance, Impulse.kr(changespeed));
out = IFFT(chain);
//Above code is for scrambling bins, use in another effects slot with bin delay?
Out.ar(68, out);
}).send(s); //use Node #3031
SynthDef("Convolution", {arg out=0, synthfreq=400, frombinscramble=0, fromdry=1, binscrambleonly=0,
pitch1=48, gain1=0.25, pitch2=55, gain2=0.10, pitch3=64, gain3=0.1, pitch4=72, gain4=0.05, pitch5=79,
gain5=0.02; var tempout, kernel, in;
gain1 = gain1.dbamp;
gain2 = gain2.dbamp;
gain3 = gain3.dbamp;
gain4 = gain4.dbamp;
gain5 = gain5.dbamp;
in = (InFeedback.ar(66)*Lag.kr(fromdry, 0.5))+(InFeedback.ar(68)*Lag.kr(frombinscramble, 0.5));
kernel =(LFSaw.ar(pitch1.midicps,0,0.2)*gain1)+(LFSaw.ar(pitch2.midicps, 0, 0.2)*gain2)+
(LFSaw.ar(pitch3.midicps, 0, 0.2)*gain3)+(LFSaw.ar(pitch4.midicps, 0, 0.2)*gain4)+
(LFSaw.ar(pitch5.midicps, 0, 0.2)*gain5);
out = Convolution.ar(in, kernel, 1024, 0.5)*0.2;
Out.ar([41], (out*Lag.kr((1-binscrambleonly),0.5))+(InFeedback.ar(68)*Lag.kr(binscrambleonly,0.5)));
}).send(s); //use Node #4031
// ----- Convolution Gui
AppClock.sched(1, { //scheduling delayed initialization
SynthDef("Convolution Gui", {arg out;
var cslid = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], cnbox = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
textdesc, textset, binscramble, mywindow, red, green, blue, redchange, greenchange,
bluechange, red2, green2, blue2, label, multiplier, offset, convoVoffset = 90, binslid = [0,0,0,0,0],
binbox = [0,0,0,0,0,0], bindesc, binset, routingbutton, binmultiplier, binoffset, binon, binresponder,
conresponder;
red = 51;
green = 140;
blue = 110;
redchange = -1;
greenchange = 0;
bluechange = 1;
red2 = 195;
green2 = 80;
blue2 = 85;
textdesc = [" Pitch 1", " Gain 1", " Pitch 2", " Gain 2", " Pitch 3", " Gain 3", " Pitch 4", " Gain 4", " Pitch 5", " Gain
5"];
textset = ["pitch1", "gain1", "pitch2", "gain2", "pitch3", "gain3", "pitch4", "gain4", "pitch5", "gain5"];
multiplier = [24, 2, 24, 2, 24, 2, 24, 2, 24, 2];
offset = [36, 0, 43, 0, 52, 0, 60, 0, 67,0];
bindesc = ["Bin %", "Distance", "Update"];
binset = ["binpercentage", "bindistance", "changespeed"];
binmultiplier = [1, 0.3, 20];
binoffset = [0,0,0];
mywindow = GUI.window.new("FFT/Convol. (31)", Rect(790, 385, 206, 300)).front;
mywindow.view.background = Color(0,0,0);
StaticText(mywindow, Rect(5,5+convoVoffset,196,200)).background_(Color.new255(255,255,255));
StaticText(mywindow, Rect(5,5+25,196,60)).background_(Color.new255(255,255,255));
for(0, 9, {arg count;
label = StaticText(mywindow, Rect(6,
6+(count*20)+convoVoffset,45,18)).background_(Color.new255(red+(redchange*count),
green+(greenchange*count), blue+(bluechange*count))).string_(textdesc[count].asString);
cnbox[count] = NumberBox(mywindow, Rect(161, 6+(count*20)+convoVoffset, 40,
18)).background_(Color.new255(red+(redchange*count),
green+(greenchange*count), blue+(bluechange*count)));
cslid[count] = SCSlider(mywindow, Rect(53, 6+(count*20)+convoVoffset, 106,
18)).background_(Color.new255(red+(redchange*count),
green+(greenchange*count), blue+(bluechange*count))).thumbSize_(10).step_(1/96);
cslid[count].action = {arg test; var slidval;
learnslot = 7;
learnnum = count;
fxstore[8, count] = cslid[count].value; //store values so presets can be saved
slidval = ((test.value)*multiplier[count])+offset[count];
case {count == 1} {slidval = slidval.ampdb;} //the following cases convert to dB for Amp
{count == 3 } {slidval = slidval.ampdb;}
{count == 5 } {slidval = slidval.ampdb;}
{count == 7 } {slidval = slidval.ampdb;}
{count == 9 } {slidval = slidval.ampdb;};
cnbox[count].value = slidval;
s.sendMsg(\n_set, 4031, textset[count].asSymbol, slidval);
};
cslid[count].valueAction = 0.5;
});
routingbutton = SCButton(mywindow, Rect(5,5, 196, 20)).states_([
[" Bin Scramble Mode", Color.black, Color.new255(red2,green2,blue2)],
[" Convolution Mode", Color.black, Color.new255(red, green, blue)],
[" Bin Scramble + Convolution", Color.black, Color.new255((red2+red)*0.5,
(green+green2)*0.2,
(blue+blue2)*0.5)]]);
routingbutton.action = {arg choice;
fxstore[7, 4] = routingbutton.value;
case {choice.value == 0} {if(binon == 1, {}, {
s.sendMsg("/s_new", "Bin Scramble", 3031, 1, 1, \binpercentage,
binbox[0].value,
\bindistance, binbox[1].value, \changespeed, binbox[2].value);});
s.sendMsg(\n_set, 4031, \fromdry, 0, \frombinscramble, 1, \binscrambleonly,
1);
binon=1; }
{choice.value == 1} {s.sendMsg(\n_set, 4031, \fromdry, 1, \frombinscramble,
0,
\binscrambleonly, 0);
if(binon == 1, {s.sendMsg(\n_free, 3031)},{}); binon = 0; }
{choice.value == 2} {if(binon == 1, {}, {
s.sendMsg("/s_new", "Bin Scramble", 3031, 1, 1, \binpercentage,
binbox[0].value,
\bindistance, binbox[1].value, \changespeed, binbox[2].value);});
s.sendMsg(\n_set, 4031, \fromdry, 1, \frombinscramble, 1, \binscrambleonly,
0); binon = 1;}
};
routingbutton.valueAction = 1;
for(0,2, {arg count;
label = StaticText(mywindow, Rect(6,
6+(count*20)+25,45,18)).background_(Color.new255(red2+(redchange*count),
green2+(greenchange*count), blue2+(bluechange*count))).string_(bindesc[count].asString);
binbox[count] = NumberBox(mywindow, Rect(161, 6+(count*20)+25, 40,
18)).background_(Color.new255(red2+(redchange*count),
green2+(greenchange*count), blue2+(bluechange*count)));
binslid[count] = SCSlider(mywindow, Rect(53, 6+(count*20)+25, 106,
18)).background_(Color.new255(red2+(redchange*count),
green2+(greenchange*count), blue2+(bluechange*count))).thumbSize_(10).step_(1/96);
binslid[count].action = {arg test; var slidval;
learnslot = 6;
learnnum = count;
fxstore[7, count] = binslid[count].value; //store values so presets can be saved
slidval = ((test.value)*binmultiplier[count])+binoffset[count];
binbox[count].value = slidval;
if(binon == 1, {s.sendMsg(\n_set, 3031, binset[count].asSymbol, slidval);}, {});
};
binslid[count].valueAction = 0.5;
});
binresponder = OSCresponder(s.addr, "fx30", {arg temp, value1, value2;
number
{for(0,2, {arg count;
routingbutton.valueAction = value2[7];
binslid[count].valueAction = value2[count+3];
});
}.defer;
}).add;
//NOTE: binshift uses freqshift's fx
conresponder = OSCresponder(s.addr, "fx31", {arg temp, value1, value2;
{for(0,9, {arg count;
cslid[count].valueAction = value2[count+3];
});
}.defer;
}).add;
//Responder for Convolution
CmdPeriod.doOnce({binresponder.remove; conresponder.remove; mywindow.close});
}).send(s);
nil;
}); //end initialization
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//FX Slot 32 Reverb
reverbgen = SynthDef("Reverb", {arg roomsize=100, revtime=5, damping = 0.5, inputdamping=0.5, stereospread=0.6,
drylvl= 0,
earlyreflvl= -0.5, taillvl= -0.5, maxroomsize=110; var sig, sig3, sig4, stereo = [0,0], stereo2 = [0,0];
sig = InFeedback.ar(67);
stereo = GVerb.ar(sig, roomsize, revtime, damping, inputdamping, stereospread, drylvl, earlyreflvl, taillvl,
maxroomsize);
stereo2 = GVerb.ar(sig, roomsize*0.5, revtime*0.65, damping*0.8, inputdamping*0.9, stereospread, drylvl,
earlyreflvl, taillvl, maxroomsize*0.5);
Out.ar([42], (stereo[0]+stereo2[0])/2);
}).send(s);
//Reverb Gui ---------AppClock.sched(1, {
reverbgui = SynthDef("Reverb Gui", {arg out=0; var tempout, mywindow, rbox = [0,0,0,0,0,0,0,0,0,0,0,0,0,0], rslid =
[0,0,0,0,0,0,0,0,0,0,0,0,0],
basered, basegreen, baseblue, border, textdesc = Array.new(13), target = Array.new(13), slidval =
[0,0,0,0,0,0,0,0,0,0,0,0,0,0],
scalefac = [0, 20, 1, 1, 1],
scalecons = [0,0,0,0,0,0], initialize = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,], horizred, horizgreen, horizblue,
hilite, revresponder;
mywindow = GUI.window.new("Reverb (32)", Rect(1001, 265, 260, 90)).front;
mywindow.view.background = Color.new255(0,0,0);
basered=170;
basegreen=95;
baseblue=15;
horizred = 0; //horizred...etc is for a smilght darkening from left to right
horizgreen = 0;
horizblue = 0;
hilite = 10; //hilite is for a vertical highlight on the labels and number box (does not apply to slider)
textdesc = [" ", " Reverb Time", " Damping", " Input Bandwidth", " Stereo Spread"];
target = [" ", "revtime", "damping", "inputdamping", "stereospread"];
border = StaticText(mywindow, Rect(115,5, 140, 80)).background_(Color.new255(255,255,255));
border = StaticText(mywindow, Rect(5,5, 105, 80)).background_(Color.new255(255,255,255));
for(1,4, {arg counter;
StaticText(mywindow, Rect(6, (20*counter)-14, 103,
18)).background_(Gradient(Color.new255(basered+hilite,basegreen+hilite,baseblue+hilite),
Color.new255(basered,basegreen,baseblue), \v)).string_(textdesc[counter].asString);
rbox[counter] = NumberBox(mywindow, Rect(216,(20*counter)-14,38,
18)).background_(Gradient(Color.new255(basered+horizred+hilite,basegreen
+horizgreen+hilite,baseblue+horizblue+hilite),
Color.new255(basered+horizred,basegreen+horizgreen,baseblue+horizblue), \v));
rslid[counter] = SCSlider(mywindow, Rect(116,20*counter-14, 98,
18)).background_(Gradient(Color.new255(basered,basegreen,baseblue),
Color.new255(basered+horizred,basegreen+horizgreen,baseblue+horizblue), \h)).thumbSize_(10);
rslid[counter].action = {var susslid, symslid;
learnslot = 8;
learnnum = counter-1;
fxstore[9, counter] = rslid[counter].value;
slidval[counter] = ((rslid[counter].value)*scalefac[counter])+scalecons[counter];
rbox[counter].value = slidval[counter];
s.sendMsg(\n_set, 3032, target[counter].asSymbol, slidval[counter]);
//reverbgen.setn(target[counter].asSymbol, slidval[counter]);
}; //end slider action
basered = basered+5;
basegreen = basegreen+2;
baseblue=baseblue-2;
rslid[counter].valueAction = 0.5;
//schedule.sched(3, {rslid[counter].valueAction = 0.5;}); //this schedules initialization 0.5 seconds after loading
}); // end counter loop
revresponder = OSCresponder(s.addr, "fx32", {arg temp, value1, value2;
number
{for(1,4, {arg count;
rslid[count].valueAction = value2[count+3];
});
}.defer;
}).add;
//NOTE: binshift uses freqshift's fx
CmdPeriod.doOnce({revresponder.remove; mywindow.close});
}).send(s);
nil;
}); //end scheduling
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//Routing Matrix
//First make the actual routing function:
SynthDef("inputlink", {arg in=98, out=99, startfades=0, fades=1, triggerenv=1, fadetime=0.1;
Out.ar(out, EnvGen.kr(Env([startfades,fades],[fadetime]),triggerenv)*InFeedback.ar(in+50)); // The actual routing
takes place here
}).send(s);
for(1,18, {arg count;
//Then the main stereo bus routing function:
SynthDef("LR output"++count.asString, {arg in=98, out=99, fades=0, panning=0.5, volume=0, targetnum; var sig,
fadetime=0.1, masterpulse30;
sig = Pan2.ar(Lag.kr(fades, fadetime)*InFeedback.ar(in+50)*(Lag.kr(volume, fadetime)), (panning*2)-1);
masterpulse30 = Impulse.kr(30);
if(count != 11, {if(count != 14, {
SendReply.kr(masterpulse30, "outlevelL"++count.asString, Amplitude.ar(sig[0],0,1)); //Sets Meter sig, attack
time, release time
SendReply.kr(masterpulse30, "outlevelR"++count.asString, Amplitude.ar(sig[1],0,1)); //Sets Meter sig, attack
time, release time
}, {})});
Out.ar(out, sig);
}).send(s);
});
//Then make the overall synthdef for the router
routingmatrix = SynthDef("Routing Matrix", {arg test=0; var mywindow, harmshiftslid, delaytimeslid, feedbackslid,
rootpitchslid, tempsynth, row1, buttonfunc,
voffset = 20, routing, text1, text1call, border, textxpos, textypos, textlength, textheight, textred, textgreen,
textblue, textdesc, counter, skip = 5,
textredchange, textgreenchange, textbluechange, slid = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], outslid =
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
resetbutton, lvlmapping1, lvlmapping2, lvlmapping3, outmeterL =
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],outmeterR = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
buttonlist, panknob = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], pan1responder, pan2responder,
slid1responder, slid2responder, setresponder,
meter1responder, meter2responder, meter3responder;
//--------------------//the "lvlmapping1" function determines the routing coefficients for all input buses
lvlmapping1 = {arg lvl1=1, lvl2=1, lvl3=1, lvl4=1, lvl5=1, lvl6=1, lvl7=1, lvl8=1, lvl9=1, lvl10=1, lvl11=1, lvl12=1,
lvl13=1, lvl14=1, lvl15=1,
lvl16=1, lvl17=1, lvl18=1, audio1, lvl1imp, lvl1impdel;
/*NOTES: buses coming from sources into the matrix are numbered 23-32. Buses leaving FX are
numbered 35-42 internally. MAIN OUTS ARE BUSES 33-34.*/
//Input Metering
audio1 = [(SoundIn.ar(0)*lvl1), (SoundIn.ar(1)*lvl2), (SoundIn.ar(2)*lvl3), (SoundIn.ar(3)*lvl4),
(SoundIn.ar(4)*lvl5),(SoundIn.ar(5)*lvl6), (SoundIn.ar(6)*lvl7),
(SoundIn.ar(7)*lvl8), (InFeedback.ar(23)*lvl9), (InFeedback.ar(24)*lvl10), (InFeedback.ar(25)*lvl11),
(InFeedback.ar(26)*lvl12), (InFeedback.ar(27)*lvl13),
(InFeedback.ar(28)*lvl14), (InFeedback.ar(29)*lvl15), (InFeedback.ar(30)*lvl16),
(InFeedback.ar(31)*lvl17), (InFeedback.ar(32)*lvl18)];
Out.ar(50, audio1); //route all to 50
lvl1imp = Impulse.kr(30);
for(1,18, {
arg targetnum; var targetname;
targetname = "level"++targetnum.asString;
SendReply.kr(lvl1imp, targetname.asString, Amplitude.ar(audio1[targetnum-1],0,1)); //Sets Meter sig,
attack time, release time
});
}.play;
//-----------------------------------------------------------------------------------------------------//Now make the routing matrix window
mywindow = GUI.window.new("Routing Matrix", Rect(58, 75, 730, 400)).front;
mywindow.view.background = Color(0,0,0);
textxpos = 11;
textypos = 21;
textlength = 162;
textheight = 18;
textred = 120;
textgreen = 130;
textblue = 170;
textredchange = -2;
textgreenchange = -1;
textbluechange = 1;
textdesc = Array.new(16);
textdesc = [" Audio Input Channel 1", " Audio Input Channel 2", " Audio Input Channel 3", " Audio Input Channel
4", " Audio Input Channel 5",
" Audio Input Channel 6", " Audio Input Channel 7", " Audio Input Channel 8", " FX Bus 25 (Pattern
Delay)", " FX Bus 26 (Harmonizer)",
" FX Bus 27 (Recorder)", " FX Bus 28 (Granulator)"," FX Bus 29 (Ring Modulator)"," FX Bus 30 (Freq
Shifter)", " FX Bus 31 (FFT/Convolution)",
" FX Bus 32 (Reverb)"];
border = StaticText(mywindow, Rect(textxpos-1,textypos-1,textlength+2,(textheight
+2)*8)).background_(Color.new255(255,255,
255)); //white Border for Audio input text
border = StaticText(mywindow, Rect(textxpos-1,textypos1+(skip)+skip+((textheight+2)*10),textlength+2,(textheight+2)*8)).background_(Color.new255(255,
255,255)); //white border for FX sends text
border = StaticText(mywindow, Rect(textxpos-1,textypos1+(skip)+((textheight+2)*8),textlength+2,(textheight+2)*2)).background_(Color.new255(255,
255,255)); //white border wav player text
text1 = {arg xpos, ypos, length, height, red, green, blue, desc;
StaticText(mywindow,
Rect(xpos,ypos,length,height)).background_(Color.new255(red,green,blue)).string_(desc);
};
counter = 0;
while({counter < 8},
{
text1call =
text1.value(textxpos,textypos+(20*counter),textlength,textheight,textred+(counter*textredchange),textgreen+(counter*te
xtgreenchange),textblue+
(counter*textbluechange),textdesc[counter]);
counter = counter + 1;
};
);
//Make the wav player text windows
StaticText(mywindow, Rect(textxpos, textypos+skip+(160),
textlength,textheight)).background_(Color.new255(115,155,115)).string_("Wave Player L Channel");
StaticText(mywindow, Rect(textxpos, textypos+skip+(180),
textlength,textheight)).background_(Color.new255(115,155,115)).string_("Wave Player R Channel");
textred = 151;
textgreen = 131;
textblue = 147;
textredchange = 2;
textgreenchange = -2;
textbluechange = -2;
while({counter < 16},
{
text1call =
text1.value(textxpos,textypos+(20*(counter))+skip+45,textlength,textheight,textred+((counter)*textredchange),textgreen
+(textgreenchange*(counter)),
textblue+(textbluechange*(counter)),textdesc[counter]);
counter = counter + 1;
};
);
textred = 120;
textgreen = 130;
textblue = 170;
textredchange = -2;
textgreenchange = -1;
textbluechange = 1;
//function to generate all buttons/sliders/db boxes for routing matrix
buttonfunc = {arg foobar; var vertoffset = 20, horizoffset = 320, red, green, blue, redchange, greenchange,
bluechange,dim, slid1, slidxpos, slidwidth, slidheight,
slidthumbsize, lvlmeterwidth,buttonx, buttony, loopx, loopy, init;
red = textred;
green = textgreen;
blue = textblue;
redchange = textredchange;
greenchange = textgreenchange;
bluechange = textbluechange;
dim = 1.1;
slidxpos = 180;
slidwidth = 46;
slidheight = 20;
slidthumbsize = 10;
lvlmeterwidth = 40;
horizoffset = slidxpos+10+slidwidth+40+lvlmeterwidth;
border = StaticText(mywindow, Rect(slidxpos1,vertoffset,slidwidth+6+lvlmeterwidth+40,(textheight+2)*8)).background_(Color.new255(255,
255,255)); //white border background audio in slider
border = StaticText(mywindow, Rect(slidxpos1,vertoffset+5+(8*20),slidwidth+6+lvlmeterwidth+40,(textheight+2)*2)).background_(Color.new255(255,
255,255)); //white border background wav player text
border = StaticText(mywindow, Rect(slidxpos1,vertoffset+10+(10*20),slidwidth+6+lvlmeterwidth+40,(textheight+2)*8)).background_(Color.new255(255,
255,255)); //white border background audio in slider
//Below is the table of reserved nodes for matrix routing
buttonx = [1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, //audio input 1(0) routing nodes
1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, //audio 2(1) nodes
1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, //etc
1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434,
1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534,
1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634,
1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734,
1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, //audio input 8(7)
nodes
1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, //Wav L routing
nodes
1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210,// Wav R routing
nodes
1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, //FX channel 1
routing nodes
1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, //FX channel 2
routing nodes
1311, 1313, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, //etc
1411, 1414, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420,
1511, 1515, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520,
1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620,
1711, 1717, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720,
1811, 1818, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820; //FX channel 8
routing nodes
];
buttonlist = Array2D(18,9);
for(0,17, //y (vertical) axis loop start for drawing gui elements
{arg loopy; var snbox = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], meter = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
metertarget = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
outsnbox = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], outmetertargetL =
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], outmetertargetR = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
lvltarget, vertbump=0, inoffset=0, lrsize, fxoffset=0, outputfaderoffset;
if(loopy==8, {red=115; green = 155; blue=115; redchange=0; greenchange=0; bluechange=0;
vertbump=5; inoffset=15});
if(loopy==9, {red=115; green = 162; blue=115; redchange=0; greenchange=0; bluechange=0;
vertbump=5;inoffset=15;});
if(loopy>9, {red=153; green=129; blue=151; redchange=2; greenchange= -2; bluechange= -2;
vertbump=10;inoffset=15});
if(loopy<10, {fxoffset=0;},{fxoffset=25;});
for(0,9, //x (horizontal) axis loop start for drawing gui elements
{arg loopx;
var label, horizbump=0, index=buttonx[loopx+(loopy*10)];
if(loopx<8, {label =(loopx+25).asString; horizbump=0; lrsize=0;}, //Displays Bus Number 25-32
{if(loopx<9,{label = "LR"; horizbump=5; lrsize=10},{})}); //Attaches "L"+"R" to main outs
if((loopy-10)==loopx, { //makes an unlabeled non-button so buses can't be fed back into
themselves
buttonlist[loopy,loopx] = Button(mywindow, Rect(horizoffset+(20*loopx)+horizbump,
vertoffset
+(loopy*20)+vertbump,20,20))
.states_([["", Color.black,
Color.new255(red+(loopy*redchange),green+(loopy*greenchange),blue+(loopy*bluechange))],["", Color.black,
Color.new255(red+(loopy*redchange),green+(loopy*greenchange),blue+(loopy*bluechange))]])}, {if(loopx < 8, {
buttonlist[loopy,loopx] = Button(mywindow, Rect(horizoffset+(20*loopx)+horizbump,vertoffset+(loopy*20)
+vertbump,20+lrsize,20))
.states_([[label.asString, Color.black,
Color.new255(red+(loopy*redchange),green+(loopy*greenchange),blue+(loopy*bluechange))],[label.asString,
Color.black, Color.red]]).action = {arg choice; var index=buttonx[loopx+(loopy*10)];
matrixstore[loopy,loopx] = buttonlist[loopy,loopx].value;
if (choice.value == 1, {s.sendMsg("/s_new", "inputlink", index, 1, 1, "in", (loopy-fxoffset),
"out", (loopx+25)); },
{s.sendMsg("n_free", index) } ) };
},//Makes and routes the non main-output buses
{
if(loopx<9,{ //this makes pairs of routing busses starting at 500 for LR out
s.sendMsg("/s_new", "LR output"++(loopy+1).asString, index, 1, 1, "in", (loopy-fxoffset), "out", (0));
buttonlist[loopy,loopx] = Button(mywindow, Rect(horizoffset+(20*loopx)+horizbump,vertoffset
+(loopy*20)+vertbump,20+lrsize,20))
.states_([[label.asString, Color.black,
Color.new255(red+(loopy*redchange),green+(loopy*greenchange),blue+(loopy*bluechange))],[label.asString,
Color.black, Color.red]]).action = {arg choice; matrixstore[loopy,loopx] =
buttonlist[loopy,loopx].value;
if (choice.value == 1, {
if(loopy == 13, {s.sendMsg(\n_set, 3028, \fades, 1)},{
if(loopy == 10, {s.sendMsg(\n_set, 4025, \fades, 1)}, {s.sendMsg("/n_set",
index, "fades", 1);});}); }, //end of "choice 1"
{if(loopy ==13,{s.sendMsg(\n_set, 3028, \fades,0) },{
if(loopy==10, {s.sendMsg(\n_set, 4025, \fades, 0)}, {s.sendMsg("/n_set",
index, "fades", 0);}) })} ) }; //LR for grain effect and stereo delay
},{};);});//Makes and routes the main output buses
});//end of if
};); //end of loopx
//this is for input faders/meters
snbox[loopy] = NumberBox(mywindow, Rect(slidxpos+1+slidwidth, vertoffset+1+(20*loopy)+vertbump,
40,18)).background_(Color.new255(red*dim+
(loopy*redchange),green*dim+(loopy*greenchange),blue*dim+(loopy*bluechange)));
slid[loopy] = SCSlider(mywindow, Rect(slidxpos, vertoffset+1+(loopy*20)+vertbump, slidwidth, slidheight2)).background_(Color.new255(red+
(loopy*redchange),green+(loopy*greenchange),blue+(loopy*bluechange))).thumbSize_(slidthumbsize);
slid[loopy].action = {var slidgain;
slidgain = (slid[loopy].value)*(slid[loopy].value)*2; //implement scaling function here
snbox[loopy].value = ampdb(slidgain);
lvltarget = "lvl"++(loopy+1).asString;
lvlmapping1.setn(lvltarget.asSymbol, slidgain); //so what's difference between "set" and "setn"?
};
meter[loopy] = SCLevelIndicator(mywindow, Rect(slidxpos+slidwidth+40, vertoffset+(20*loopy)+vertbump, 45,
20));
metertarget[loopy] = "level"++(loopy+1).asString;
meter1responder = OSCresponder(s.addr, metertarget[loopy].asSymbol, {arg time, resp, msg;
meter[loopy].value = msg[3].ampdb.linlin(-40,0,0,1);
}.defer
}).add;
meter[loopy].warning = -2.dbamp;
meter[loopy].critical = -1.dbamp;
{
//makes whitebackground for panning knobs & output faders/meters
StaticText(mywindow, Rect(horizoffset+200,
vertoffset+(loopy*20)+vertbump,107,20)).background_(Color.new255(255,255,255));
//this is for output faders/meters
outputfaderoffset = 356;
outsnbox[loopy] = NumberBox(mywindow, Rect(slidxpos+1+slidwidth+outputfaderoffset,
vertoffset+1+(20*loopy)+vertbump, 40,18))
.background_(Color.new255(red*dim+(loopy*redchange),green*dim+(loopy*greenchange),blue*dim+(loopy*blue
change)));
outslid[loopy] = SCSlider(mywindow, Rect(slidxpos+outputfaderoffset, vertoffset+1+(loopy*20)+vertbump,
slidwidth, slidheight-2))
.background_(Color.new255(red+(loopy*redchange),green+(loopy*greenchange),blue+(loopy*bluechange))).thu
mbSize_(slidthumbsize);
outslid[loopy].action = {var slidgain;
if(loopy < 10, {fxstore[10, loopy] = outslid[loopy].value;}, {fxstore[11, (loopy-10)] = outslid[loopy].value;}); //
store presets
slidgain = (outslid[loopy].value)*(outslid[loopy].value)*2; //implement scaling function here
outsnbox[loopy].value = ampdb(slidgain);
lvltarget = "lvl"++(loopy+1).asString;
if(loopy == 10, {s.sendMsg(\n_set, 4025, \gain, slidgain)},
{if(loopy == 13, {s.sendMsg(\n_set, 3028, \gain, slidgain)},
{s.sendMsg(\n_set, buttonx[(10*loopy)+8], "volume", slidgain);})});
};
outmeterL[loopy] = SCLevelIndicator(mywindow, Rect(slidxpos+slidwidth+40+outputfaderoffset,
vertoffset+(20*loopy)+vertbump, 50, 20));
outmeterR[loopy] = SCLevelIndicator(mywindow, Rect(slidxpos+slidwidth+40+outputfaderoffset+51,
vertoffset+(20*loopy)+vertbump, 50, 20));
outmetertargetL[loopy] = "outlevelL"++(loopy+1).asString;
outmetertargetR[loopy] = "outlevelR"++(loopy+1).asString;
meter2responder = OSCresponder(s.addr, outmetertargetL[loopy].asSymbol, {arg time, resp, msg;
{
outmeterL[loopy].value = msg[3].ampdb.linlin(-40,0,0,1);
}.defer
}).add;
meter3responder = OSCresponder(s.addr, outmetertargetR[loopy].asSymbol, {arg time, resp, msg;
{
outmeterR[loopy].value = msg[3].ampdb.linlin(-40,0,0,1);
}.defer
}).add;
outmeterL[loopy].warning = -2.dbamp;
outmeterL[loopy].critical = -1.dbamp;
outmeterR[loopy].warning = -2.dbamp;
outmeterR[loopy].critical = -1.dbamp;
//Makes panning knobs
StaticText(mywindow, Rect(horizoffset+200+1,
vertoffset+(loopy*20)+vertbump+1,18,18)).background_(Color.new255(red+(loopy*redchange),
green+(loopy*greenchange),blue+(loopy*bluechange)));
GUI.skins.default.knob.mySkin = ( );
GUI.skins.default.knob.mySkin.dial_(Color.new255(0,0,0)).center_(Color.new255(red+(loopy*redchange)+35,gre
en+(loopy*greenchange)+35,
blue+(loopy*bluechange)+35)).scale_(Color.new255(red+(loopy*redchange)60,green+(loopy*greenchange)-60,blue+(loopy*bluechange)-60)).level_(Color.new255(255,0,0));
//"If" turns off pan knobs for stereo output tracks
if(loopy == 10, {StaticText(mywindow, Rect(horizoffset+200+1, vertoffset+(loopy*20)+vertbump+1, 18,
18)).string_("NA");
panknob[loopy] = Knob.new(mywindow, Rect(0,0,0,0));},
{if(loopy == 13, {StaticText(mywindow, Rect(horizoffset+200+1, vertoffset+(loopy*20)+vertbump+1, 18,
18)).string_("NA");
panknob[loopy] = Knob.new(mywindow, Rect(0,0,0,0));},
{
panknob[loopy] = Knob.new(mywindow, Rect(horizoffset+200+1,
vertoffset+(loopy*20)+vertbump+1,18,18)).skin_(GUI.skins.default.knob.mySkin);
panknob[loopy].centered_(true);
panknob[loopy].action = {
if(loopy < 10, {fxstore[12, loopy] = panknob[loopy].value;}, {fxstore[13, (loopy-10)] =
panknob[loopy].value;}); // store presets
s.sendMsg("/n_set", buttonx[(10*loopy)+8], "panning", panknob[loopy].value);
};
if(loopy==8,{panknob[loopy].valueAction = 0;},{if(loopy==9,{panknob[loopy].valueAction = 1;},{
panknob[loopy].valueAction = 0.5;});
});
});
}); //end of if(loopy ==10
};);
//end of loopy
slid1responder = OSCresponder(s.addr, "matrixtop", {arg temp, value1, value2;
// responder for
setting presets
{for(0,9, {arg count;
outslid[count].valueAction = value2[count+3];
});
}.defer;
}).add;
slid2responder = OSCresponder(s.addr, "matrixbottom", {arg temp, value1, value2; //additional responder for
setting presets
{for(0,7, {arg count;
outslid[count+10].valueAction = value2[count+3];
});
}.defer;
}).add;
pan1responder = OSCresponder(s.addr, "pantop", {arg temp, value1, value2;
setting presets
{for(0,9, {arg count;
panknob[count].valueAction = value2[count+3];
});
}.defer;
}).add;
pan2responder = OSCresponder(s.addr, "panbottom", {arg temp, value1, value2;
setting presets
{for(0,7, {arg count;
panknob[count+10].valueAction = value2[count+3];
});
}.defer;
}).add;
// responder for
//additional responder for
resetbutton = Button(mywindow, Rect(10,10,10,10)).states_([["",Color.black,
Color,red],["",Color.black,Color.yellow]])
.action = {arg reset;
if(reset.value == 1, {
for(0,17,
{arg initall;
slid[initall].valueAction_(0.7071);
outslid[initall].valueAction_(0.7071);
if(initall == 8, {panknob[initall].valueAction_(0)},
{if(initall == 9, {panknob[initall].valueAction_(1)},
{panknob[initall].valueAction_(0.5);})});
});
resetbutton.value = 0;},{});
};
AppClock.sched(2, {resetbutton.valueAction = 1;
nil;}); //this schedules a manual fader reset to 0
};//End of Buttonfunc function
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//internal function to manage matrix routing
row1 = buttonfunc.value(99); //triggers the above function (routing matrix gui)
setresponder = OSCresponder(s.addr, "matrixset", {arg temp, value1, value2;
{//matrixlist =
Object.readArchive(presetdirectory.asString++p2directory++value1.asString++"matrix");
for(0,17, {arg county; //change back to 0,17
for(0,8, {arg countx; //change back to 0,8
//matrixlist[county,countx].postln;
buttonlist[county,countx].valueAction = matrixlist[county, countx];
})
});
}.defer;
}).add;
CmdPeriod.doOnce({pan1responder.remove; pan2responder.remove; slid1responder.remove;
slid2responder.remove; setresponder.remove; meter1responder.remove; meter2responder.remove;
meter3responder.remove; mywindow.close});
}).send(s);
//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------masterout = SynthDef("Master Stereo Out", {arg monitor; var level;
Out.ar([0], [InFeedback.ar(33)]);
Out.ar([1], [InFeedback.ar(34)]);
}).send(s);
AppClock.sched(0.5,{schedule.advance(3); //because of send(s) priority, this sets the faders to zero, .5 seconds after
loading
nil
});
AppClock.sched(0.5, {
synthcall = ["Pattern Delay Write","Delay On Off", "Pitch Shift", "Grain Engine", "Ring Mod", "Freq Shift", "Convolution",
"Reverb", "Master Stereo Out"];
synthnodes = [3025, 4025, 3026, 3028, 3029, 3030, 4031, 3032, 3033];
for(0, 8, {arg num;
s.sendMsg("/s_new", synthcall[num].asString, synthnodes[num], 1, 1);
//synthcall[num].post; " ".post; synthnodes[num].postln;
});
nil;
});//end appclock
)

Similar documents

SystemC with Borland C++ Builder 5.0

SystemC with Borland C++ Builder 5.0 More designs from the example directory of the original SystemC source codes are tested with Borland C++ Builder. In the FIR design, the register-transfer level version of the design consisting of ...

More information