Debian Codegraph @

iOS/Csound iOS Obj-C Examples/Csound iOS Examples/ViewControllers/PitchShifter/PitchShifterViewController.m

raw
1 /*
2
3 PitchShifterViewController.m:
4
5 Copyright (C) 2014 Thomas Hass, 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 "PitchShifterViewController.h"
28
29 @implementation PitchShifterViewController
30
31 - (IBAction)toggleOnOff:(UISwitch *)sender
32 {
33 if (sender.on) {
34 NSString *tempFile = [[NSBundle mainBundle] pathForResource:@"pitchshifter" ofType:@"csd"];
35
36 [self.csound stop];
37 self.csound = [[CsoundObj alloc] init];
38 self.csound.useAudioInput = YES;
39
40 [self.csound addBinding:mXYControl];
41
42 [self.csound play:tempFile];
43 } else {
44 [self.csound stop];
45 }
46 }
47
48 - (IBAction)showInfo:(UIButton *)sender {
49 UIViewController *infoVC = [[UIViewController alloc] init];
50 infoVC.modalPresentationStyle = UIModalPresentationPopover;
51
52 UIPopoverPresentationController *popover = infoVC.popoverPresentationController;
53 popover.sourceView = sender;
54 popover.sourceRect = sender.bounds;
55 [infoVC setPreferredContentSize:CGSizeMake(300, 150)];
56
57 UITextView *infoText = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, infoVC.preferredContentSize.width, infoVC.preferredContentSize.height)];
58 infoText.editable = NO;
59 infoText.selectable = NO;
60 NSString *description = @"This example uses Csound's 'pvs' real-time spectral-processing opcodes to perform pitch-shifting on a live microphone input signal, controlled with a custom XY control pad.";
61 [infoText setAttributedText:[[NSAttributedString alloc] initWithString:description]];
62 infoText.font = [UIFont fontWithName:@"Menlo" size:16];
63 [infoVC.view addSubview:infoText];
64 popover.delegate = self;
65
66 [popover setPermittedArrowDirections:UIPopoverArrowDirectionUp];
67
68 [self presentViewController:infoVC animated:YES completion:nil];
69
70 }
71
72 - (void)csoundObjCompleted:(CsoundObj *)csoundObj {
73 [mSwitch setOn:NO animated:YES];
74 }
75
76 #pragma mark - Lifecycle
77
78 - (void)viewDidLoad
79 {
80 [super viewDidLoad];
81 self.title = @"16. Mic: XY PitchShift+Mix";
82
83 [mXYControl setXValue:1.0f];
84 [mXYControl setYValue:0.5f];
85 }
86
87
88 @end