Created
September 3, 2015 03:12
-
-
Save AlexanderBollbach/ae750d90234d75ee317b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)loadPresetWithKey:(NSString*)theKey { | |
AppDelegate* appDel = ((AppDelegate*)[UIApplication sharedApplication].delegate); | |
OrbitViewController* orbitViewController = (OrbitViewController*)appDel.containerViewController.frontViewController; | |
[orbitViewController.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; | |
[self.orbModelMaster.orbModels removeAllObjects]; | |
NSUserDefaults *myDefaults = [NSUserDefaults standardUserDefaults]; | |
NSMutableDictionary *presetDictionaryDecoded = [NSKeyedUnarchiver unarchiveObjectWithData:[myDefaults objectForKey:@"presetsDictionary"]]; | |
self.orbModelMaster.orbModels = [presetDictionaryDecoded objectForKey:theKey]; | |
for (OrbModel* orbModel in self.orbModelMaster.orbModels) { | |
OrbView* newOrbView = [[OrbView alloc] initWithFrame:CGRectMake(0,0,50,50) andName:orbModel.name]; | |
newOrbView.center = CGPointMake(orbModel.centerX,orbModel.centerY); | |
[orbitViewController.view addSubview:newOrbView]; | |
newOrbView.orbModelRef = orbModel; | |
NSString* hh = [[NSBundle mainBundle]pathForResource:@"Snare" ofType:@".wav"]; | |
AVAudioPlayer* aPlayer; | |
switch (orbModel.sampler) { | |
case kSamplerKick: | |
orbModel.player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:@"Kick.wav"] error:nil]; | |
break; | |
case kSamplerSnare: | |
orbModel.player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:@"Snare.wav"] error:nil]; | |
break; | |
case kSamplerHH: | |
aPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:hh] error:nil]; | |
orbModel.player = aPlayer; | |
break; | |
case kSamplerCowBell: | |
orbModel.player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:@"CowBell.wav"] error:nil]; | |
break; | |
default: | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment