播放录制的音频,没有毛刺

时间:2013-03-26 06:55:57

标签: ios avaudioplayer avaudiorecorder avaudiosession

我录制了音频文件:

NSDictionary *recordSettings = [NSDictionary
                                            dictionaryWithObjectsAndKeys:
                                            [NSNumber numberWithInt:AVAudioQualityMin],
                                            AVEncoderAudioQualityKey,
                                            [NSNumber numberWithInt:16],
                                            AVEncoderBitRateKey,
                                            [NSNumber numberWithInt: 2],
                                            AVNumberOfChannelsKey,
                                            [NSNumber numberWithFloat:44100.0],
                                            AVSampleRateKey,
                                            nil];
            NSError *error = nil;
            recorder = [[AVAudioRecorder alloc]
                        initWithURL:soundFileURL
                        settings:recordSettings
                        error:&error];

通过以下方式播放音频播放器:

  UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
        AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
        UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
        AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);

DiracAudioPlayer *mDiracAudioPlayer = [[DiracAudioPlayer alloc] initWithContentsOfURL:inUrl channels:1 error:&error];
    [mDiracAudioPlayer setDelegate:self];
    mDiracAudioPlayer.numberOfLoops=-0;
    mDiracAudioPlayer.volume=0.1;  
    [mDiracAudioPlayer play];   

但是当我一次又一次地录制和播放音频文件时。我引起了毛刺  一段时间。

如何避免这些故障? 请!帮助我。

0 个答案:

没有答案