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

Re: [sc-users] buffers and 'spawns' : SC3



On Tuesday, December 17, 2002, at 07:48 PM, Jem Finer wrote:

- I've been using a routine to do a basic form of Granular Synthesis . . . in the same way as I used to use a Spawn (except the Playbuf stuff is in a Synthdef) . . . but what I was wondering is whether this is the way to do such a thing as it seems to use a hell of a lot of CPU . . . well according
to the OS X CPU Monitor anyway.

Like, maybe there's some other thing I haven't discovered yet.


Re the buffer . . . is there then an optimum size to make it ?

wait up.. my previous email was telling you about streaming sound files from disk.
you are loading whole (small) files in.

when using \buffer_readAlloc it will allocate the buffer for the size of the soundfile.
you don't even need to know.

One other thing . . . once you've read a soundfile to a buffer is there a call to get it's size a la blahblah.size in SC2 . . . maybe the same but not
sure how to write it.

on the synth side you can use some of the sample info ugens.
on the language side you can open it with SoundFile and read the headers.



oh yeah, while I'm here : everytime I call the SynthDef from the routine I'm giving it a new node. This seems a bit crazy in that after a while I've got
through 1000's.

they're just numbers. the synth's themselves are dead.
you should use the Server's synth node allocator.
do not roll your own.

 Thought that the envelope DoneAction in the SynthDef might
sort it out set at 3 but it messes with the iteration. Surely there must be
a way to kill a node and reallocate it.

think of all the little synths you've created in sc2 over your life. all of them.... dead. and nameless. if we had given them all names, maybe you would care about
all of them more ?
a granulation in sc2 creates oodles of them, and has to compile the ugen graph each time.


Maybe I should send the simple code :

s.boot;

(
SynthDef("samplePlayerEnv",{
arg bus = 0, buffer = 0, pitch = 1,out = 0, start = 0, loop = 1,length =
1,trigger = 1;
var e,eg,soundout;
e = Env.new([0,1,1,0],[0.05,0.9,0.05],'sin');
soundout = PlayBuf.ar(2, buffer, pitch, trigger, start, loop);
eg = EnvGen.ar(e, timeScale: length,doneAction: 2);
Out.ar(out,soundout * eg)
}).writeDefFile;
s.sendMsg("/d_load", "synthdefs/samplePlayerEnv.scsyndef");
)

s.sendMsg("/b_alloc",0,100,2);

s.sendMsg("/b_allocRead",0,"Sounds/ca loop 4.aiff");

you should use the Buffer object

also you are allocating the buffer twice.

	b = Buffer.read(s,"Sounds/ca loop 4.aiff");

much easier.
	then b.bufnum gives the bufnum



(

var r;


r = Routine({
    inf.do({ arg i;

        {
        //basic iteration, length controls "grain duration"
        s.sendMsg("/s_new", "samplePlayerEnv", 1001 + i  ,1,
0,'length',1,'start', 10000 * i,'trigger', Impulse.ar(1));

you should use the Synth object (check the swiki, its not in the CVS yet).

Synth.new("samplePlayerEnv",[ 'length',1.0,'start',10000 * i,'trigger', .ummm.. ])

you can't send an Impulse.ar like that !

Synth does not yet use the Server's synthID allocators, but it will.


        }.defer;
//wait controls "grain rate"
        0.5.wait;
    });

});
SystemClock.play(r);
)

SystemClock.clear;

s.quit


you should try to do this all in the same Synth.

use the PlayBuf trigger, and see if you can set up a sample and hold on the pitch.
so at each trigger from the Impulse.ar
(which is either inside of the SynthDef or patched into the synth from another synth
	using the busses).
the pitch gets locked, the Playbuf gets trigged.

then you are doing it all inside of one synth, and no routine at all.


-felix