[chuck-users] Get audio samples of adc (fernando alonso)

Perry Cook prc at CS.Princeton.EDU
Sun Jun 9 15:06:30 EDT 2013


Either is fine, in fact the samples would be identical in this example.

However, if you wanted to apply a gain scaling to the samples coming
from adc (as part of a more elaborate patch, for example), then the
gain labeled "input" would be the place to do it (I'll tell you why soon).
In the example I gave, we could set input.gain to 32768.0 then do the 
cast of input.last() to int, saving the multiply.  For that, you'd need to
connect adc through the Gain UG and to blackhole, because it doesn't
update/compute without that.

Why wouldn't we just change the gain of adc?  Well, as a matter of best 
practices, that is a very bad idea.  Turns out that since adc is a persistent
and unique UG (like dac and blackhole), as long as the VM runs, the
gain change on adc is permanent and global!  Imagine how surprised 
another shred might be if it used adc and found the samples ranging 
from -32767 to 32768.  Bad idea, so I make my students always connect
adc to a Gain UG, just avoid the temptation of operating on adc directly.

Also, if you connect adc => blackhole (or adc => dac), that connection is
also global and permanent, even though the shred that did it might end.
So again, operating on adc directly is not good practice.  adc.last() is 
perfectly fine at all times, but I just make my students avoid all use of adc
directly.

Hope this helps,

PRC





More information about the chuck-users mailing list