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

Re: [sc-users] DiskOut/buffers



Hmm, thanks James, restructured completely. I'm using a backup buffer.
Seems to work, sometimes the reset seems not to operate, works better with shorter buffers

Best

-a-

EventRecPlayer {


var <>ana ;
var <>on, <>off ;
var <>sy ;
var <>rec ;
var <>buf, <>buf2 ;
var <>num ;
var <>bus ;

*new { arg ana ;
^super.new.initERP(ana)
}

initERP { arg anAna;
ana = anAna ;
bus = Bus.audio(Server.local, 1) ;
buf = Buffer.alloc(Server.local, Server.local.sampleRate * 1.0) ; // alloc the bus
buf2 = Buffer.alloc(Server.local, Server.local.sampleRate * 1.0) ; // alloc the bus
num = 0 ;
// this will record to the buf
rec = SynthDef(\recout, { arg bufnum, bus, offset = 0;
RecordBuf.ar(SoundIn.ar(0), bufnum, offset) })
.play(Server.local, [\bufnum, buf.bufnum, \bus, buf], \addToTail);
// a lock
on = false ;
{PlayBuf.ar(1, buf, loop:-1)}.play
}


update { arg theChanged, theChanger, more ;
case 
{ more[0] == \onset  } 
if (on == false){
num.postln ;
buf.zero ;
// from the beginning
rec.set(\offset, 0) ;
// go
rec.run ;
// update lock
on = true"start".postln;}


{ more[0] == \silence && on == true }
"pause".postln ; // pause
rec.run(false) ;
// rec to a progressive filename
buf.copyData(buf2) ;
buf2.write
("/test/"++num.asString++".aiff".standardizePath, "aiff", "int16") ;
on = false
num = num+1 ;
}
}

}

On Jul 21, 2009, at 2:40 PM, James Harkins wrote:

You have two completionMessages (b_write and s_new) in your Buffer.alloc, which IIRC is not allowed.

I think it would be better to record into a preallocated buffer (so that you don't miss the few ms for OSC messaging) and copy segments of that buffer into new buffers.

hjh


On Jul 21, 2009, at 5:29 AM, Andrea Valle wrote:

(here we are again).
I'm trying to record events.
This means:
- when I receive an onset I start recording
- when I detectsilence I stop recording.

I tried many ways (allocating just one buffer and varying the file where it write etc).
At the end I reached thie following draft.

"update" is because the class is a depedant of an analysis class sending onsets and detectsilence.
The fact is that I'm always (in all cases) having problems with resulting files, 0 or 4kb (header, I guess).
I suspect it depends on asynchronous allocation.
What's the easy way to do this?
Thanks a lot



: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman


--------------------------------------------------
Andrea Valle
--------------------------------------------------
CIRMA - DAMS
Università degli Studi di Torino
--------------------------------------------------
" This is a very complicated case, Maude. You know, a lotta ins, a lotta outs, a lotta what-have-yous." 
(Jeffrey 'The Dude' Lebowski)