[ javadoc ]
The AudioListener interface is used by the Recordable interface and defines only two methods. These methods are:
[snip java]
void samples(float[] samples)
void samples(float[] samplesLeft, float[] samplesRight)
[/snip]
One of these methods will be called repeatedly by the Recordable object that an AudioListener has been added to, depending upon whether the audio being monitored is mono or stereo. There is no guarantee that the array(s) passed to listeners are unique. For efficiency reasons, the same array(s) could be passed to all listeners of a particular Recordable. It is therefore important that an AudioListener not modify the array(s) it receives so that all listeners are guaranteed to receive the same information. Unfortunately, Java does not provide away to enforce this, so it is left to implementers to play nice. Another thing to be aware of is that the samples method of a listener will likely be called from a thread other than the one the object is created in. This means that implementers will probably want to make their implementations synchronized to prevent inconsistency.
Code Sample (online example)
[snip code_sample]http://code.compartmental.net/minim/examples/Recordable/addListener/addListener.pde[/snip]
Pingback: class — getting volume data in Flash and Processing
does anybody know of any way to get the frequency of a set of samples? i’m trying to draw a program that draws lines who’s color varies depending on the frequency of the sample.