6 Foot Rabbit 
WARNING this is beta, but i thought i should put it up i like the way it works more than some of my other patches, I still need to: 
Fix reverse on the beatcut section 
Fix bug with loop on startup 
Get Effects Working Better (ie PlayerInputProxy) 
A few other things 

! ! If anyone wants to lend a hand or has any suggestions i would appreciate it.  Esp other ideas about cut methods.  Also if anyone has any badass effect Instr's that they want to send my way... :) 

Requirements: 
LoopBuf Ugen 
MidiSlider Class (or comment out the midislider code) 

Instructions: 
(Optional) set variable num to change number of instances, All instances share an array of samples 
Load 1 or more samples 
(This is a bug) if you want to use loop mode, you have to switch away and then back, other wise choose your cut method (just the first time) 
Hit Start 

[Load] - Load Samples 
[-][Sample Select] - Remove Sample, Select Sample 
[CutMode][p/e] - Method of sample playback, switch between effect and cut parameters 
[Pitch][f/r] - Pitch, reverse 
[Sync][Quantize] - Snap to quantise for start, stop and switching of cut methods 
[Start] 

The effects are now WORKING, (well to some extent, still no, individual patches, or guis) The way it works is. it looks "/Applications/Supercollider/Instr/" (you can change that to you instr dir) and into the file Effects.rtf, any effects you want need to be name like Instr([\Effect, \yourEffect]...) then you can select the effect from the popup menu, turn it on or off and call .gui on the patch.  XOut and mixing are not yet working, 
(
/////////////////////////////////////////////////////////////////

/// GLOBAL VARS

var window, synthDefArray, num = 2, mainGroup;

/// BUFFER VARS

var bufferArray, pathPopUpArray, volMidiArray;

////// INSTR DIRECTORY

var instrRtfs, rtfArray, rtfString;
var file, instrArray, instrNameArray;
var instrDir;
var instrProb;

////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SYNTHDEFS
////////////////////////////////////////////////////////////////////////////////////////////////////////////

////// LOOPER

SynthDef("slMono", {
        arg bus, buffer, amp, mute = 1, rate, length, offset, slope = 0.005;
        var env, sound;
        env = EnvGen.kr(Env.new([0,1,1,0], [slope / 2, 1 - slope, slope / 2]),
                timeScale:length, doneAction:2) * (amp * mute);
        sound = PlayBuf.ar(1, buffer, rate, 1.0, offset * 44100, 1) * env;
        Out.ar(bus, [sound, sound]);
}).load(s);

SynthDef("slStereo", {
        arg bus, buffer, amp, mute = 1, rate, length, offset, slope = 0.005;
        var env, sound;
        env = EnvGen.kr(Env.new([0,1,1,0], [slope / 2, 1 - slope, slope / 2]),
                timeScale:length, doneAction:2) * (amp * mute);
        sound = PlayBuf.ar(2, buffer, rate, 1.0, offset * 44100, 1) * env;
        Out.ar(bus, sound);
}).load(s);

SynthDef("slMonoLoop", {
        arg bus, buffer, amp, mute = 1, rate, length, offset, speed;
        var env, sound, offSmp;
        offSmp = offset * 44100;
        env = EnvGen.kr(Env.new([0,1,1,0], [0.01, 0.98, 0.01]),
                timeScale:length, doneAction:2) * (amp * mute);
        sound = LoopBuf.ar(1, buffer, rate, 1.0, offSmp, offSmp + (speed * 44100)) * env;
        Out.ar(bus, [sound, sound]);
}).load(s);

SynthDef("slStereoLoop", {
        arg bus, buffer, amp, mute = 1, rate, length, offset, speed;
        var env, sound, offSmp;
        offSmp = offset * 44100;
        env = EnvGen.kr(Env.new([0,1,1,0], [0.01, 0.98, 0.01]),
                timeScale:length, doneAction:2) * (amp * mute);
        sound = LoopBuf.ar(2, buffer, rate, 1.0, offSmp, offSmp + (speed * 44100)) * env;
        Out.ar(bus, sound);
}).load(s);

synthDefArray = ["slMono", "slStereo", "slMonoLoop", "slStereoLoop"];

Instr(\slInput, {arg inbus; In.ar(inbus, 2)});

////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// INITIALIZATION
////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// BUFFER INIT

bufferArray = Array.new;
pathPopUpArray = Array.new;
volMidiArray = Array.new;
mainGroup = Group.head(RootNode.new);

////// INSTR DIRECTORY

instrDir = "/Applications/Supercollider/Instr/";

instrRtfs = Cocoa.getPathsInDirectory(instrDir);
(instrRtfs.size - 1).do({
        arg i;
        file = File(instrDir ++ instrRtfs.at(i + 1), "r");
        String.readNew(file).compile.value;
        file.close;
});

Library.at(\Instr).at(\Effect).do({
        arg file;
        file.do({
                arg instr;
                instrArray = instrArray.add(instr.name);
        });
        
});

instrArray.do({
        arg item;
        instrNameArray = instrNameArray.add(item.at(1).asString);
});

////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GUI
////////////////////////////////////////////////////////////////////////////////////////////////////////////

window = SCWindow("6 Foot Rabbit", Rect(0, 0, (num * 105) + 5, 415), false).front;
window.view.background_(Color(0.2, 0.5, 0.2));
window.onClose_({
        bufferArray.do({
                arg item;
                item.free;
        });
        volMidiArray.do({
                arg item;
                item.free;
        });
});

////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// INSTANCES
////////////////////////////////////////////////////////////////////////////////////////////////////////////

num.do({
arg l;
var synth, sampGroup, sampBus;

/// GUI VARS

var sampleComp, effectComp, mixComp, loopComp, beatComp, grainComp;

var pathPopUp, cutPopUp, effectCutButton,effectPopUpArray23, effectOnOffArray, mixSlider;

var pathPopUpValue = 0, cutPopUpValue =4, syncValue = 0, syncLength = 16, pitchValue = 1, revValue = 1, startValue = 0;

/// CUT METHOD VARS

var cutTask, bcBarLength = 32, bcBarOffset = 0, bcBarHigh = 32, bcTableFill, bcTally = 0;

var bcRhythmArray, bcAmpArray, bcPositionArray, bcProbArray, bcRhythmArrayCopy, bcSampleArray;

var bcLengthValue = 1, bcEntropyValue = 0, bcSampleEntropy = 0, bcRollProb = 0, bcEntropyFillValue = 0;

////// LOOP

var lLoopStart = 0, lLoopEnd = 1, loopSelect = nil, loopRange;

////// AUDIO THRU

////// BEAT CUT

////// GRAINULAR

var gPosition = 0, gPositionVar = 0.4, gDensity = 0.3, gDensityVar = 0.7, gLength = 0, gLengthVar = 1;

var gSlope = 0.4, gSlopeVar = 0.6, gAmp = 0, gAmpVar = 1;

////// EFFECTS

var effectGroup1, effectGroup2, effectGroup3, effectGroup4;

var effectPatch1, effectPatch2, effectPatch3, effectPatch4;

var effectGroupArray, effectPatchArray;

////// MIX

var ampValue = 1, panValue = 0;

/////// PATCH

var patch, patchFunction, patchGroup;
var effectOnArray, effectSocketArray;
var prevPatchArray, prevOnArray, prevArgsArray;

////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// INITIALIZATION
////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// GLOBAL INIT

sampGroup = Group.head(mainGroup);
sampBus = Bus.audio(s, 2);
patchGroup = Group.tail(mainGroup);
//sampBus = Bus.new;

effectGroup1 = Group.tail(sampGroup);
effectGroup2 = Group.tail(sampGroup);
effectGroup3 = Group.tail(sampGroup);
effectGroup4 = Group.tail(sampGroup);

/// CUT METHOD INIT

bcProbArray = [0.1, 0.2, 0.4, 0.5, 0.4];

////// OTHER

effectOnArray = Array.fill(5, {0});
effectSocketArray = Array.fill(5, {0});
prevPatchArray = Array.fill(5, {0});
prevOnArray = Array.fill(5, {0});
prevArgsArray = Array.fill(5, {0});

patch = Patch(\slInput, [sampBus.index]);

////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GUI
////////////////////////////////////////////////////////////////////////////////////////////////////////////

////// SAMPLE

sampleComp = SCCompositeView(window, Rect(5 + (l*105), 5, 100, 125))
        .background_(Color(0.4, 0.7, 0.4));
        
SCButton(sampleComp, Rect(10 + (l*105), 10, 90, 15))
        .states_([["Load", Color.black, Color(0.2, 0.5, 0.2)]])
        .action_({
                CocoaDialog.getPaths({
                        arg paths;
                        var sf, low, high, bars;
                        paths.do({
                                arg item, i;
                                var bundle, popUpItems; 
                                bundle = CXBundle.new;
                                bufferArray = bufferArray.add(Sample.new(item));
                                popUpItems = pathPopUpArray.at(0).items.add(bufferArray.last.name);
                                pathPopUpArray.do({
                                        arg item;
                                        item.items_(popUpItems);
                                });                             
                                bufferArray.last.prepareToBundle(sampGroup, bundle);
                                bundle.send(s, 0);
                                bufferArray.last.guessBeats;
                                bufferArray.last.beats.postln;
                        });
                }, {"Canceled".postln}, 20);
        });

SCButton(sampleComp, Rect(10 + (l*105), 30, 15, 15))
        .states_([["-", Color.black, Color(0.2, 0.5, 0.2)]])
        .action_({
                var items;
                bufferArray.at(pathPopUpValue).free;
                bufferArray.removeAt(pathPopUpValue);
                items = pathPopUpArray.at(0).items;
                items.postln;
                items.removeAt(pathPopUpValue.asInteger);
                items.postln;
                pathPopUpArray.do({
                        arg item;
                        item.items_(items);
                });
        });
        
pathPopUpArray = pathPopUpArray.add(SCPopUpMenu(sampleComp, Rect(25 + (l*105), 30, 75, 15))
        .action_({
                arg view;
                pathPopUpValue = view.value;
        });
);

cutPopUp = SCPopUpMenu(sampleComp, Rect(10 + (l*105), 50, 75, 15))
        .items_(["Loop", "BeatCut", "Granular"])
        .action_({
                arg view;
                var syncFunc, viewValue;
                viewValue = view.value;
                if (cutPopUpValue != viewValue, {       
                        //effectCutButton.valueAction_(0);
                        syncFunc = {
                                if (startValue == 1, {
                                        cutTask.stop;
                                        synth.free
                                });
                                if (viewValue == 0, {
                                        cutTask = Task({
                                                var length = 1, rate;
                                                loop({
                                                        rate = ((bufferArray.wrapAt(pathPopUpValue).size / 44100) / Tempo.beats2secs(
                                                                bufferArray.wrapAt(pathPopUpValue).beats*4));
                                                        length = (lLoopEnd - lLoopStart) * (bufferArray.wrapAt(pathPopUpValue).size / 44100)
                                                                 ;
                                                        synth=Synth(synthDefArray.at((bufferArray.wrapAt(pathPopUpValue).numChannels-1)),[
                                                                "bus", sampBus.index,
                                                                "buffer", bufferArray.wrapAt(pathPopUpValue).bufnum,
                                                                "amp", ampValue,
                                                                "rate", rate * pitchValue *revValue,
                                                                "length", (length / rate) * (1 / pitchValue),
                                                                "offset", (bufferArray.at(pathPopUpValue).size / 44100) * lLoopStart
                                                        ], sampGroup, \addToHead);
                                                        (((lLoopEnd - lLoopStart) * (bufferArray.wrapAt(pathPopUpValue).beats * 4)) 
                                                                * (1 / pitchValue)).wait;
                                                });
                                        }, TempoClock.default);
                                });
                                if (viewValue == 1, {
                                        cutTask = Task({
                                                var offset, dbeat, sample, length, loop;
                                                loop({
                                                        bcBarLength.do({
                                                                arg i;
                                                                i = i + bcBarOffset;
                                                                if (bcRhythmArrayCopy.at(i) != 0, {
                                                                        sample = [pathPopUpValue, bcSampleArray.at(i)].at(
                                                                                        windex([1 - bcSampleEntropy, bcSampleEntropy]));
                                                                        offset = [
                                                                                bcPositionArray.at((i % (bufferArray.wrapAt(sample).beats 
                                                                                        * 16)).asInteger), 
                                                                                (bufferArray.wrapAt(sample).beats * (16.rand))
                                                                        ].at(windex([1 - bcEntropyValue, bcEntropyValue]));
        
                                                                        loop = windex([1 - bcRollProb, bcRollProb]);
                                                                        length =Tempo.beats2secs(0.25)
                                                                                *(bcRhythmArrayCopy.at(i)*bcLengthValue).max(0.2);
                                                                        if (((loop == 1) && (bcRhythmArrayCopy.at(i) < 4)), {
                                                                                Synth(synthDefArray.at(bufferArray.wrapAt(sample).numChannels+1),
                                                                                [
                                                                                        "bus", sampBus.index,
                                                                                        "buffer", bufferArray.wrapAt(sample).bufnum,
                                                                                        //"amp", bcAmpArray.at(i),
                                                                                        "amp", ampValue,
                                                                                        "rate", ((bufferArray.wrapAt(sample).size / 44100) / 
                                                                                                Tempo.beats2secs(bufferArray.wrapAt(sample).beats*4))
                                                                                                * pitchValue * revValue,
                                                                                        "length", length,
                                                                                        "speed",Tempo.beats2secs([0.0625,0.125,0.25,0.33].choose),
                                                                                        "offset",(((bufferArray.wrapAt(sample).size / 44100) /
                                                                                                (bufferArray.wrapAt(sample).beats * 16))*offset)
                                                                                                * pitchValue
                                                                                ], sampGroup, \addToHead);
                                                                        }, {
                                                                                Synth(synthDefArray.at((bufferArray.wrapAt(sample).numChannels-1)
                                                                                .min(1)),[
                                                                                        "bus", sampBus.index,
                                                                                        "buffer", bufferArray.wrapAt(sample).bufnum,
                                                                                        //"amp", bcAmpArray.at(i), sounds bad
                                                                                        "amp", ampValue, 
                                                                                        "rate", ((bufferArray.wrapAt(sample).size / 44100) / 
                                                                                                Tempo.beats2secs(bufferArray.wrapAt(sample).beats*4))
                                                                                                * pitchValue * revValue,
                                                                                        "length", length,
                                                                                        "offset",(((bufferArray.wrapAt(sample).size / 44100) /
                                                                                                (bufferArray.wrapAt(sample).beats * 16))*offset)
                                                                                                * pitchValue
                                                                                ], sampGroup, \addToHead);
                                                                                //bufferArray.wrapAt(sample).beats.postln;
                                                                        });
                                                                        if (bcEntropyFillValue == 1, {
                                                                                bcPositionArray.put(i, offset);
                                                                        });
                                                                });
                                                                0.25.wait;
                                                        });
                                                });
                                        }, TempoClock.default);
                                });
                                if (viewValue == 2, {
                                        cutTask = Task({
                                                loop({
                                                        Synth(synthDefArray.at((bufferArray.wrapAt(pathPopUpValue).numChannels - 1)), [
                                                                "bus", sampBus.index,
                                                                "buffer", bufferArray.wrapAt(pathPopUpValue).bufnum,
                                                                "amp", rrand(gAmp, gAmpVar) * ampValue,
                                                                "rate", ((bufferArray.wrapAt(pathPopUpValue).size / 44100) / 
                                                                        Tempo.beats2secs(bufferArray.wrapAt(pathPopUpValue).beats * 4))
                                                                        * pitchValue * revValue,
                                                                "length", rrand(gLength, gLengthVar) * 0.5,
                                                                "slope", rrand(gSlope, gSlopeVar),
                                                                "offset",(bufferArray.at(pathPopUpValue).size/
                                                                        44100)*rrand(gPosition,gPositionVar)
                                                        ], sampGroup, \addToHead);
                                                        (rrand(gDensity, gDensityVar) * 0.5).wait;
                                                });
                                        }, SystemClock);
                                });
                                if (startValue == 1, {cutTask.start});
                        };
                        if (syncValue == 0, {
                                TempoClock.default.schedAbs(
                                        TempoClock.default.elapsedBeats.trunc(syncLength) + syncLength, {
                                                syncFunc.value;
                                                nil;
                                        });     
                        }, {
                                syncFunc.value;
                        });
                });
                cutPopUpValue = viewValue;
                effectCutButton.valueAction_(0);
                effectCutButton.valueAction_(1);
        });
cutPopUpValue = 2;
cutPopUp.valueAction_(0);

effectCutButton = SCButton(sampleComp, Rect(85 + (l*105), 50, 15, 15))
        .states_([
                ["p", Color.black, Color(0.2, 0.5, 0.2)],
                ["e", Color.black, Color(0.2, 0.5, 0.2)]
        ])
        .action_({
                arg view;
                if (view.value == 0, {
                        effectComp.visible_(true);
                        loopComp.visible_(false);
                        beatComp.visible_(false);
                        grainComp.visible_(false);
                }, {
                        effectComp.visible_(false);
                        loopComp.visible_(false);
                        beatComp.visible_(false);
                        grainComp.visible_(false);
                        if (cutPopUpValue == 0, {loopComp.visible_(true)});
                        if (cutPopUpValue == 1, {beatComp.visible_(true)});
                        if (cutPopUpValue == 2, {grainComp.visible_(true)});
                });
        });
        
SCPopUpMenu(sampleComp, Rect(10 + (l*105), 70, 75, 15))
        .items_(["2 Octaves Up", "1 Octave Up", "Normal", "1 Octave Down", "2 Octaves Down"])
        .action_({
                arg view;
                pitchValue = [4, 2, 1, 0.5, 0.25].at(view.value);
        })
        .value_(2);
        
SCButton(sampleComp, Rect(85 + (l*105), 70, 15, 15))
        .states_([
                ["f", Color.black, Color(0.2, 0.5, 0.2)],
                ["r", Color.black, Color(0.2, 0.5, 0.2)]
        ])
        .action_({
                arg view;
                revValue = [1, -1].at(view.value);
        });
        
SCButton(sampleComp, Rect(10 + (l*105), 90, 45, 15))
        .states_([
                ["Synced", Color.black, Color(0.2, 0.5, 0.2)],
                ["Free", Color.black, Color(0.2, 0.5, 0.2)]
        ])
        .action_({
                arg view;
                syncValue = view.value;
        });
        
SCPopUpMenu(sampleComp, Rect(55 + (l*105), 90, 45, 15))
        .items_(["1 Bar", "2 Bars", "4 Bars", "8 Bars"])
        .action_({
                arg view;
                syncLength = [4, 8, 16, 32].at(view.value);
        })
        .value_(2.0);

SCButton(sampleComp, Rect(10 + (l*105), 110, 90, 15))
        .states_([
                ["Start", Color.black, Color(0.2, 0.5, 0.2)],
                ["Stop", Color.black, Color(0.2, 0.5, 0.2)]
        ])
        .action_({
                arg view;
                var func;
                startValue = view.value;
                func = {        
                        if (startValue == 1, {
                                cutTask.start;
                                patch.play(patchGroup);
                        }, {
                                cutTask.stop;
                                patch.stop;
                                synth.free;
                        });
                };
                if (syncValue == 0, {
                        TempoClock.default.schedAbs(
                                TempoClock.default.elapsedBeats.trunc(syncLength) + syncLength, {
                                        func.value;
                                        nil;
                                });     
                }, {
                        func.value;
                });
        });

////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// EFFECTS
////////////////////////////////////////////////////////////////////////////////////////////////////////////

effectComp = SCCompositeView(window, Rect(5 + (l*105), 135, 100, 205))
        .background_(Color(0.4, 0.7, 0.4));

5.do({
        arg i;
        effectGroupArray = [effectGroup1, effectGroup2, effectGroup3, effectGroup4];
        effectPatchArray = [effectPatch1, effectPatch2, effectPatch3, effectPatch4];
        SCButton(effectComp, Rect(10 + (l*105), 140 + (i*40), 15, 15))
                .states_([
                        [" ", Color.black, Color(0.2, 0.5, 0.2)],
                        ["|", Color.black, Color(0.2, 0.5, 0.2)]
                ])
                .action_({
                        arg view;
                        effectOnArray.put(i, view.value);
                        patchFunction.value;
                        prevOnArray.put(i, view.value);
                });
        
        SCPopUpMenu(effectComp, Rect(25 + (l*105), 140 + (i*40), 60, 15))
                .items_(instrNameArray)
                .action_({
                        arg view;
                        effectSocketArray.put(i, view.value);
                        if (effectOnArray.at(i) == 1, {
                                patchFunction.value;
                        });
                        prevPatchArray.put(i, view.value);
                });

        SCButton(effectComp, Rect(85 + (l*105), 140 + (i*40), 15, 15))
                .states_([["e", Color.black, Color(0.2, 0.5, 0.2)]])
                .action_({
                        patch.gui;
                });
                
        SCSlider(effectComp, Rect(10 + (l*105), 160 + (i*40), 90, 15))  
});

////// MIX

mixComp = SCCompositeView(window, Rect(5 + (l*105), 345, 100, 65))
        .background_(Color(0.4, 0.7, 0.4));
        
mixSlider = SC2DSlider(mixComp, Rect(10 + (l*105), 350, 90, 35))
        .action_({
                arg view;
                ampValue = \amp.asSpec.map(view.y);
                sampGroup.set("amp", ampValue);
                panValue = view.x;
        })
        .x_(0.5);
        
volMidiArray = volMidiArray.add(MidiSlider({
        arg val;
        {
                mixSlider.y_(val / 127);
                nil;
        }.defer;
}));
window.name_(window.name ++ "-" ++ (volMidiArray.last.cc + 1).asString);

SCButton(mixComp, Rect(10 + (l*105), 390, 90, 15))
        .states_([
                ["Mute", Color.black, Color(0.2, 0.5, 0.2)],
                ["UnMute", Color.black, Color(0.2, 0.5, 0.2)]
        ]);

////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// CUT EDIT COMPOSITES
////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// LOOP
////////////////////////////////////////////////////////////////////////////////////////////////////////////

loopComp = SCCompositeView(window, Rect(5 + (l*105), 135, 100, 205))
        .background_(Color(0.4, 0.7, 0.4))
        .visible_(false);
                
SCStaticText(loopComp, Rect(10 + (l*105), 140, 90, 15))
        .string_("Loopedit")
        .align_(\center)
        .background_(Color(0.2, 0.5, 0.2));
        
SCButton(loopComp, Rect(10 + (l*105), 160, 90, 15))
        .states_([
                ["Free", Color.black, Color(0.2, 0.5, 0.2)],
                ["Synced", Color.black, Color(0.2, 0.5, 0.2)]
        ])
        .action_({
                arg view;
                if (view.value == 1, {
                        loopRange.step_(0.125);
                }, {
                        loopRange.step_(0.0001);
                });
        })
        .value_(1);
        
SCStaticText(loopComp, Rect(10 + (l*105), 180, 90, 15))
        .string_("Loop Points")
        .align_(\center)
        .background_(Color(0.2, 0.5, 0.2));

loopRange = SCRangeSlider(loopComp, Rect(10 + (l*105), 200, 90, 15))
        .action_({
                arg view;
                lLoopStart = view.lo;
                lLoopEnd = view.hi;
                if (abs(lLoopEnd - lLoopStart) < 0.01, {
                        lLoopStart = lLoopStart - 0.001;
                        lLoopEnd = lLoopEnd + 0.001;
                });
        })
        .lo_(lLoopStart)
        .hi_(lLoopEnd)
        .step_(0.125);

SCButton(loopComp, Rect(10 + (l*105), 220, 90, 15))
        .states_([["Retrigger", Color.black, Color(0.2, 0.5, 0.2)]]);

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////BEAT CUT 
////////////////////////////////////////////////////////////////////////////////////////////////////////////

beatComp = SCCompositeView(window, Rect(5 + (l*105), 135, 100, 205))
        .background_(Color(0.4, 0.7, 0.4))
        .visible_(false);
        
SCButton(beatComp, Rect( 10 + (l*105), 140, 90, 15))
        .states_([["Fill", Color.black, Color.new(0.7, 0.7, 0.9)]])
        .action_({
                var tally = 0;
                bcTableFill.value;
                (bcBarLength).do({
                        arg i;
                        if (bcRhythmArray.at(bcBarHigh - 1 - i) == 0, {
                                tally = tally + 1
                        }, {
                                bcRhythmArrayCopy.put((bcBarHigh -1- i), tally + 1);
                                tally = 0;
                        });
                });
        });
        
SCRangeSlider(beatComp, Rect( 10 + (l*105), 160, 90, 15))
        .step_(0.25)
        .hi_(bcBarHigh / 64)
        .lo_(bcBarOffset)
        .action_({
                arg view;
                var tally = 0, high;
                bcBarLength = ((view.hi - view.lo) * 64).max(16).asInteger;
                bcBarOffset = (view.lo * 64).asInteger;
                bcBarHigh = (view.hi * 64).asInteger.max(16);
                (bcBarLength).do({
                        arg i;
                        if (bcRhythmArray.at(bcBarHigh - 1 - i) == 0, {
                                tally = tally + 1
                        }, {
                                bcRhythmArrayCopy.put((bcBarHigh -1- i), tally + 1);
                                tally = 0;
                        });
                });
        });

SCStaticText(beatComp, Rect( 10 + (l*105), 180, 90, 15))
        .string_("Probability")
        .align_(\center)
        .background_(Color.new(0.7, 0.7, 0.9));
        
SCMultiSliderView(beatComp, Rect(10 + (l*105), 200, 90, 35))
        .gap_(0)        
        .thumbSize_(90 / 5)
        .action_({
                arg view;
                bcProbArray.put(view.index, view.currentvalue);
        })
        .value_(bcProbArray);
        
SCSlider(beatComp, Rect( 10 + (l*105), 240, 90, 15))
        .value_(0.5)
        .action_({
                arg view;
                bcLengthValue = view.value;
        })
        .value_(bcLengthValue);

SCSlider(beatComp, Rect( 10 + (l*105), 260, 90, 15))
        .value_(0.5)
        .action_({
                arg view;
                bcEntropyValue = view.value;
        })
        .value_(bcEntropyValue);
        
SCSlider(beatComp, Rect( 10 + (l*105), 280, 90, 15))
        .value_(0.5)
        .action_({
                arg view;
                bcSampleEntropy = view.value;
        })
        .value_(bcSampleEntropy);
        
SCSlider(beatComp, Rect( 10 + (l*105), 300, 90, 15))
        .value_(0.5)
        .action_({
                arg view;
                bcRollProb = view.value;
        })
        .value_(bcRollProb);

SCButton(beatComp, Rect( 10 + (l*105), 320, 90, 15))
        .states_([
                ["Entropy Write Off", Color.black, Color.new(0.7, 0.7, 0.9)], 
                ["Entropy Write On", Color.black, Color.new(0.6, 0.6, 0.8)]
        ])
        .action_({
                arg view;
                bcEntropyFillValue = view.value;
        });
                        
bcTableFill = {
        var wholePlus, low, high, tally = 0, randVol;
        
        bcRhythmArray = Array.new;
                                
        while ({bcRhythmArray.size <= 64}, {
                wholePlus = [16, 20, 24, 28, 32].choose;
                bcRhythmArray = bcRhythmArray ++ [
                        ([wholePlus] ++ Array.fill(wholePlus - 1, 0)),
                        [8, 0, 0, 0, 0, 0, 0, 0],
                        [4, 0, 0, 0],
                        [2, 0],
                        [1],
                ].at(windex(
                        if (bcProbArray.normalizeSum == [0, 0, 0, 0, 1], {
                                bcProbArray.normalizeSum;
                        }, {
                                bcProbArray.normalizeSum + [
                                        [0.0, 0.0, 0.0, 0.0, 0.0],
                                        [0.0, 0.0, 0.0, 0.0, 1.0]
                                ].at(bcRhythmArray.size % 2).normalizeSum
                        });
                ));
        });
        
        bcRhythmArrayCopy = bcRhythmArray;
                        
        bcPositionArray = Array.fill(bcRhythmArray.size, {0});
                
        bcRhythmArray.do({
                arg item, i;
                bcPositionArray.put(i, [i , bcRhythmArray.size.rand]
                        .at(windex([1 - bcEntropyValue, bcEntropyValue])));
        });
                        
        randVol = {
                arg i;
                [0.9, 0.6, 0.7, 0.6, 0.8, 0.6, 0.7, 0.6].at(i % 8) + rrand(-0.2, 0.2);
        };
        
        bcAmpArray = Array.fill(bcRhythmArray.size, {0});

        bcRhythmArray.do({
                arg item, i;
                bcAmpArray.put(i, randVol.value(i));
        });
        
        bcSampleArray = Array.fill(bcRhythmArray.size, {20.rand});
};

bcTableFill.value;
(bcBarLength).do({
        arg i;
        if (bcRhythmArray.at(bcBarHigh - 1 - i) == 0, {
                bcTally = bcTally + 1
        }, {
                bcRhythmArrayCopy.put((bcBarHigh -1- i), bcTally + 1);
                bcTally = 0;
        });
});     

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////GRANULAR
////////////////////////////////////////////////////////////////////////////////////////////////////////////

grainComp = SCCompositeView(window, Rect(5 + (l*105), 135, 100, 205))
        .background_(Color(0.4, 0.7, 0.4))
        .visible_(false);               
                
SCStaticText(grainComp, Rect(10 + (l*105), 140, 90, 15))
        .align_(\center)
        .background_(Color(0.2, 0.5, 0.2))
        .string_("Position");

SCRangeSlider(grainComp, Rect(10 + (l*105), 160, 90, 15))
        .action_({
                arg view;
                gPosition = view.lo;
                gPositionVar = view.hi;
        })
        .lo_(gPosition)
        .hi_(gPositionVar);

SCStaticText(grainComp, Rect(10 + (l*105), 180, 90, 15))
        .align_(\center)
        .background_(Color(0.2, 0.5, 0.2))
        .string_("Density");

 SCRangeSlider(grainComp, Rect(10 + (l*105), 200, 90, 15))
        .action_({
                arg view;
                gDensity = view.lo;
                gDensityVar = view.hi;          
        })
        .lo_(gDensity)
        .hi_(gDensityVar);

SCStaticText(grainComp, Rect(10 + (l*105), 220, 90, 15))
        .align_(\center)
        .background_(Color(0.2, 0.5, 0.2))
        .string_("Length");

SCRangeSlider(grainComp, Rect(10 + (l*105), 240, 90, 15))
        .action_({
                arg view;
                gLength = view.lo;
                gLengthVar = view.hi;           
        })
        .lo_(gLength)
        .hi_(gLengthVar);

SCStaticText(grainComp, Rect(10 + (l*105), 260, 90, 15))
        .align_(\center)
        .background_(Color(0.2, 0.5, 0.2))
        .string_("Slope");

SCRangeSlider(grainComp, Rect(10 + (l*105), 280, 90, 15))
        .action_({
                arg view;
                gSlope = view.lo;
                gSlopeVar = view.hi;            
        })
        .lo_(gSlope)
        .hi_(gSlopeVar);

SCStaticText(grainComp, Rect(10 + (l*105), 300, 90, 15))
        .align_(\center)
        .background_(Color(0.2, 0.5, 0.2))
        .string_("Amp");

SCRangeSlider(grainComp, Rect(10 + (l*105), 320, 90, 15))
        .action_({
                arg view;
                gAmp = view.lo;
                gAmpVar = view.hi;
        })
        .lo_(gAmp)
        .hi_(gAmpVar);
        
//effectCutButton.valueAction_(0);
//effectCutButton.valueAction_(1);

patchFunction = {
        var tempArray, index = 0, notInput;
        notInput = true;
        if (patch.isPlaying, {
                patch.stop;
        });
                
        tempArray = Array.new;
        prevArgsArray = Array.fill(5, {nil});
        
        if (patch.instr.name.at(0) != \slInput, {
                while ({patch.isKindOf(Patch) && notInput}, {
                        tempArray = tempArray.add(patch.args);
                        patch = patch.args.at(0);
                        if (patch.instr.name.at(0) == \slInput, {notInput = false});
                });
        });
        prevOnArray.do({
                arg item, i;
                if ((item == 1) && (effectSocketArray.at(i) == prevPatchArray.at(i)), {
                        prevArgsArray.put(i, tempArray.pop);
                });
        });                     
        patch.free;
        patch = Patch(\slInput,  [sampBus.index]);
        effectSocketArray.do({
                arg item, i;
                if (effectOnArray.at(i) == 1, {
                        if (prevArgsArray.at(i) == nil, {
                                patch = Patch(instrArray.at(item.asInteger), [patch]);
                        }, {
                                prevArgsArray.at(i).do({
                                        arg item, j;
                                        "".postln;"".postln;
                                        item.postln;
                                        "".postln;"".postln;
                                        if (item.isKindOf(KrNumberEditor) == false, {
                                                if (item.isKindOf(SimpleNumber) || item.isKindOf(Patch), {
                                                        prevArgsArray.at(i).put(j, patch);
                                                }, {
                                                        prevArgsArray.at(i).put(j, nil);
                                                });
                                        }, {
                                                prevArgsArray.at(i).put(
                                                        j, KrNumberEditor(item.value, item.spec)
                                                );
                                        });
                                });
                                patch = Patch(instrArray.at(item.asInteger) ,prevArgsArray.at(i));
                        });
                });
        });
        if (startValue == 1, {patch.play(patchGroup)});
};
        
});

)
//authors so far: 
casey basichis