| 1 |
/* |
| 2 |
|
| 3 |
CsoundHaiku4ViewController.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 |
import SafariServices // For SFSafariViewController |
| 29 |
|
| 30 |
class CsoundHaiku4ViewController: BaseCsoundViewController { |
| 31 |
|
| 32 |
override func viewDidLoad() { |
| 33 |
title = "05. Play: Haiku IV" |
| 34 |
super.viewDidLoad() |
| 35 |
} |
| 36 |
|
| 37 |
override func viewDidAppear(_ animated: Bool) { |
| 38 |
super.viewDidAppear(animated) |
| 39 |
|
| 40 |
let tempFile = Bundle.main.path(forResource: "IV", ofType: "csd") |
| 41 |
|
| 42 |
csound.stop() |
| 43 |
csound = CsoundObj() |
| 44 |
csound.play(tempFile) |
| 45 |
} |
| 46 |
|
| 47 |
// Use SFSafariViewController to display Iain McCurdy's web-page about the piece |
| 48 |
@IBAction func showSite(_ sender: UIButton) { |
| 49 |
let url: URL! = URL(string: "http://iainmccurdy.org/csoundhaiku.html") |
| 50 |
let safariVC = SFSafariViewController(url: url) |
| 51 |
present(safariVC, animated: true, completion: nil) |
| 52 |
} |
| 53 |
|
| 54 |
@IBAction func showInfo(_ sender: UIButton) { |
| 55 |
infoVC.preferredContentSize = CGSize(width: 300, height: 180) |
| 56 |
infoText = "Haiku IV is the fourth in a suite of nine generative Csound pieces by Iain McCurdy. Csound begins rendering the work when the view appears and stops when the view unloads and CsoundObj is deallocated." |
| 57 |
displayInfo(sender) |
| 58 |
} |
| 59 |
|
| 60 |
override func didReceiveMemoryWarning() { |
| 61 |
super.didReceiveMemoryWarning() |
| 62 |
// Dispose of any resources that can be recreated. |
| 63 |
} |
| 64 |
} |