Skip to content

LimitPoint/ReverseAudio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

ReverseAudio

ReverseAudio.swift

Reverses one channel of an audio file into another 1-channel WAV audio file

Learn more about reversing audio files from our in-depth blog post.

The associated Xcode project implements a SwiftUI app for macOS and iOS that presents a list of audio files included in the bundle resources subdirectory 'Audio Files'.

Add your own audio files or use the sample set provided.

Each file in the list has an adjacent button to either play or reverse the audio.

Classes

The project is comprised of:

  1. The App (ReverseAudioApp) that displays a list of audio files in the project.
  2. And an ObservableObject (ReverseAudioObservable) that manages the user interaction to reverse and play audio files in the list.
  3. The AVFoundation code (ReverseAudio) that reads, reverses and writes audio files.

ReverseAudio

Reversing audio is performed in 3 steps using AVFoundation:

  1. Read the audio samples of a file into an Array of [Int16] and reverse it
  2. Create an array of sample buffers [CMSampleBuffer] for the array of reversed audio samples
  3. Write the reversed sample buffers in [CMSampleBuffer] to a file

The top level method that implements all of this, and is employed by the ReverseAudioObservable is:

func reverseAudio(asset:AVAsset, destinationURL:URL, progress: @escaping (Float) -> (), completion: @escaping (Bool, String?) -> ())

About

Reverses one channel of an audio file into another 1-channel WAV audio file

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages