How to use MTAudioProcessingTapProcessCallback to modify the pitch of the audio on iOS

12 views Asked by At

Here is the tapProcess callback. and How to modify the audio's pitch by modifying bufferListInOut, also, how to do if I just want to modify the audio in specific CMTimeRange

let tapProcessCallback: MTAudioProcessingTapProcessCallback = { tap,
        numberFrames, flags, bufferListInOut, numberFramesOut, flagsOut in
        var timeRange: CMTimeRange = CMTimeRange.zero
        let status = MTAudioProcessingTapGetSourceAudio(tap, numberFrames, bufferListInOut, flagsOut, &timeRange, numberFramesOut)
        if status != noErr {
            print("Failed to get source audio")
            return
        }
        let context = Unmanaged<AudioProcessingTapContext>.fromOpaque(MTAudioProcessingTapGetStorage(tap)).takeUnretainedValue()
        let bufferList = UnsafeMutableAudioBufferListPointer(bufferListInOut)
        
        // then how to modify audio.....
    }

I want to process the audio realtime when playback, and can change the audio in specific CMTimeRange

0

There are 0 answers