 import UIKit
 import AVFoundation
-import XCPlayground
+import PlaygroundSupport
 
-guard let audioFileURL = NSBundle.mainBundle().URLForResource("snare-analog", withExtension: "wav") else {
+guard let audioFileURL = Bundle.main.url(forResource: "snare-analog", withExtension: "wav") else {
     fatalError("audio file is not in bundle.")
 }
 
-var audioFile:AVAudioFile?
+var audioFile: AVAudioFile?
 do {
     audioFile = try AVAudioFile(forReading: audioFileURL)
 } catch {

let session = AVAudioSession.sharedInstance()
do {
    try session.setCategory(AVAudioSessionCategoryPlayback)
    try session.overrideOutputAudioPort(.Speaker)
    try session.setActive(true)
} catch {
    fatalError("cannot create/set session \(error)")

delay.wetDryMix = 100

let reverb = AVAudioUnitReverb()
reverb.loadFactoryPreset(.cathedral)
reverb.wetDryMix = 50

var timePitch = AVAudioUnitTimePitch()
timePitch.pitch = 100 // cents
timePitch.rate = 2

engine.attach(player)
engine.attach(delay)
engine.attach(reverb)
engine.attach(timePitch)

let format = audioFile!.processingFormat
engine.connect(player, to: delay, format: format)
