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

[sc-dev] Buffer.new was: Re: [sc-users] Buffer.cueSoundFile problem



I think that what is now Buffer-new should be replaced by Buffer-basicNew in order to make it consistent with the Node classes. -new should either be nothing, or replace alloc, IMO. Thoughts?

When I get a few minutes I still plan to have a go at tightening Buffer and Bus up. When done I'll post something for comment.

S.

On 9 Nov 2004, at 22:42, James Harkins wrote:

The main problem is that you are, in fact, allocating a new buffer every time you run the loop, instead of reusing the one you already have.

b = Buffer.alloc(s, 65536, 1);
b.cueSoundFile(....);
// play stuff
b.close;
b.cueSoundFile(...);

Since you're not allocating more memory each iteration this way, you should be able to do this indefinitely.

Buffer.new -- or Buffer(...) -- is not the right way. It creates the Buffer object on the client but it never sends the message to the server to allocate the memory. Thus, no sound. You should be using Buffer.alloc. (I made this mistake many times...)

hjh

On Monday, Nov 8, 2004, at 22:14 US/Eastern, Brent Wetters wrote:

Hello,

I've been trying to work through the thread originally posted by Paul Lansky ("Magic Number 246") and I keep running into the same problems...namely that after 246 iterations of the loop, the server fails, or I get no sound at all. I'm relatively new to supercollider, so any help would be most appreciated. here's the code, which is essentially just copied from Lansky's original. I've made some minor changes, most of which I've changed back for this post.

(
var random;
SynthDef("playit",
{ arg out=0, buffer ;
Out.ar(0,DiskIn.ar( 2, buffer )*0.25*
EnvGen.ar(Env.new([1,1],[0.25]),gate:1, doneAction:2));
}).send(s);


Routine({
i = 0;
b = Buffer; // if I use b = Buffer(s) I don't get sound...

// the only thing that sort of works is to put the full
// b = Buffer.cueSoundFile(s,"sounds/
a11wlk01.wav",0,2 );
// and in the loop
// x = Synth("playit", [\buffer,b.bufnum]);
// then I get beyond 246 and get sound, BUT as you can see by the meaningless
// random line, I want it to play random snipits from inside the (727 second) file
// and I can't see any way to do that unless the cueSoundFile is inside the loop

loop({
i = i+1; i.postln;
random = 727.rand * 41000;
x=Synth("playit",

[\buffer,b.cueSoundFile(s,"sounds/
a11wlk01.wav",0,2 ).bufnum]);
// would be "...sounds
a11wlk01.wav",random..." with the random thingy added

// if I here put [\buffer,b.cueSoundFile(etc..., it works, but the 246 problem is still there


// if I put a b.close;, I either get no sound, or an error...

0.1.wait;

});
}).play
)

any ideas? Thanks!

---brent_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users

____________________________________

H. James Harkins /// dewdrop_world
http://www.dewdrop-world.net

"If attacked by a lion, thrust your arm down his throat.
This takes some practice." -- Cyril Connolly

_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users