#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
*/
// must be wav or caff signed 16-bit little endian
- (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
Hi Ian,
What you have now will work fine. You're preloading the effects, so they'll play without any delay. Note that you don't necessarily have to convert your sounds to LEI16. That's the internal format used by OpenAL, but ObjectAL will auto convert any sound format supported by iOS. You won't incur any speed penalties when playing them.
--
You received this message because you are subscribed to the Google Groups "ObjectAL-for-iPhone" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectal-for-ip...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "ObjectAL-for-iPhone" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/objectal-for-iphone/cKuq7EsDlZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to objectal-for-ip...@googlegroups.com.
Yes, even mp3 is fine. The only limitation of mp3 is that looping doesn't always sound nice (this is a problem with the format itself). Aac doesn't have this problem.
You can preload anywhere you want, just so long as it happens before you start playing the sounds.
You received this message because you are subscribed to a topic in the Google Groups "ObjectAL-for-iPhone" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/objectal-for-iphone/cKuq7EsDlZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to objectal-for-ip...@googlegroups.com.
On Apr 29, 2015, at 5:37 PM, Karl Stenerud <kste...@gmail.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "ObjectAL-for-iPhone" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/objectal-for-iphone/cKuq7EsDlZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to objectal-for-ip...@googlegroups.com.
- (IBAction)D1{
int randomSoundNumber = arc4random() % 3; //random number from 0 to 2
NSLog(@"random sound number = %i", randomSoundNumber);
NSString *effectTitle;
switch (randomSoundNumber) {
case 0:
effectTitle = @"D1a";
break;
case 1:
effectTitle = @"D1b";
break;
case 2:
effectTitle = @"D1c";
break;
default:
NSLog (@"Integer out of range");
break;
}
NSString *soundPath = [[NSBundle mainBundle] pathForResource:effectTitle ofType:@"wav"];
[OALSimpleAudio sharedInstance].reservedSources = 0; // Leave sources in OALSimpleAudio so that we can use it for trivial sounds.
D1 = [[ALChannelSource alloc]initWithSources:3]; // Allow simultaneous sounds (sources) for drum.
D1a = [[OpenALManager sharedInstance] bufferFromFile:soundPath]; // Load the sound effect and keep a reference.
[D1 play:D1a loop:NO];
}
- (IBAction)A2 {
int randomSoundNumber = arc4random() % 3; //random number from 0 to 2
NSLog(@"random sound number = %i", randomSoundNumber);
NSString *effectTitle;
switch (randomSoundNumber) {
case 0:
effectTitle = @"A2a";
break;
case 1:
effectTitle = @"A2b";
break;
case 2:
effectTitle = @"A2c";
break;
default:
NSLog (@"Integer out of range");
break;
}
NSString *soundPath = [[NSBundle mainBundle] pathForResource:effectTitle ofType:@"wav"];
[OALSimpleAudio sharedInstance].reservedSources = 0; // Leave sources in OALSimpleAudio so that we can use it for trivial sounds.
A2 = [[ALChannelSource alloc]initWithSources:3]; // Allow simultaneous sounds (sources) for drum.
A2a = [[OpenALManager sharedInstance] bufferFromFile:soundPath]; // Load the sound effect and keep a reference.
[A2 play:A2a loop:NO];
Ian
To unsubscribe from this group and stop receiving emails from it, send an email to objectal-for-iphone+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "ObjectAL-for-iPhone" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/objectal-for-iphone/cKuq7EsDlZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to objectal-for-iphone+unsub...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "ObjectAL-for-iPhone" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectal-for-iphone+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to objectal-for-ip...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to objectal-for-ip...@googlegroups.com.