| 1 |
/* |
| 2 |
|
| 3 |
InstrumentEditorViewController.m: |
| 4 |
|
| 5 |
Copyright (C) 2014 Aurelius Prochazka |
| 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 |
|
| 27 |
#import "InstrumentEditorViewController.h" |
| 28 |
|
| 29 |
@interface InstrumentEditorViewController() |
| 30 |
@property (strong, nonatomic) IBOutlet UITextView *orchestraTextView; |
| 31 |
@end |
| 32 |
|
| 33 |
@implementation InstrumentEditorViewController |
| 34 |
|
| 35 |
-(void)viewDidLoad { |
| 36 |
self.title = @"08. Instrument Tweaker"; |
| 37 |
[super viewDidLoad]; |
| 38 |
NSString *csdFile = [[NSBundle mainBundle] pathForResource:@"instrumentEditor" ofType:@"csd"]; |
| 39 |
NSLog(@"FILE PATH: %@", csdFile); |
| 40 |
|
| 41 |
[self.csound stop]; |
| 42 |
|
| 43 |
self.csound = [[CsoundObj alloc] init]; |
| 44 |
[self.csound play:csdFile]; |
| 45 |
} |
| 46 |
- (IBAction)trigger:(id)sender { |
| 47 |
[self.csound updateOrchestra:self.orchestraTextView.text]; |
| 48 |
NSString *score = @"i1 0 1"; |
| 49 |
[self.csound sendScore:score]; |
| 50 |
} |
| 51 |
|
| 52 |
- (IBAction)showInfo:(UIButton *)sender { |
| 53 |
UIViewController *infoVC = [[UIViewController alloc] init]; |
| 54 |
infoVC.modalPresentationStyle = UIModalPresentationPopover; |
| 55 |
|
| 56 |
UIPopoverPresentationController *popover = infoVC.popoverPresentationController; |
| 57 |
popover.sourceView = sender; |
| 58 |
popover.sourceRect = sender.bounds; |
| 59 |
[infoVC setPreferredContentSize:CGSizeMake(300, 120)]; |
| 60 |
|
| 61 |
UITextView *infoText = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, infoVC.preferredContentSize.width, infoVC.preferredContentSize.height)]; |
| 62 |
infoText.editable = NO; |
| 63 |
infoText.selectable = NO; |
| 64 |
NSString *description = @"This example allows the user to modify the contents of the .csd on-the-fly using the updateOrchestra method from CsoundObj."; |
| 65 |
[infoText setAttributedText:[[NSAttributedString alloc] initWithString:description]]; |
| 66 |
infoText.font = [UIFont fontWithName:@"Menlo" size:16]; |
| 67 |
[infoVC.view addSubview:infoText]; |
| 68 |
popover.delegate = self; |
| 69 |
|
| 70 |
[popover setPermittedArrowDirections:UIPopoverArrowDirectionUp]; |
| 71 |
|
| 72 |
[self presentViewController:infoVC animated:YES completion:nil]; |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
@end |