How to export a sample of a file with AudioKit 5.0.b1?

209 views Asked by At

I am trying to update my app so it can run using Xcode 12.0 beta 3 (12A8169g) and AudioKit 5.0.b1. Previously I had this code to export my AKAudioFile into a desired format and with defined start and end positions:

let sampleRate = audioFile.fileFormat.sampleRate
let fromSample = Int64(audioFile.duration * start * sampleRate)
let toSample = Int64(audioFile.duration * end * sampleRate)
audioFile.exportAsynchronously(name: "audio", baseDir: .temp, exportFormat: exportFormat, fromSample: fromSample, toSample: toSample) { file, error in
    guard let file = file else {
        return
    }
    success(file)
}

Currently it seems that I have to use AKConverter for this task, but it seems that I cannot specify fromSample and toSample when I convert the file. So probably there is a way to first cut a portion of a file and then convert it to the desired format, but I did not find how can I efficiently do that. So how can I convert my code so that it works with v.5.0.b1?

0

There are 0 answers