PDA

View Full Version : OpenAL multiple sounds POP




nickculbertson
May 23, 2011, 09:57 AM
Hello,
I'm using the Finch OpenAL code for playing sounds using OpenAL. I eliminated the popping that occurs when a sound is played for a second time by adding an second identical sound and fading the volume of the first sound to 0.

if (Count41==1){
Count41==2;
sound2.gain = slider.value/20;
[self performSelector:@selector (stop1) withObject:nil afterDelay:0.05];
[sound play];
}else if (Count41==2){
Count41==1;
sound1.gain = slider.value/20;
[self performSelector:@selector (stop2) withObject:nil afterDelay:0.05];
[sound2 play];
}


The problem is when I play a third sound as the sound1 or sound2 are playing a pop occurs. play1 and play2 at the same time.


-(IBAction)play1{
if (Count41==1){
Count41==2;
sound2.gain = slider.value/20;
[self performSelector:@selector (stop1) withObject:nil afterDelay:0.05];
[sound play];
}else if (Count41==2){
Count41==1;
sound1.gain = slider.value/20;
[self performSelector:@selector (stop2) withObject:nil afterDelay:0.05];
[sound2 play];
}
}

-(IBAction)play2{
if (Count41==1){
Count42==2;
sound4.gain = slider.value/20;
[self performSelector:@selector (stop1) withObject:nil afterDelay:0.05];
[sound3 play];
}else if (Count42==2){
Count42==1;
sound3.gain = slider.value/20;
[self performSelector:@selector (stop2) withObject:nil afterDelay:0.05];
[sound4 play];
}
}



Any ideas on how to start a sound as one is already playing without the pop sound occurring.

Thanks,
Nick