View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

Auto Karaoke

Uploaded Image: bug04.gif

// auto karaoke #I, SC3d
// jrh 03/01 needs XBuf
(
var  bank;
n = 5; //number of buffers
bank = Library.at(\bank, 0);
n.do({ arg i; bank.alloc(i, 2, 44100*2); });
//bank.read(0, ":sounds:floating_1");
//bank.read(1, ":sounds:floating_1", 20000);
//bank.read(2, ":sounds:floating_1", 50000);
m = MouseX.new([0.0, n-1]);
o = MouseY.new([0, 1.0]);

r = 
        #{ arg index=0.0, offset=0.0, dur=0.8, splice=0.1;      ["go!", index].postln;
                {
                        var env, eg;
                        env = Env.linen(splice, dur - (splice * 2), splice, 1, 'sine');
                        eg = EnvGen.kr(env);
                        RecordXBuf.ar(Library.at(\bank, 0), index, AudioIn.ar([1, 2]), offset, eg, 1-eg, run:1.0 );
                        Plug.ar(0)
                }.play(dur);
        
        
};

#{ arg n;
        play({
                var mx, my;
        
                mx = MouseX.new([0.0, n-1]);
                my = MouseY.new([0, 1.0]);
                Pbind(
                        \ugenFunc, { arg index, offset, amp, bank; 
                                        var env;
                                        env = Env.linen(0.1, 0.3, 0.2, amp); 
                                        EnvGen.kr(env) * PlayXBuf.ar(bank, index, 1, offset)
                        },
                        \bank, Library.at(\bank, 0),
                        \index, Pfunc({ mx.value }),
                        \offset, Pfunc({ my.value }),
                        \amp, Pseq([1, 1], inf),
                        \dur, 0.5
                ).ar(2)
        })
}.send(n);

)

//evaluate this to record some sound
//mouse position at the moment of evauation
//is bankindex and offset

r.send(m.value, o.value);








Links to this Page