AudioUnitRender result -10867 ============================= - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { [self configureAVAudioSession]; //additional stuff here [self initSoundBanks]; //additional stuff here [self initSampler]; } return self; } - (void) configureAVAudioSession { AudioStreamBasicDescription asbd = [AEAudioController nonInterleaved16BitStereoAudioDescription]; asbd.mSampleRate = 44100; //session.sampleRate; float size = 0.005f; self.audioController = [[AEAudioController alloc] initWithAudioDescription:asbd inputEnabled:NO]; _audioController.preferredBufferDuration = size; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioRouteChangeListenerCallback:) name:AVAudioSessionRouteChangeNotification object:nil]; [_audioController start:NULL]; [_audioController setMasterOutputVolume:0.95]; groupPemade = [_audioController createChannelGroup]; groupKantil = [_audioController createChannelGroup]; groupClick = [_audioController createChannelGroup]; audioOn = true; } - (void)initSoundBanks { soundBankPlayer[0] = [[SoundBankPlayer alloc] initWithAudioController:_audioController]; [soundBankPlayer[0] setSoundBank:@"Gender"]; soundBankPlayer[1] = [[SoundBankPlayer alloc] initWithAudioController:_audioController]; [soundBankPlayer[1] setSoundBank:@"Gender"]; soundBankPlayer[2] = [[SoundBankPlayer alloc] initWithAudioController:_audioController]; [soundBankPlayer[2] setSoundBank:@"Gender"]; soundBankPlayer[3] = [[SoundBankPlayer alloc] initWithAudioController:_audioController]; [soundBankPlayer[3] setSoundBank:@"Gender"]; soundBankPlayer[4] = [[SoundBankPlayer alloc] initWithAudioController:_audioController]; [soundBankPlayer[4] setSoundBank:@"Drums"]; audioOn = true; } - (void)initSampler{ [soundBankPlayer[0] initSampler:groupPemade]; [soundBankPlayer[1] initSampler:groupPemade]; [soundBankPlayer[2] initSampler:groupKantil]; [soundBankPlayer[3] initSampler:groupKantil]; [soundBankPlayer[4] initSampler:groupClick]; [_audioController setVolume:0.95 forChannelGroup:groupPemade]; [_audioController setVolume:0.85 forChannelGroup:groupKantil]; [_audioController setVolume:1.0 forChannelGroup:groupClick]; [soundBankPlayer[0] setPan:-0.4]; [soundBankPlayer[1] setPan:0.4]; [soundBankPlayer[2] setPan:-0.4]; [soundBankPlayer[3] setPan:0.4]; } Class SoundBankPlayer ===================== - (id)initWithAudioController:(AEAudioController *)audioController { if ((self = [super init])) { _audioController = audioController; _initialized = NO; _soundBankName = @""; } return self; } - (void)setSoundBank:(NSString *)newSoundBankName { if (![newSoundBankName isEqualToString:_soundBankName]) { _soundBankName = [newSoundBankName copy]; [self loadAUPreset:_soundBankName]; } } - (void)loadAUPreset:(NSString *)filename { NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:@"aupreset"]; _aupreset = [NSMutableDictionary dictionaryWithContentsOfFile:path]; } - (void)initSampler:(AEChannelGroupRef)group { AudioComponentDescription component = AEAudioComponentDescriptionMake(kAudioUnitManufacturer_Apple, kAudioUnitType_MusicDevice, kAudioUnitSubType_Sampler); // NSError *error = NULL; _sampler = [[AEAudioUnitChannel alloc] initWithComponentDescription:component // audioController:_audioController preInitializeBlock:^(AudioUnit samplerUnit){ // Get the type of reference we need (NSDictionary is a CFPropertyList) CFPropertyListRef presetPropertyList = (__bridge CFPropertyListRef)(_aupreset); // Set the class info property for the Sampler unit using the property list as the value. AudioUnitSetProperty(samplerUnit, kAudioUnitProperty_ClassInfo, kAudioUnitScope_Global, 0, &presetPropertyList, sizeof(CFPropertyListRef) ); // should rightly be checking for an error here... took it out for demo } // error:&error ]; if (_sampler) { [_audioController addChannels:@[_sampler]]; [_audioController addChannels:@[_sampler] toChannelGroup:group]; } _initialized = YES; }