We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › getVolume getPan for drawing
Page Index Toggle Pages: 1
getVolume getPan for drawing (Read 733 times)
getVolume getPan for drawing
Feb 5th, 2009, 11:46pm
 
So I am trying to have a stroke move upwards if the volume is 'high' and downwards if the volume is 'low'. also i will have two microphones set up so if sound comes from the left the stroke should move to the left, sound coming form the right microphone will direct it to the right. I am working with the minim library and so far have experimented with audioInput and waveforms but I don't know how to extract the information of the volume and panning and then assign the outcome as the line coordinates. Would be great if anyone could help!
Re: getVolume getPan for drawing
Reply #1 - Feb 9th, 2009, 6:52am
 
hi

getVolume and getPan do not do what you wish they do. They return the value of a parameter for playing back sampled or synthesized sound, like the volume or pan knob on a mixer.

You want something that analyzes incoming sound and makes a value judgment about it, which is more complicated and inexact. Assuming there isn't some new analysis modules in the new minim that I don't know about, you'll have to write your own, here's a couple very basic ideas to get you rolling:

for volume: take the last X samples in the buffer and take the average of their absolute values. A small value for X makes this number very responsive and punchy (and jittery), while a larger X makes this number respond more slowly and smoothly. And remember that our ear does not interpret amplitude linearly as volume, so you'll probably want to do a square root of the results to get something that roughly correlates to a volume measurement.

for pan: take the volume measurements of the two inputs and compare their relative volumes to compute which side has more power.

best,
danI
Page Index Toggle Pages: 1