OpenAL multiple sounds POP

Discussion in 'iOS Programming' started by nickculbertson, May 23, 2011.

  1. nickculbertson, May 23, 2011
    Last edited: May 23, 2011

    macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #1
    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.
    Code:
    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.

    Code:
    -(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
     

Share This Page