Re: [chuck-users] Get audio samples of adc (fernando alonso)
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
Thanks so much for your reply! It is perfecto to me.
I am working in some interesting things with chuck, and I trying to use the
Wavelet Transform to get pith, flux, etc. Your reply is very useful for me.
2013/6/9 Perry Cook
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
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Fernando Alonso Martín Lualobus@gmail.com http://roboticnaturalinteraction.comhttp://www.roboticNaturalInteraction.com/famartin.html
participants (2)
-
fernando alonso
-
Perry Cook