Dear list,
I'm working on a auto input recorder, that record only what is under
the amp follower threshold. To this point it seems to work well. However I'm trying to implement a autonomous buffer recording system, adding a new buffer every time it stops recording, the audio is copied to a new buffer. I don't know where I'm messing it up, but in the end the resultant recorded buffers turn out to have recorded the same moments, are repeated and seems to have bits of audio from previous buffers. Quite confusing (and I've tried it a lot). Would anyone would be kind enough to help to solve this. Cheers, andré ~buffers=List[]; //empty list of buffers b= Buffer.alloc(s, 44100*30,1); //long buffer to record in to //Synth doing amp analysis and recording //use headphones to prevent feedback SynthDef(\gate, {arg sample, lagTime=0, thresh= 0.01, ampAttack=0.04, ampRelease=0.04, attack=0.05, release=0.05, delTime=0, bufnum, run; var source, trigger, envelope, on, off, time, output, record; source = AudioIn.ar(1); trigger = (Lag.kr(Amplitude.kr(source, ampAttack,ampRelease),lagTime) < thresh); envelope = EnvGen.kr(Env.asr(attack, 1, release, 1,curve:'sine'), trigger); output = DelayN.ar(source, 1, delTime) * envelope; on = Trig1.kr(trigger); off = Trig1.kr(1-trigger); time = Line.kr(0, 1000000 ,1000000); SendTrig.kr(on,1,time); SendTrig.kr(off,0,time); record= RecordBuf.ar(output*2, bufnum, 0, 1, run); Out.ar(1, output); }).send(s); //OSCresponder that send rec mesg to Synthdef and adds recorded buffers to buffer list ~state = OSCresponder(s.addr,'/tr',{ arg time,responder,msg; [time,responder,msg]; msg[2].postln.switch( 1, {~startTime= Main.elapsedTime; ~gate.set(\bufnum,b.bufnum, \run,1); }, 0, {~endTime= Main.elapsedTime; ~length=(~endTime-~startTime); ~gate.set(\run,0); ~buffers.add(Buffer.alloc(s, 44100*~length, 1) ); b.copyData(~buffers.last, 0, 0, 44100*~length); }) }).add ~gate= Synth (\gate, [\sample, ~file.bufnum, \tresh, 0.001,\ampAttack,0.01, \ampRelease,0.1, \lagTime, 4, \delTime,0.3, \lagTime2, 0]); ~gate.free ~buffers.size ~buffers[8].plot.test ~sample =~buffers[0]; ~sample.write("~/sample0.aiff".standardizePath, sampleFormat: 'int16'); ~sample.close; ~sample.free; |