Debian Codegraph @

iOS/Csound iOS Obj-C Examples/Csound iOS Examples/ViewControllers/CsoundHaiku4/CsoundHaiku4ViewController.m

raw
1 /*
2
3 CsoundHaiku4ViewController.m:
4
5 Copyright (C) 2011 Steven Yi
6 Updated in 2017 by Dr. Richard Boulanger, Nikhil Singh
7
8 This file is part of Csound iOS Examples.
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 #import "CsoundHaiku4ViewController.h"
27
28 @implementation CsoundHaiku4ViewController
29
30 -(void)viewDidLoad {
31 self.title = @"05. Play: Haiku IV";
32 [super viewDidLoad];
33 }
34
35 -(void)viewDidAppear:(BOOL)animated {
36 [super viewDidAppear:animated];
37
38 NSString *tempFile = [[NSBundle mainBundle] pathForResource:@"IV" ofType:@"csd"];
39 NSLog(@"FILE PATH: %@", tempFile);
40
41 [self.csound stop];
42
43 self.csound = [[CsoundObj alloc] init];
44
45 [self.csound play:tempFile];
46 }
47
48 -(IBAction)showSite:(UIButton *)sender {
49 NSURL *url = [NSURL URLWithString:@"http://iainmccurdy.org/csoundhaiku.html"];
50 SFSafariViewController *safariVC = [[SFSafariViewController alloc] initWithURL:url];
51
52 [self presentViewController:safariVC animated:YES completion:nil];
53 }
54
55 - (IBAction)showInfo:(UIButton *)sender {
56 UIViewController *infoVC = [[UIViewController alloc] init];
57 infoVC.modalPresentationStyle = UIModalPresentationPopover;
58
59 UIPopoverPresentationController *popover = infoVC.popoverPresentationController;
60 popover.sourceView = sender;
61 popover.sourceRect = sender.bounds;
62 [infoVC setPreferredContentSize:CGSizeMake(300, 180)];
63
64 UITextView *infoText = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, infoVC.preferredContentSize.width, infoVC.preferredContentSize.height)];
65 infoText.editable = NO;
66 infoText.selectable = NO;
67 NSString *description = @"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.";
68 [infoText setAttributedText:[[NSAttributedString alloc] initWithString:description]];
69 infoText.font = [UIFont fontWithName:@"Menlo" size:16];
70 [infoVC.view addSubview:infoText];
71 popover.delegate = self;
72
73 [popover setPermittedArrowDirections:UIPopoverArrowDirectionUp];
74
75 [self presentViewController:infoVC animated:YES completion:nil];
76
77 }
78
79 @end