annotate SliderViewController.mm @ 49:178642d134a7 tip

xtra files
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 01 May 2013 17:34:33 +0100
parents 43958fd481aa
children
rev   line source
rt300@36 1 //
rt300@36 2 // SliderViewController.m
rt300@36 3 // sonicZoom
rt300@36 4 //
rt300@36 5 // Created by Robert Tubb on 01/02/2013.
rt300@36 6 //
rt300@36 7 //
rt300@36 8
rt300@36 9 #import "SliderViewController.h"
rt300@48 10 #include "testApp.h"
rt300@36 11
rt300@36 12 @interface SliderViewController ()
rt300@36 13
rt300@36 14 @end
rt300@36 15
rt300@36 16 @implementation SliderViewController
rt300@36 17
rt300@45 18
rt300@45 19 // init with either sequencer or all timbre
rt300@36 20 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
rt300@36 21 {
rt300@36 22 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
rt300@36 23 if (self) {
rt300@36 24 // Custom initialization
rt300@43 25 [self populateParamNames];
rt300@43 26 self.sliderArray = [[NSMutableArray alloc] init];
rt300@43 27
rt300@36 28 }
rt300@36 29 return self;
rt300@36 30 }
rt300@36 31
rt300@36 32 - (void)viewDidLoad
rt300@36 33 {
rt300@43 34 int left = 22;
rt300@44 35 int top = 10;
rt300@44 36 const int height = 50;
rt300@43 37 const int width = 337;
rt300@43 38
rt300@36 39 [super viewDidLoad];
rt300@43 40
rt300@43 41 for(int i=0;i<10;i++){
rt300@43 42
rt300@43 43 if(i==5){
rt300@44 44 top = 10;
rt300@43 45 left = left*3 + width;
rt300@43 46 }
rt300@43 47 SliderController * sliderV = [[SliderController alloc] initWithNibName:@"SliderController" bundle:nil delegate:self pID:i];
rt300@43 48
rt300@43 49 [self.view addSubview:sliderV.view];
rt300@43 50
rt300@43 51 sliderV.view.frame = CGRectMake(left,top,width,height);
rt300@43 52 [sliderV setPID:i];
rt300@43 53 NSLog(@"setting name to %@", self.paramNames[i]);
rt300@43 54 [sliderV changeLabel:self.paramNames[i] ];
rt300@43 55 [sliderV setParamValue:44];
rt300@44 56 if(i>=5){
rt300@44 57 [sliderV makeRed];
rt300@44 58 }
rt300@43 59 top += height;
rt300@43 60
rt300@43 61 [self.sliderArray addObject:sliderV]; // not working
rt300@43 62
rt300@43 63 }
rt300@43 64 int i = [self.sliderArray count];
rt300@43 65 NSLog(@"count: %d", i);
rt300@43 66
rt300@43 67 [(SliderController *)[self.sliderArray objectAtIndex:5] setParamValue:13];
rt300@43 68
rt300@36 69 }
rt300@36 70
rt300@36 71 - (void)didReceiveMemoryWarning
rt300@36 72 {
rt300@36 73 [super didReceiveMemoryWarning];
rt300@36 74 // Dispose of any resources that can be recreated.
rt300@36 75 }
rt300@36 76
rt300@36 77 - (void)setAppRef:(id)theOFApp{
rt300@36 78 self.theOFAppRef = theOFApp;
rt300@36 79
rt300@36 80 }
rt300@36 81
rt300@36 82 - (IBAction)show:(id)sender
rt300@36 83 {
rt300@36 84 self.theOFAppRef = sender;
rt300@36 85 self.view.hidden = NO;
rt300@36 86 }
rt300@43 87 - (IBAction)hide:(id)sender
rt300@43 88 {
rt300@43 89 self.theOFAppRef = sender;
rt300@43 90 self.view.hidden = YES;
rt300@43 91 }
rt300@37 92 - (void)dealloc {
rt300@43 93
rt300@37 94 [super dealloc];
rt300@37 95 }
rt300@37 96 - (void)viewDidUnload {
rt300@37 97 [super viewDidUnload];
rt300@37 98 }
rt300@43 99 - (void)slider:(int)which changedTo:(float)value{
rt300@43 100 // call testApp
rt300@43 101 ((testApp *)self.theOFAppRef)->sliderMoved(which,value);
rt300@43 102 }
rt300@43 103 - (void)setSlider:(int)which to:(float)value{
rt300@43 104 [[self.sliderArray objectAtIndex:which] setParamValue:value];
rt300@43 105 }
rt300@43 106 - (void)populateParamNames{
rt300@43 107
rt300@45 108 /*
rt300@43 109 self.paramNames = [NSArray arrayWithObjects:
rt300@43 110 @"Transpose",@"1/4 note",@"1/6 note",@"1/7 note",@"1/8 note",
rt300@45 111 @"Waveform",@"Filter Type",@"Filter Cutoff",@"Envelope",@"FM freq",
rt300@43 112 nil];
rt300@45 113 */
rt300@45 114 self.paramNames = [NSArray arrayWithObjects:
rt300@46 115 @"Amp Env Shape",@"Waveform (Sin,Saw,Pulse)",@"FM amount",@"FM frequency",@"Reverb",
rt300@46 116 @"Filter Type (LP,BP,HP)",@"Filter Cut off",@"Filter Resonance",@"Filter Env Shape",@"Filt Env Amount",
rt300@45 117 nil];
rt300@43 118 }
rt300@36 119 @end