1/* 2 3 AudioInTestViewController.m: 4 5 Copyright (C) 2014 Steven Yi, Victor Lazzarini, 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 "AudioInTestViewController.h" 28 29@implementation AudioInTestViewController 30 31-(void)viewDidLoad { 32 self.title = @"11. Mic: Stereo Delay"; 33 [super viewDidLoad]; 34} 35 36-(IBAction)toggleOnOff:(id)component { 37 UISwitch *uiswitch = (UISwitch *)component; 38 NSLog(@"Status: %d", [uiswitch isOn]); 39 40 if(uiswitch.on) { 41 42 NSString *tempFile = [[NSBundle mainBundle] pathForResource:@"audioInTest" 43 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:_mLeftDelayTimeSlider forChannelName:@"leftDelayTime"]; 55 [csoundUI addSlider:_mLeftFeedbackSlider forChannelName:@"leftFeedback"]; 56 [csoundUI addSlider:_mRightDelayTimeSlider forChannelName:@"rightDelayTime"]; 57 [csoundUI addSlider:_mRightFeedbackSlider forChannelName:@"rightFeedback"]; 58 59 [self.csound play:tempFile]; 60 61 } else { 62 [self.csound stop]; 63 } 64} 65 66- (IBAction)showInfo:(UIButton *)sender { 67 UIViewController *infoVC = [[UIViewController alloc] init]; 68 infoVC.modalPresentationStyle = UIModalPresentationPopover; 69 70 UIPopoverPresentationController *popover = infoVC.popoverPresentationController; 71 popover.sourceView = sender; 72 popover.sourceRect = sender.bounds; 73 [infoVC setPreferredContentSize:CGSizeMake(300, 120)]; 74 75 UITextView *infoText = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, infoVC.preferredContentSize.width, infoVC.preferredContentSize.height)]; 76 infoText.editable = NO; 77 infoText.selectable = NO; 78 NSString *description = @"This example shows audio processing in real-time with independent delay-time and feedback settings for each channel."; 79 [infoText setAttributedText:[[NSAttributedString alloc] initWithString:description]]; 80 infoText.font = [UIFont fontWithName:@"Menlo" size:16]; 81 [infoVC.view addSubview:infoText]; 82 popover.delegate = self; 83 84 [popover setPermittedArrowDirections:UIPopoverArrowDirectionUp]; 85 86 [self presentViewController:infoVC animated:YES completion:nil]; 87 88} 89 90 91 92#pragma mark CsoundObjListener 93 94-(void)csoundObjCompleted:(CsoundObj *)csoundObj { 95 [_mSwitch setOn:NO animated:YES]; 96} 97@end 98