[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] waveset deletion



thought i'd throw this up since i received so much help from the list and
Wavesets.sc is adc's!  thanks all.
jz 
(
/* -----------------*/
/* Waveset Deletion */
/* jz 12/13/02      */
/* ---------------- */

var f, s, sig, ws;
var wsStart, wsEnd, which = 1, wsStartTime;
var w, probA, probB, numCyclesSl, manipTime;

w = GUIWindow.new("Probablistic Wavset Deletion", Rect.newBy(249, 121, 400,
400));
StringView.new( w, Rect.newBy(30, 23, 128, 20), "chance of deletion");
probA = NumSliderView.new( w, Rect.newBy(31, 47, 167, 20), "probablity of
waveset deletion", 0, 0, 1, 0, 'linear');
StringView.new( w, Rect.newBy(30, 71, 128, 20), "# of waveCycles");
numCyclesSl = NumSliderView.new( w, Rect.newBy(31, 95, 167, 20), "# of
waveCycles", 1, 1, 100, 1, 'linear');
manipTime = CheckBoxView.new( w, Rect.newBy(231, 47, 128, 20), "loop + 1",
0, 0, 1, 0, 'linear');
    
e = Env.new(#[0,1,0.5,0],#[0.01, 0.5, 0.01], 1,2);
f = GetFileDialog.new.path;
s = SoundFile.new;
s.read(f);
sig = s.data@0;

// init:
Wavesets.clearLibs;
ws = Wavesets.new.file_(s);

Synth.play({ arg synth;
    var numXs;
    numXs = (ws.zeroCrossings);
    numXs = numXs.size-5;
    
    Spawn.ar({ arg spawn, events;
    var amp1, amp2, numCycles;
        // random deletion:
        amp1 = [0, 1].wchoose([probA.poll, 1-(probA.poll)]);
        amp2 = [0, 1].wchoose([probA.poll, 1-(probA.poll)]);
        spawn.releaseAll;
        numCycles = numCyclesSl.poll.asInteger;
    if (manipTime.poll == 0, { which = which + numCycles; }, {which = which
+ 1});
        which = which.wrap(0, numXs-numCycles);
        wsStart = ws.zeroCrossings.at(which);
        wsEnd = ws.zeroCrossings.at(which + numCycles);
        spawn.nextTime = (wsEnd/s.sampleRate) - (wsStart/s.sampleRate);
        PlayBuf.ar(sig, s.sampleRate, 1, wsStart, wsStart, wsEnd,
EnvGen.kr(e)*[amp1, amp2])
    },2)

});
w.close;
)