I'm trying to mix six sound clips together.
Imagine each clip is a single guitar string pluck sound and I want to mix them to produce a guitar chord.
Here, a clip is an array of real numbers in the range [-1,1], where each number is a m开发者_JS百科ono sample.
double mixed_sample = mix(double sample1, ..., double sample6);
Please, implement mix
!
You have got to be kidding.
Mixing is simple addition of signals.
double mix(double s1, double s2, double s3, double s4, double s5, double s6)
{
return (s1 + s2 + s3 + s4 + s5 + s6);
}
Next step is to provide individual channel gains.
double variable_mix(double s1, double s2, double s3, double s4, double s5, double s6,
double g1, double g2, double g3, double g4, double g5, double g6)
{
return (s1*g1 + s2*g2 + s3*g3 + s4*g4 + s5*g5 + s6*g6);
}
Of course, this is kind of a pain in the ass to code, and the parameter-passing overhead will eat you alive, but this is basically what you have to do.
精彩评论