AKAudioFile inherits from AVAudioFile so you can use it just like any AVAudioFile
The baseDirectory parameter if an enum value from AKAudioFile.BaseDirectory :
baseDir is defaulted to be .resources, so loading an AKAudiofile
from this playground Resources folder can be done like this :
As AKAudioFile is an optional, it will be set to nil if a problem occurs.
Notice that an error message is printed in the debug area, and an error is thrown...
So it's a good idea to check that the AKAudioFile is valid before using it.
Let's display some info about drumloop :
AKAudioFile can easily be trimmed and exported and you can set a
callback function that will be triggered upon export has been completed.
Then, we can extract from 1 to 2 seconds of drumloop, as an mp4 file that will be
written in documents directory. If the destination file exists, it will be overwritten.
AKAudioFile for writing / recording
AKAudioFile is handy to create file for recording or writing to.
If you set no parameter, an AKAudioFile is created in temp directory,
set to match AudioKit AKSettings (a stereo empty 32 bits float wav file at 44.1 kHz,
with a unique name identifier.
The simplest way to create such a file is like this:
But the benefits of using AKAudioFile instead of AVAudioFile, is that you can normalize,
reverse them or extract samples as float arrays. You can even perform audio edits very easily.
Have a look to AKAudioFile Part 2...