TheJeff
TheJeff

Reputation: 4121

Playing Audio With AudioKit 5 - Unable to start playback

I'm trying to get AudioKit 5 working. The docs are kind of a massive monolith, no easy central getting started guide that I can find. There are a bazillion samples, but getting started should be easy.

All of the playground tutorials don't quite work, since this is an iOS app, not a playground, and AudioKit.start() doesn't seem to be an actual thing.

Anyhoo, here's my code:

    import AudioKit

    // run some method with the code below:
    let engine = AudioEngine()
    let audioPlayer = AudioPlayer()
    let pitchShifter = TimePitch(audioPlayer)
    engine.output = audioPlayer
    do {
        try engine.start()
        let audioFile = try AVAudioFile(forReading: url)
        try audioPlayer.load(file: audioFile, buffered: true)
    } catch {
        let lastError = "Failed to start AudioKit engine: \(error.localizedDescription)"
        print(lastError ?? "Unknown error")
    }
    audioPlayer.play()

Nothing throws errors, it just get no output from the phone.

Upvotes: 0

Views: 49

Answers (0)

Related Questions