1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
|
/*
MasterViewController.m:
Copyright (C) 2011 Steven Yi
Updated in 2017 by Dr. Richard Boulanger, Nikhil Singh
This file is part of Csound iOS Examples.
The Csound for iOS Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Csound is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Csound; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
*/
#import "MasterViewController.h"
#import "DetailViewController.h"
#import "SimpleTest1ViewController.h"
#import "SimpleTest2ViewController.h"
#import "ButtonTestViewController.h"
#import "MidiTestViewController.h"
#import "AppDelegate.h"
#import "BaseCsoundViewController.h"
#import "AudioInTestViewController.h"
#import "HarmonizerTest.h"
#import "HardwareTestViewController.h"
#import "InstrumentEditorViewController.h"
#import "CsoundHaiku4ViewController.h"
#import "RecordTestViewController.h"
#import "MultiTouchXYViewController.h"
#import "WaveviewViewController.h"
#import "AudioFileTestViewController.h"
#import "ConsoleOutputViewController.h"
#import "PitchShifterViewController.h"
#import "TrappedGeneratorViewController.h"
@implementation MasterViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Csound for iOS";
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.clearsSelectionOnViewWillAppear = NO;
self.preferredContentSize = CGSizeMake(320.0, 600.0);
}
testNames = [NSMutableArray arrayWithObjects:
@"01. Simple Test 1",
@"02. Simple Test 2",
@"03. Button Test",
@"04. Play: Haiku IV",
@"05. Render: Trapped in Convert",
@"06. Render: Console Output",
@"07. Instrument Tweaker",
@"08. F-table Viewer",
@"09. Soundfile: Pitch Shifter",
@"10. Mic: Stereo Delay",
@"11. Mic: Harmonizer",
@"12. Mic: Recording",
@"13. Hardware: MIDI Controller",
@"14. Hardware: Motion Control",
@"15. XY Pad: MultiTouch ",
@"16. XY Pad: Mic PitchShift+Mix",
nil];
}
return self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionMiddle];
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return testNames.count;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
// Configure the cell.
cell.textLabel.text = [testNames objectAtIndex:indexPath.row];
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
BaseCsoundViewController* controller;
//should probably enum this someday
switch (indexPath.row) {
case 0:
controller = [[SimpleTest1ViewController alloc] initWithNibName:@"SimpleTest1ViewController" bundle:nil];
break;
case 1:
controller = [[SimpleTest2ViewController alloc] initWithNibName:@"SimpleTest2ViewController" bundle:nil];
break;
case 2:
controller = [[ButtonTestViewController alloc] initWithNibName:@"ButtonTestViewController" bundle:nil];
break;
case 3:
controller = [[CsoundHaiku4ViewController alloc] initWithNibName:@"CsoundHaiku4ViewController" bundle:nil];
break;
case 4:
controller = [[TrappedGeneratorViewController alloc] initWithNibName:@"TrappedGeneratorViewController" bundle:nil];
break;
case 5:
controller = [[ConsoleOutputViewController alloc] initWithNibName:@"ConsoleOutputViewController" bundle:nil];
break;
case 6:
controller = [[InstrumentEditorViewController alloc] initWithNibName:@"InstrumentEditorViewController" bundle:nil];
break;
case 7:
controller = [[WaveviewViewController alloc] initWithNibName:@"WaveviewViewController" bundle:nil];
break;
case 8:
controller = [[AudioFileTestViewController alloc] initWithNibName:@"AudioFileTestViewController" bundle:nil];
break;
case 9:
controller = [[AudioInTestViewController alloc] initWithNibName:@"AudioInTestViewController" bundle:nil];
break;
case 10:
controller = [[HarmonizerTest alloc] initWithNibName:@"HarmonizerTest" bundle:nil];
break;
case 11:
controller = [[RecordTestViewController alloc] initWithNibName:@"RecordTestViewController" bundle:nil];
break;
case 12:
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
controller = [[MidiTestViewController alloc] initWithNibName:@"MidiTestViewController" bundle:nil];
} else {
controller = [[MidiTestViewController alloc] initWithNibName:@"MidiTestViewController_iPad" bundle:nil];
}
break;
case 13:
controller = [[HardwareTestViewController alloc] initWithNibName:@"HardwareTestViewController" bundle:nil];
break;
case 14:
controller = [[MultiTouchXYViewController alloc] initWithNibName:@"MultiTouchXYViewController" bundle:nil];
break;
case 15:
controller = [[PitchShifterViewController alloc] initWithNibName:@"PitchShifterViewController" bundle:nil];
break;
default:
break;
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[self.navigationController pushViewController:controller animated:YES];
[(UITableView *)self.view deselectRowAtIndexPath:indexPath animated:YES];
} else {
AppDelegate *appDelegate = (AppDelegate *)([UIApplication sharedApplication].delegate);
UISplitViewController *splitViewController = appDelegate.splitViewController;
BaseCsoundViewController *currentDetail = (BaseCsoundViewController *)splitViewController.delegate;
if(currentDetail.navigationItem.leftBarButtonItem != nil) {
controller.navigationItem.leftBarButtonItem = currentDetail.navigationItem.leftBarButtonItem;
controller.masterPopoverController = currentDetail.masterPopoverController;
}
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:controller];
NSArray *viewControllers = [[NSArray alloc] initWithObjects:[splitViewController.viewControllers objectAtIndex:0], detailNavigationController, nil];
splitViewController.viewControllers = viewControllers;
splitViewController.delegate = controller;
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) {
[UIView animateWithDuration:0.2 animations:^{
splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
}];
}
}
}
@end
|