rt300@36: // rt300@36: // SliderViewController.m rt300@36: // sonicZoom rt300@36: // rt300@36: // Created by Robert Tubb on 01/02/2013. rt300@36: // rt300@36: // rt300@36: rt300@36: #import "SliderViewController.h" rt300@48: #include "testApp.h" rt300@36: rt300@36: @interface SliderViewController () rt300@36: rt300@36: @end rt300@36: rt300@36: @implementation SliderViewController rt300@36: rt300@45: rt300@45: // init with either sequencer or all timbre rt300@36: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil rt300@36: { rt300@36: self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; rt300@36: if (self) { rt300@36: // Custom initialization rt300@43: [self populateParamNames]; rt300@43: self.sliderArray = [[NSMutableArray alloc] init]; rt300@43: rt300@36: } rt300@36: return self; rt300@36: } rt300@36: rt300@36: - (void)viewDidLoad rt300@36: { rt300@43: int left = 22; rt300@44: int top = 10; rt300@44: const int height = 50; rt300@43: const int width = 337; rt300@43: rt300@36: [super viewDidLoad]; rt300@43: rt300@43: for(int i=0;i<10;i++){ rt300@43: rt300@43: if(i==5){ rt300@44: top = 10; rt300@43: left = left*3 + width; rt300@43: } rt300@43: SliderController * sliderV = [[SliderController alloc] initWithNibName:@"SliderController" bundle:nil delegate:self pID:i]; rt300@43: rt300@43: [self.view addSubview:sliderV.view]; rt300@43: rt300@43: sliderV.view.frame = CGRectMake(left,top,width,height); rt300@43: [sliderV setPID:i]; rt300@43: NSLog(@"setting name to %@", self.paramNames[i]); rt300@43: [sliderV changeLabel:self.paramNames[i] ]; rt300@43: [sliderV setParamValue:44]; rt300@44: if(i>=5){ rt300@44: [sliderV makeRed]; rt300@44: } rt300@43: top += height; rt300@43: rt300@43: [self.sliderArray addObject:sliderV]; // not working rt300@43: rt300@43: } rt300@43: int i = [self.sliderArray count]; rt300@43: NSLog(@"count: %d", i); rt300@43: rt300@43: [(SliderController *)[self.sliderArray objectAtIndex:5] setParamValue:13]; rt300@43: rt300@36: } rt300@36: rt300@36: - (void)didReceiveMemoryWarning rt300@36: { rt300@36: [super didReceiveMemoryWarning]; rt300@36: // Dispose of any resources that can be recreated. rt300@36: } rt300@36: rt300@36: - (void)setAppRef:(id)theOFApp{ rt300@36: self.theOFAppRef = theOFApp; rt300@36: rt300@36: } rt300@36: rt300@36: - (IBAction)show:(id)sender rt300@36: { rt300@36: self.theOFAppRef = sender; rt300@36: self.view.hidden = NO; rt300@36: } rt300@43: - (IBAction)hide:(id)sender rt300@43: { rt300@43: self.theOFAppRef = sender; rt300@43: self.view.hidden = YES; rt300@43: } rt300@37: - (void)dealloc { rt300@43: rt300@37: [super dealloc]; rt300@37: } rt300@37: - (void)viewDidUnload { rt300@37: [super viewDidUnload]; rt300@37: } rt300@43: - (void)slider:(int)which changedTo:(float)value{ rt300@43: // call testApp rt300@43: ((testApp *)self.theOFAppRef)->sliderMoved(which,value); rt300@43: } rt300@43: - (void)setSlider:(int)which to:(float)value{ rt300@43: [[self.sliderArray objectAtIndex:which] setParamValue:value]; rt300@43: } rt300@43: - (void)populateParamNames{ rt300@43: rt300@45: /* rt300@43: self.paramNames = [NSArray arrayWithObjects: rt300@43: @"Transpose",@"1/4 note",@"1/6 note",@"1/7 note",@"1/8 note", rt300@45: @"Waveform",@"Filter Type",@"Filter Cutoff",@"Envelope",@"FM freq", rt300@43: nil]; rt300@45: */ rt300@45: self.paramNames = [NSArray arrayWithObjects: rt300@46: @"Amp Env Shape",@"Waveform (Sin,Saw,Pulse)",@"FM amount",@"FM frequency",@"Reverb", rt300@46: @"Filter Type (LP,BP,HP)",@"Filter Cut off",@"Filter Resonance",@"Filter Env Shape",@"Filt Env Amount", rt300@45: nil]; rt300@43: } rt300@36: @end