Hey James, Thanks for these suggestions, super helpful. I made the changes you suggested and then after some tweaking I now have things working. One odd thing I noticed is that certain UGens ask for a Buffer.index but seem to want a Buffer.bufnum instead (?) and throw errors about not understanding the Buffer.index until this change is made (see rec_manual where i use ~loopbuf1.bufnum instead of ~loopbuf1.index for one example). Thanks again! Casey P.S. Here is where I ended up (for anyone else coming to this later): ( // Create 3 groups and 2 busses ~clean = Group.new; ~looped = Group.after(~clean); ~finalMix = Group.after(~looped); ~cleanBus = Bus.audio(s, 1); ~loopedBus = Bus.audio(s, 1); // control busses for volume ~cleanBusVol = Bus.control(s, 1).set(0.0); ~organBusVol = Bus.control(s, 1).set(0.0); ~loopedBusVol = Bus.control(s, 1).set(0.0); ) ( // make the synth that does this m = { arg cleanAmp = 0.5, loopedAmp = 0.5; var clean, looped, sig; clean = In.ar(~cleanBus.index, 1) * cleanAmp; looped = In.ar(~loopedBus.index, 1) * loopedAmp; sig = clean + looped; Out.ar([0,1], sig); }.play(target: ~finalMix); ) ( // run it m.set(\cleanAmp, ~cleanBusVol.asMap, \loopedAmp, ~loopedBusVol.asMap); ) // setup GUI ( ~window = Window.new("mixer", Rect(0,0,600,640)) .onClose_({ "closing".postln; }); ~s1 = Slider.new(~window, Rect(10, 10, 50, 200)) .action_({ |slider| ("clean bus vol = " + slider.value).postln; ~cleanBusVol.set(slider.value); }); ~s2 = Slider.new(~window, Rect(70, 10, 50, 200)) .action_({ |slider| ("loop bus vol = " + slider.value).postln; ~loopedBusVol.set(slider.value); }); // ~s3 = Slider.new(~window, Rect(70, 10, 50, 200)) // .action_({ |slider| // ("organ bus vol = " + slider.value).postln; // // ~organBusVol.set(slider.value); // }); ~window.front; ) Looper: MIDIIn.connectAll; ( ~loopbuf1 = Buffer.alloc( s, s.sampleRate * 60, 1, completionMessage: { ("Loaded ~loopbuf1! numFrames: " + (s.sampleRate * 60)).postln } ); // for rec_manual ~bDur = Bus.control(s, 1); // used to share off time from phasor (see rec_manual) ) ( // records until an off message which latches phasor location, frees self on latch SynthDef( \rec_manual, { | amp = 0.0, buf, inBus, rate = 1, recManualBus, off = 0, trig = 0 | var env, in, phase, time; in = In.ar( inBus, 1 ); phase = Phasor.ar(trig, BufRateScale.kr(buf) * rate, 0, (BufFrames.kr(buf))); BufWr.ar(in, buf, phase); time = Latch.kr(phase, off); Out.kr( recManualBus, time ); FreeSelf.kr( time ); }).add; SynthDef( \looper, { | amp = 0.99, buf, end, outBus, rate = 1, start = 0, trig = 1 | var env, play; env = EnvGen.kr( Env.asr( 0.01, amp, 0.01 ), trig, doneAction: 2 ); play = LoopBuf.ar( 1, buf, 1, trig, start, start, end, 2); Out.ar( outBus, env * play ); }).add; ) ////////////////// RECORD AND LOOP THE THINGS ////////////////// ///////// manually ///////// // trig by midifighter ( MIDIdef.cc(\test1, {arg ...msg; var vel, num, chn; vel = msg[0]; num = msg[1]; chn = msg[2]; if( vel == 127, { ( num + "START REC" ).postln; ~loopt1 = Synth.new( \rec_manual, [ \amp, 0.9, \buf, ~loopbuf1.bufnum, \inBus, ~cleanBus.index, \recManualBus, ~bDur.index, \trig, 1 ], ~looped); }, { ( num + "STOP REC" ).postln; ~loopt1.set(\off, 1); ~i = Synth.new(\looper, [\amp, 0.90, \buf, ~loopbuf1.bufnum, \end, ~bDur.asMap, \outBus, ~loopedBus.index, \trig, 1 ], ~looped); }); }, 48); // match #48 ) ///////// On December 29, 2017 at 3:17:40 PM, jamshark70@xxxxxx (jamshark70@xxxxxx) wrote:
|