Search code examples
swiftaudioaudiokitavaudioengine

Removing audio channels from audio file swift


I need to remove specific audio channels from the audio file and I need to save it as a mono file. I found that it can be achieved using AVAudioEngine or AudioKit but I didn't find any helpful example.

What do I need if the audio file is 5.1 channels? I would like to separate all channels, remove specific channels like channel 2, 3 and 4, merge the remaining channel, and make a mono audio file and save it.


Solution

  • I didn't find any good way for this but how I achieved this is by converting audio to wav file then I separate each channel sample, combined only data of the channels I required and then convert that file multichannel wav file.

    I used the guidance form the link http://soundfile.sapp.org/doc/WaveFormat/ for identifying wave file header and separating each channel sample.

    then I converted the multichannel wav file to mono channel using AVAssetReader and AVAssetWriter.