« Return to Thread: Cropping buffer - Server.sync + best way
some minor suggestions...i would avoid Server.default inside a method. specially here since the Buffer object already knows which server it belongs to.and this.numChannels and this.bufnum could be just numChannels and bufnum.your argument numFrames you might want to rename just to make it different from Buffer.numFrames.the first .sync should not be needed.and perhaps add an action function?_f/*b = Buffer.read(s, "sounds/a11wlk01.wav");b.playb.crop(100000, 66666, false)b.playb*/+ Buffer {crop {arg startFrame, frames, overwrite=false, action;var cond, tempbuf, newbuf;cond = Condition.new;
Routine.run {tempbuf = Buffer.alloc(server, frames, numChannels);server.sync(cond);this.copyData(tempbuf, 0, startFrame, frames);server.sync(cond);this.free;server.sync(cond);newbuf = Buffer.alloc(server, tempbuf.numFrames, tempbuf.numChannels, bufnum:bufnum);server.sync(cond);tempbuf.copyData(newbuf);server.sync(cond);tempbuf.free;tempbuf = nil;
if(overwrite, { newbuf.write(this.path, "aiff", "int16") });
server.sync(cond);this.updateInfo(action); // update so the buffer object has the new buffer info};}}21 jul 2008 kl. 01.04 skrev thor:Thanks for all the replies. Right now I don't have time to investigate the bind issuebut I've implemented the crop method like this:(still interested in improvements : )b = Buffer.read(s, "sounds/a11wlk01.wav");b.playb.crop(100000, 66666, false)b.playb+ Buffer {crop {arg startFrame, numFrames, overwrite=false;var s, cond, tempbuf, tempbufnum, newbuf, chNum;cond = Condition.new;s = Server.default;
Routine.run {chNum = this.numChannels;s.sync(cond);tempbuf = Buffer.alloc(s, numFrames, chNum);s.sync(cond);this.copyData(tempbuf, 0, startFrame, numFrames);tempbufnum = this.bufnum;s.sync(cond);this.free;s.sync(cond);newbuf = Buffer.alloc(s, tempbuf.numFrames, tempbuf.numChannels, bufnum:tempbufnum);s.sync(cond);tempbuf.copyData(newbuf);s.sync(cond);tempbuf.free;tempbuf = nil;
if(overwrite, { newbuf.write(this.path, "aiff", "int16") });
s.sync(cond);this.updateInfo; // update so the buffer object has the new buffer info};}}#|fredrikolofsson.com klippav.org musicalfieldsforever.com|#_______________________________________________sc-users mailing listinfo (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
« Return to Thread: Cropping buffer - Server.sync + best way
| Free embeddable forum powered by Nabble | Forum Help |