使用ObjectAl作为iOS音板应用。到目前为止工作得很好。如果我可以稍微调整延迟,那将是非常棒的。 现在我只是用OALSimpleAudio直接使用它。 任何人都知道我是否应该在OALSimpleAudio.m文件中调整参数以试图降低延迟?谢谢! 编程非常新,但玩得开心!
#import "BTM_soundView.h"
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#import "pandrum_appDelegate.h"
#import "ObjectAL.h"
@implementation BTM_soundView
- (id) init
{
if(nil != (self = [super init]))
{
// We don't want ipod music to keep playing since
// we have our own bg music.
[OALSimpleAudio sharedInstance].allowIpod = NO;
// Mute all audio if the silent switch is turned on.
[OALSimpleAudio sharedInstance].honorSilentSwitch = YES;
// This loads the sound effects into memory so that
// there's no delay when we tell it to play them.
[[OALSimpleAudio sharedInstance] preloadEffect:@"ding.caf"];
[[OALSimpleAudio sharedInstance] preloadEffect:@"templebell.caf"];
[[OALSimpleAudio sharedInstance] preloadEffect:@"snare.wav"];
[[OALSimpleAudio sharedInstance] preloadEffect:@"snare.caf"];
}
return self;
}
@synthesize viewController = _viewController;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
}
/*
// made .caf file in Terminal for each sound
afconvert -f caff -d LEI16 templebell.wav templebell.caf
*/
- (IBAction)SSound1{
[[OALSimpleAudio sharedInstance] playEffect:@"snare.wav"];
}
- (IBAction)SSound2{
[[OALSimpleAudio sharedInstance] playEffect:@"templebell.caf"];
}
- (IBAction)SSound3{
[[OALSimpleAudio sharedInstance] playEffect:@"ding.caf"];
}
- (IBAction)SSound4{
[[OALSimpleAudio sharedInstance] playEffect:@"snare.caf"];
}
@end