var audioFile:AVAudioFile! var audioEngine:AVAudioEngine! var audioPlayerNode: AVAudioPlayerNode! var stopTimer: Timer! enum ButtonType: Int { case slow = 0, fast, chipmunk, vader, echo, reverb } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) configureUI(.notPlaying) } override func viewDidLoad() { super.viewDidLoad() print("second viewDidLoad") print(recordedAudioURL) setupAudio() // Do any additional setup after loading the view. } @IBAction func playSoundForButton(_ sender: UIButton) { switch (ButtonType(rawValue: sender.tag)!) { case .slow: playSound(rate : 0.5) case .fast: playSound(rate : 1.5) case .chipmunk: playSound(pitch : 1000) case .vader: playSound(pitch : -1000) case .echo: playSound(echo : true) case .reverb: playSound(reverb : true) default: playSound() } configureUI(.playing) print("Play Sound Button Pressed") } @IBAction func stopButtonPressed(_ sender: AnyObject) { stopAudio() print("Stop Audio Button Pressed") }
Add a code snippet to your website: www.paste.org