question about input detector from adc (MIC)
Dear all, I would like to detect "sound" input from MIC (adc). It means that if any sound occure, one event or anything should be done. My thought is that: adc => gain g => blackhole; 1 => g.gain; g.last() => float x; while( true ) { if ( std.fabs(x) == 1. ) <<<x>>>; } But the x is always 0. So how to do it?? Thanks a lot!! Lewis
Hi Lewis,
I would like to detect "sound" input from MIC (adc). It means that if any sound occure, one event or anything should be done.
adc => gain g => blackhole; 1 => g.gain; g.last() => float x; while( true ) { if ( std.fabs(x) == 1. ) <<<x>>>; }
But the x is always 0.
It look like you are not advancing time in the loop, which means that the chuck time is frozen (and no audio is getting processed). Also, you need to update x inside the loop. Try this: adc => gain g => blackhole; float x; while( true ) { g.last() => x; if( std.fabs(x) >= .95 ) <<< x, "" >>>; 1::samp => now; } The above code advances time in 1::samp (duration of 1 sample) increments - you might try different values to see the results. Depending on what you want to do, this instantaneous polling approach is likely not robust. An alternative is to take recent history into consideration - possibly by implement some sort of leaky integrator / envelope follower (as Perry mentioned). It should be possible to do directly in chuck, though a specialized envelope follower unit generator might be more efficient (the latter is forthcoming). Hope this helps. Best, Ge!
---------- Original Message -----------
From: Ge Wang
adc => gain g => blackhole;
float x; while( true ) { g.last() => x; if( std.fabs(x) >= .95 ) <<< x, "" >>>; 1::samp => now; }
The above code advances time in 1::samp (duration of 1 sample) increments - you might try different values to see the results.
I tried something like this technique too. Not with the ADC, mind you, but with printing 44 thousand lines to the monitor a second. It would be interesting to see wether the resulting noise could be modulated by adapting the refreshrate of this monitor but on my Windows laptop things got so hard to controll at that point that I didn't particularly feel like doing that at that time. It might be a interesting technique to do modulated with some time-based condition instead of "true", for example as a break or right before using machine.crash() but I don't think it's well suited as a lead instrument. :¬) Kas.
participants (3)
-
Ge Wang
-
Kassen
-
劉建志