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 › Combining/mixing-down samples
Page Index Toggle Pages: 1
Combining/mixing-down samples (Read 523 times)
Combining/mixing-down samples
Nov 28th, 2006, 4:46am
 
Greetings,
I'm trying to figure how to bounce multiple Sonia samples down to a single sample. The best analogy is probably to a 4-track recorder (does anyone use these anymore?). Basically I'm recording several samples via microphone, then want to mix them down to one -- any thoughts on a nice way to do this? I've been messing around with trying to disable the mic, then re-route the Sonia output (playing the already recorded samples) to LiveInput, but seems like there must be a better way...
thanks so much,
-dc
Re: Combining/mixing-down samples
Reply #1 - Nov 29th, 2006, 9:34pm
 
You *should* be able to do this with sonia, except the library has a bug that breaks the readChannel() function that you would need.  (See my post entitled "Sonia bug: readChannel() not working?")

So I'd reccomend switching to the ESS libary.  The syntax is almost exactly the same.  Anyway, to mix down 3 samples, called s1,s2,s3, try weighted addition into a destination sample.

Code:

float vol1=1.; //sample 1 is full volume
float vol2=.5; //sample 2 is half volume
float vol3=.25; //sample 3 is quarter volume
mixDown=new AudioChannel(441000); //destination


for(int i=0;i<441000;i++){ mixDown.samples[i]=s1.samples[i]*vol1+s2.samples[i]*vol2+s3.samples[i]*vol3;
}



Of course, in this example the source samples have to be at least as long as the destination sample, so you'd have to perform some checking to make sure you're not going outside array boundaries.
Page Index Toggle Pages: 1