Debian Codegraph @

iOS/Csound iOS Obj-C Examples/Csound iOS Examples/ViewControllers/Harmonizer/HarmonizerTest.m

raw
1 /*
2
3 HarmonizerTest.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
27
28 #import "HarmonizerTest.h"
29
30 @implementation HarmonizerTest
31
32 -(void)viewDidLoad {
33 self.title = @"12. Mic: Harmonizer";
34 [super viewDidLoad];
35 }
36
37 -(IBAction) toggleOnOff:(id)component {
38 UISwitch *uiswitch = (UISwitch *)component;
39 NSLog(@"Status: %d", [uiswitch isOn]);
40
41 if(uiswitch.on) {
42
43 NSString *tempFile = [[NSBundle mainBundle] pathForResource:@"harmonizer" ofType:@"csd"];
44 NSLog(@"FILE PATH: %@", tempFile);
45
46 [self.csound stop];
47
48 self.csound = [[CsoundObj alloc] init];
49 self.csound.useAudioInput = YES;
50 [self.csound addListener:self];
51
52 CsoundUI *csoundUI = [[CsoundUI alloc] initWithCsoundObj:self.csound];
53
54 [csoundUI addSlider:mHarmPitchSlider forChannelName:@"slider"];
55 [csoundUI addSlider:mGainSlider forChannelName:@"gain"];
56
57 [self.csound play:tempFile];
58
59 } else {
60 [self.csound stop];
61 }
62 }
63
64 - (IBAction)showInfo:(UIButton *)sender {
65 UIViewController *infoVC = [[UIViewController alloc] init];
66 infoVC.modalPresentationStyle = UIModalPresentationPopover;
67
68 UIPopoverPresentationController *popover = infoVC.popoverPresentationController;
69 popover.sourceView = sender;
70 popover.sourceRect = sender.bounds;
71 [infoVC setPreferredContentSize:CGSizeMake(300, 120)];
72
73 UITextView *infoText = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, infoVC.preferredContentSize.width, infoVC.preferredContentSize.height)];
74 infoText.editable = NO;
75 infoText.selectable = NO;
76 NSString *description = @"This examples uses Csound's streaming phase vocoder to create a harmonizer effect. A dry/wet balance control is provided.";
77 [infoText setAttributedText:[[NSAttributedString alloc] initWithString:description]];
78 infoText.font = [UIFont fontWithName:@"Menlo" size:16];
79 [infoVC.view addSubview:infoText];
80 popover.delegate = self;
81
82 [popover setPermittedArrowDirections:UIPopoverArrowDirectionUp];
83
84 [self presentViewController:infoVC animated:YES completion:nil];
85
86 }
87
88
89
90 #pragma mark CsoundObjListener
91
92 -(void)csoundObjCompleted:(CsoundObj *)csoundObj {
93 [mSwitch setOn:NO animated:YES];
94 }
95
96 @end