| 1 |
/* |
| 2 |
|
| 3 |
AudioInTestViewController.swift |
| 4 |
|
| 5 |
Nikhil Singh, Dr. Richard Boulanger |
| 6 |
Adapted from the Csound iOS Examples by Steven Yi and Victor Lazzarini |
| 7 |
|
| 8 |
This file is part of Csound iOS SwiftExamples. |
| 9 |
|
| 10 |
The Csound for iOS Library is free software; you can redistribute it |
| 11 |
and/or modify it under the terms of the GNU Lesser General Public |
| 12 |
License as published by the Free Software Foundation; either |
| 13 |
version 2.1 of the License, or (at your option) any later version. |
| 14 |
|
| 15 |
Csound is distributed in the hope that it will be useful, |
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
GNU Lesser General Public License for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU Lesser General Public |
| 21 |
License along with Csound; if not, write to the Free Software |
| 22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 23 |
02111-1307 USA |
| 24 |
|
| 25 |
*/ |
| 26 |
|
| 27 |
import UIKit |
| 28 |
|
| 29 |
class AudioInTestViewController: BaseCsoundViewController { |
| 30 |
|
| 31 |
@IBOutlet var mLeftDelayTimeSlider: UISlider! |
| 32 |
@IBOutlet var mLeftFeedbackSlider: UISlider! |
| 33 |
@IBOutlet var mRightDelayTimeSlider: UISlider! |
| 34 |
@IBOutlet var mRightFeedbackSlider: UISlider! |
| 35 |
@IBOutlet var mSwitch: UISwitch! |
| 36 |
|
| 37 |
override func viewDidLoad() { |
| 38 |
title = "11. Mic: Stereo Delay" |
| 39 |
super.viewDidLoad() |
| 40 |
} |
| 41 |
|
| 42 |
@IBAction func toggleOnOff(_ sender: UISwitch) { |
| 43 |
print("Status: \(sender.isOn)") |
| 44 |
|
| 45 |
if sender.isOn { |
| 46 |
let tempFile = Bundle.main.path(forResource: "audioInTest", ofType: "csd") |
| 47 |
|
| 48 |
csound.stop() |
| 49 |
csound = CsoundObj() |
| 50 |
csound.useAudioInput = true |
| 51 |
csound.add(self) |
| 52 |
|
| 53 |
let csoundUI: CsoundUI = CsoundUI(csoundObj: csound) |
| 54 |
csoundUI.add(mLeftDelayTimeSlider, forChannelName: "leftDelayTime") |
| 55 |
csoundUI.add(mLeftFeedbackSlider, forChannelName: "leftFeedback") |
| 56 |
csoundUI.add(mRightDelayTimeSlider, forChannelName: "rightDelayTime") |
| 57 |
csoundUI.add(mRightFeedbackSlider, forChannelName: "rightFeedback") |
| 58 |
|
| 59 |
csound.play(tempFile) |
| 60 |
} else { |
| 61 |
csound.stop() |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
@IBAction func showInfo(_ sender: UIButton) { |
| 66 |
infoVC.preferredContentSize = CGSize(width: 300, height: 120) |
| 67 |
infoText = "This example shows audio processing in real-time with independent delay-time and feedback settings for each channel." |
| 68 |
displayInfo(sender) |
| 69 |
} |
| 70 |
|
| 71 |
override func didReceiveMemoryWarning() { |
| 72 |
super.didReceiveMemoryWarning() |
| 73 |
// Dispose of any resources that can be recreated. |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
extension AudioInTestViewController: CsoundObjListener { |
| 78 |
func csoundObjCompleted(_ csoundObj: CsoundObj!) { |
| 79 |
DispatchQueue.main.async { [unowned self] in |
| 80 |
self.mSwitch.isOn = false |
| 81 |
} |
| 82 |
} |
| 83 |
} |