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

Re: [sc-users] automated buffer -- How's that get in there?!?



Hi James (why pretend anyone else is still reading -- this must be
annoying... sorry everyone!)
     Bear with me whilst I attempt to parse the code you sent!  (after
having stared at it for several hours...)

This bit sets the watcher symbol to be universally recognized for use by
routines, etc.
~watcher = NodeWatcher.newFrom(s); 

This bit uses the above nodewatcher to parse and categorize (and set?) the
state of the buffers in the pool.

~stateManager = { |buffer, node, endState = \ready| 
        buffer.state = \busy; // don't let anyone else use this buffer 
                // below is to make sure the state changes when the synth
stops 
        ~watcher.register(node); 
        Updater(node, { |node, flag| 
                (flag == \n_end).if({ 
                        buffer.state = endState; 
                }); 
                node.releaseDependants; 
        }); 
}; 

These are my fake filters for which I have working replacements whose names
must be registered for access in this global variable.  I assume that I
should register (send.(s)) the synths to the server before doing this, so
feasibly I'll have a list of synths that preceed the following.

~filters = #[\nameOfFilterSynth1, \nameOfFilterSynth2, 
\nameOfFilterSynth3, \nameOfFilterSynth4...]; 


So this controls the playing and filtering of the soundfiles in buffers, in
this case also controlling the recording process.  The \recorder and \player
synths would have to be registered previously with the filter synthdefs.  In
this case, you are using the weighted choose to record and play soundfiles
%25 of the time (each) and %50 to filter the SFs.  Could you describe what
is happening with the 

 ~stateManager.value(buf1, node); 

bit of code?

r = Task({ 
        var buf1, buf2, node; 
        loop { 
                        // you might change the weights in the wchoose 
                        // if you need other events, you can add the keys
here 
                #[\record, \play, \filter].wchoose(#[0.25, 0.25,
0.5]).switch 
                        { \record } { 
                                buf1 = ~pool.select({ |b| b.state == \empty
}).tryPerform(\choose); 
                                buf1.notNil.if({ 
                                        node = Synth(\recorder,
[\targetbufnum, buf1.buffer.bufnum]); 
                                        ~stateManager.value(buf1, node); 
                                }); 
                        } 
                                
                        { \play } { 
                                buf1 = ~pool.select({ |b| b.state == \ready
}).tryPerform(\choose); 
                                buf1.notNil.if({ 
                                        node = Synth(\player,
[\sourcebufnum, buf1.buffer.bufnum]); 
                                        ~stateManager.value(buf1, node); 
                                }); 
                        } 
                        
                        { \filter } { 
                                buf1 = ~pool.select({ |b| b.state == \ready
}).tryPerform(\choose); 
                                buf2 = ~pool.select({ |b| b.state == \empty
}).tryPerform(\choose); 
                                (buf1.notNil and: { buf2.notNil }).if({ 
                                        node = Synth(~filters.choose,
[\sourcebufnum, buf1.buffer.bufnum, 
                                                \targetbufnum,
buf2.target.bufnum]); 
                                        ~stateManager.value(buf1, node); 
                                        ~stateManager.value(buf2, node); 
                        }; 
                rrand(4.0, 20.0).wait; // how many beats to wait until the
next event? 
        } 
}); 

So, I dropped the above code into a file, added the pool definition at the
beginning, dropped in a bunch of synths and after inserting some ')'s and
'}'s places, everything registered with no errors.  Of course, nothing works
because I have no sound files.  (and for other reasons, I'm sure) 

I will need to record the sound files to the buffers myself, independantly
from the above routine because the recordings will be time varying... that
is, I'll make them when I have to : D.  

So, to do this, I'll need to register a recording synth def... something
like the following when I register the rest of my junk...

SynthDef(\recorder, { arg targetbufnum, outbus = 0; 
         var sig = AudioIn.ar(1); 
		RecordBuf.ar(sig, targetbufnum); 
         	Out.ar(outbus, sig);
}).send(s);

(stole this bit and modified it so it won't work!  Impressive, no?)

Then I'll need a way to parse the pool, etc, as with the routine.  I've
nabbed the '\recorder' bit of code from the above routine and deleated it so
nothing is accidentally thrown into a buffer, and I've started a routine of
my own to handle the recordings only it doesn't seem like a routine is the
best tool for the job.  

Let me know if I'm on the right track of if I'm blundering down the
proverbial dark alley....

#[\record, \player, \filter].wchoose(#[0.25, 0.25, 0.5]).switch 
                        { \record } { 
                                buf1 = ~pool.select({ |b| b.state == \empty
}).tryPerform(\choose); 
                                buf1.notNil.if({ 
                                        node = Synth(\recorder,
[\targetbufnum, buf1.buffer.bufnum]); 
                                        ~stateManager.value(buf1, node); 
                                }); 
                        } 

I need to create something that does the above, only without the .choose and
the .switch, (and obviously without the other synths).  

(
~rec = Routine({ 
        var buf1, buf2, node; 
        n.do {
               buf1 = ~pool.select({ |b| b.state == \empty
}).tryPerform(\choose); 
               buf1.notNil.if({ 
               node = Synth(\recorder, [\targetbufnum, buf1.buffer.bufnum]); 
               ~stateManager.value(buf1, node); 
                                }); 
                        }
	})
) 

~rec.play;
~rec.stop;

The above doesn't throw errors, but I just winged it so I'm not sure
anything's actually going where it is supposed to and when I do a 

~pool.post;

The buffers all show up \empty, but there doesn't appear to be anything in
the record module to set the buffer to \ready -- aside, of course, from the
~statemanager from the above-above code.  The NodeWatcher, however, is
beyond my comprehension at this precise moment.

Can you tell me if I'm making any sort of conceptual faux pas with the
"recorder" bit above?  

In addition, are there methods you find useful for collecting information on
activities?... IOW, to see if anything is working?  (like the ~pool.post;
above, which told me nothing, but more useful!)

I must say that, despite my ongoing inability to grasp certain core concepts
with the program, that I'm learning quite a bit, and having a blast!  (when
I'm not crying myself to sleep after bashing my face against my disgusting
300-pound CRT out of frustration)

I know your site bio states that you received your PhD from Duke, did you
study any of this sort of thing there?  The "designing [your] own software
for live algorithmic composition and performace" seems like you have a
history in programming as well?

I sometimes wish I had payed more attention in class as a child...

SP(e)

P.S. Continual thanks for ongoing guidence!
--
View this message in context: http://www.nabble.com/automated-buffer----How%27s-that-get-in-there-%21--t1030376.html#a2904853
Sent from the Supercollider - User forum at Nabble.com.