2011-10-25 23 views
1

iPhoneの画面上をタッチすると連続したオーディオクリップを再生しようとしています。画面領域に応じて特定のオーディオ切り抜きがあります。タッチがその領域を変更すると、前のオーディオは消えて&(新しい領域の)新しいクリップがフェードインします [self playSoundForRect]メソッドを呼び出す領域の変更を検出しています。方法は次のとおりです。iPhoneのタッチ操作でオーディオファイルを連続して再生する

-(void)playSoundWithPath 
{ 
    [self fadeVolume]; 
    NSString *audioPath; 
    switch (curRect) // curRect is the Currently entered region 
    { 
     case 1: 
      audioPath = [[NSBundle mainBundle] pathForResource:@"clip1" ofType:@"mp3"]; 
      break; 
     case 2: 
      audioPath = [[NSBundle mainBundle] pathForResource:@"clip2" ofType:@"mp3"]; 
      break; 
     case 3: 
      audioPath = [[NSBundle mainBundle] pathForResource:@"clip3" ofType:@"mp3"]; 
      break; 
     case 4: 
      audioPath = [[NSBundle mainBundle] pathForResource:@"clip4" ofType:@"mp3"]; 
      break; 
     default: 
      break; 
    } 
    theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:audioPath] error:NULL]; 
    theAudio.delegate = self; 
    [theAudio play]; 
} 

-(void)fadeVolume 
{ 
    if (theAudio.volume > 0.1) 
    { 
     theAudio.volume -= 0.1; 
     [self performSelector:@selector(fadeVolume) withObject:nil afterDelay:0.1];   
    } 
    else 
    { 
     [theAudio stop]; 
    } 
} 

コードは正しく動作していません。どのように正しく&のクリップを混ぜて、彼らは滑らかに感じるように&連続?どのようなsuggesion歓迎です。

答えて

0

生のオーディオ用のミキサーを作成し、AVPlayer APIの代わりにRemoteIOを使用してミックスをストリーミングしてみてください。

+0

お返事ありがとうございます。 RemoteIOは少し複雑ですが、私はOpenALを使用しています。 –

関連する問題