0

I've got a problem with Audiokit's renderToFile method. I've got one AKClipPlayer, that has one clip starting from position 0.0. I need to render AKClipPlayer resulting playback into the file.

func preRender() {
       self.clipPlayer.play()
   }

   let writeFile = try AKAudioFile()
        guard let duration = self.musicPlayer.clips.first?.duration else {
            let error = makeError(message: "No track file")
            failure(error)
            return
        }
        self.clipPlayer.volume = 1.0
        preparePlayers()

        try AudioKit.renderToFile(writeFile, duration: duration,
                                  prerender: preRender)

Here is rendering results on picture below. enter image description here

First track is recorded audio clip. Second is first rendering result. File is truncated in the beginning. If I add another clip to clipPlayer and repeat rendering - first clip become unsynced. And the second one is in sync with click.

The question is what I'm doing wrong? How to make all of the clips to be synced when render. If I just play audio from clip player everything is perfectly synced.

I'am using Version 10.3 (10G8) and AudioKit v4.7.2

1 Answers1

0

To fix the issue - I have added an empty clip as the first element of clipPlayer.clips. This stops clips from unsyncing.