We begin by cleaning our bedroom... (any audioFiles in the Temp directory are deleted)
We load the piano piece from resources and play it :
While the piano is playing, we will process the file in background. AKAudioFile has a private ProcessFactory
that will handle any process in background
We define a call back that will be invoked when an async process has been completed. Notice that the process can
have succeeded or failed. if processedFile is different from nil, process succeeded, so you can get the processed
file. If processedFile is nil, process failed, but you can get the process thrown error:
Let's process our piano asynchronously. First, we reverse the piano so it will play backward...
Now we lower the piano level by normalizing it to a max level set at - 6 dB
Now, extract one second from piano...
You may have noticed that Async Processes are queued serially. That means that the next process will only occur
AFTER previous processes have been completed. First in, first out, completionHandlers will always be triggered in
the same order as you invoked an async process.
Most of the time, you 'll want to chain process. Then, you have to define a specific callback for each
process step. Let's experiment with the drum loop
We will first reverse the loop, and append the original loop to the reversed loop, and replace the file of our
player with the resulting processed file.
These processes are done in background, that means that the next line will be printed BEFORE the first (or any)
async process has ended.