GithubHelp home page GithubHelp logo

kstenerud / objectal-for-iphone Goto Github PK

View Code? Open in Web Editor NEW
886.0 47.0 171.0 12.65 MB

Mac and iOS Audio development, minus the headache. ObjectAL is the easy Objective-C interface to OpenAL, AVAudioPlayer, and audio session management.

Home Page: http://kstenerud.github.com/ObjectAL-for-iPhone

Ruby 0.40% Objective-C 97.69% C 1.35% Shell 0.56%

objectal-for-iphone's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

objectal-for-iphone's Issues

Feature request OALSimpleAudio

I would like a flag that blocks multiple instances of a one shot from playing.

Example: I have an image that plays a sound when a user touches image. I want it to not play that sound again until it has completed playing. Currently i can trigger that sound as many times as there are channels. Globally setting it in my case would be acceptable as no sounds should overlap when played.

Documentation Section 1.4 refers to old/incorrect folder location.

In Section 1.4 of the documentation, we are instructed to copy the directory "libs/ObjectAL" into our project.

There is no such directory; and there are two directories named ObjectAL, namely "ObjectAL" and "ObjectAL/ObjectAL" -- thus it's pretty confusing for newbies.

Thanks for all the work on this by the way, I look forward to using it.

[OALSimpleAudio bgPlaying] not working

Calling [[OALSimpleAudio sharedInstance] bgPlaying] returns FALSE even when there is background music playing.

I wrote a category to OALSimpleAudio to only trigger the play action when the speficied background music file is not already playing but since bgPlaying returns FALSE even when the background music is actually playing, the code below simply does not work.

@implementation OALSimpleAudio (Additions)

- (void)playBgIfNotAlreadyPlaying:(NSString *)fileName loop:(BOOL)loop {
    if (![self isPlayingBgNamed:fileName]) {
        [self stopBg];
        [self playBg:fileName loop:loop];
    }
}

- (BOOL)isPlayingBgNamed:(NSString *)fileName {
    if ([self bgPlaying]) {
        if ([[[[self backgroundTrackURL] absoluteString] lastPathComponent] isEqualToString:fileName]) {
            return YES;
        } else {
            return NO;
        }
    } else {
        return NO;
    }
}

@end

[source setPosition:alpoint(float, float, float)] cannot work when reverb is "Yes"

Hello everybody.

I am going to create new Wadaiko (Japanese drum) app on iPhone 5.
I have problem that when "[OpenALManager sharedInstance].currentContext.listener.reverbOn" is YES,
"[source setPosition:alpoint(float, float, float)]" cannot work.

I confirmed that when "[OpenALManager sharedInstance].currentContext.listener.reverbOn" is NO,
"[source setPosition:alpoint(float, float, float)]" can work.
I think "Reverb" object have some problems, but I cannot
find the point of these on all souces.

If you have method to solve these problem, please let me know.

Starting iPod Playback Shuts Down Audio

  1. Start the demo app
  2. pick 1 or 2 source demo
  3. double tap home to bring up the springboard/ipod menu
  4. Start a song

Result: Audio in game fades out. iPod starts playing. Sounds do not return.

Note that if you are playing iPod when you enter the app then these repro steps fail.

Using the latest build from GIT

Audio doesn't resume if I switch applications by double-clicking the home button.

Hi,

On iOS 6, when I use application switching by double-clicking the home button, sound doesn't resume:

  1. Install ObjectALDemo.
  2. Change the bundle ID com.yourcompany2. to install another ObjectALDemo.
  3. Kill all instances of ObjectALDemo.
  4. Open 1st OpenALDemo and choose "Single Source (Positioning)"
  5. Press home button.
  6. Open 2nd OpenALDemo and choose "Crossfade".
  7. Double-click home button and switch to 1st.
  8. Double-click home button and switch to 2nd.

After these steps, sound doesn't continue to play. It seems OALAudioSession receives beginInterruption but doesn't receive endInterruptionWithFlags: therefore OpenAL remains uninitialized.

I've tested this on iOS 6.0.1 and 6.1.2. Both iOS versions don't behave exactly same but same problem occurs.

Thank you.

Stop the music currently playing on iOS 7

At launch, app must not stop the music currently playing.

It work well on iOS 6 but on iOS 7.
The first time a method is invoke with singleton the music is stopped.

"Error installing cocos2d"

"Error installing cocos2d" when we go for pod install. while compiling ObjectAL-for-iPhone
you can see attached image.
We are getting following image.
screen shot 2014-10-29 at 4 40 38 pm

Problems compiling Demo project - Xcode 4.2 - Cocos2d

Hi, as you can imagine with the title I'm not an expert at all, and i'm struggling to get the Demo project to compile with Lion/Xcode4.2, the original cocos2D that came with the project won't run and trying to update cocos2d to 1.0.1 version brings new problems i suppose because the API changes in that version... there is any project with the new version that i can try?

Tnx in advance for you help and time

Erick

Pitch shifting question

I've tested your demo. It's amazing. But I have a question about the pitch shifting. When I change the pitch higher, the player speed is faster and when I change it lower, the player speed is slower. Why like this? Can I change the pitch (tone) without change the speed of the play?

Another question is, is your library supporting audio streaming?

Thanks

Build errors with Xcode 4.2

Just downloaded the latest Xcode 4.2 and iOS release. Now getting build errors on all SYNTHESIZE_SINGLETON_FOR_CLASS statements like this one:

SYNTHESIZE_SINGLETON_FOR_CLASS(OALActionManager);

The LLVM compiler 3.0 reports:

Returning 'volatile OALActionManager *' from a function with result type 'OALActionManager *' discards qualifiers

Any ideas how to quiet these compiler warnings, Karl? Thanks in advance!

Cannot build on 10.6.8 with Xcode 4.2 - 2 errors

Both errors in OALAudioSession.m:: handleInterruption: method:

  1. Sematic Issue: Use of undeclared identifier 'AVAudioSessionInterruptionTypeBegan on line 642

  2. Sematic Issue: Use of undeclared identifier 'AVAudioSessionInterruptionTypeEnded on line 645

These errors occur even when building with iOS 6 SDK.

Build errors with Xcode 4.1

I'm trying to build my iOS 4 project, and getting several build errors when using including either the bleeding edge or 2.0 versions of ObjectAL. Here are the Xcode build errors:

OALFunction.m - lines 39, 68, 98, 128 (the SYNTHESIZE_SINGLETON_FOR_CLASS statements). Xcode error is "Conflicting distributed object modifers on return type in implementation of 'release'".

OALActionManager.m - line 56, same error code.

OpenALManager.m - line 156, same error code.

OALAudioSession.m - line 107, same error code.

IOSVersion.m - line 17, same error code.

OALAudioTracks.m - line 61, same error code.

OALSimpleAudio.m - line 67, same error code.

infinite loop while loading file

well i dont know too much about all this stuff but i was getting an infinite loop while loading some audio files (most of them was working ok). so traced it and find out that when ExtAudioFileRead(fileHandle, &numFramesRead, &bufferList) returns in numFramesRead 0 it indicates that end-of-file was reached. so ive added a simple break for it and it seems to be working for me, i just wanted to share it and get an opinion about it
here's the whole method

  • (void_) audioDataWithStartFrame:(SInt64) startFrame
    numFrames:(SInt64) numFrames
    bufferSize:(UInt32_) bufferSize
    {
    @synchronized(self)
    {
    if(nil == fileHandle)
    {
    OAL_LOG_ERROR(@"Attempted to read from closed file. Returning nil (url = %@)", url);
    return nil;
    }

    OSStatus error;
    UInt32 numFramesRead;
    AudioBufferList bufferList;
    UInt32 bufferOffset = 0;
    
    
    // < 0 means read to the end of the file.
    if(numFrames < 0)
    {
        numFrames = totalFrames - startFrame;
    }
    
    // Allocate some memory to hold the data
    UInt32 streamSizeInBytes = (UInt32)(streamDescription.mBytesPerFrame * numFrames);
    void* streamData = malloc(streamSizeInBytes);
    if(nil == streamData)
    {
        OAL_LOG_ERROR(@"Could not allocate %d bytes for audio buffer from file (url = %@)",
                      streamSizeInBytes,
                      url);
        goto onFail;
    }
    
    if(noErr != (error = ExtAudioFileSeek(fileHandle, startFrame)))
    {
        REPORT_EXTAUDIO_CALL(error, @"Could not seek to %ll in file (url = %@)",
                             startFrame,
                             url);
        goto onFail;
    }
    
    
    bufferList.mNumberBuffers = 1;
    bufferList.mBuffers[0].mNumberChannels = streamDescription.mChannelsPerFrame;
    for(UInt32 framesToRead = (UInt32) numFrames; framesToRead > 0; framesToRead -= numFramesRead)
    {
        bufferList.mBuffers[0].mDataByteSize = streamDescription.mBytesPerFrame * framesToRead;
        bufferList.mBuffers[0].mData = streamData + bufferOffset;
    
        numFramesRead = framesToRead;
        if(noErr != (error = ExtAudioFileRead(fileHandle, &numFramesRead, &bufferList)))
        {
            REPORT_EXTAUDIO_CALL(error, @"Could not read audio data in file (url = %@)",
                                 url);
            goto onFail;
        }
        if (numFramesRead == 0)
            break;
    
        bufferOffset += streamDescription.mBytesPerFrame * numFramesRead;
    }
    
    if(nil != bufferSize)
    {
        *bufferSize = streamSizeInBytes;
    }
    
    return streamData;
    

    onFail:
    if(nil != streamData)
    {
    free(streamData);
    }
    return nil;
    }
    }

OALAudioTrack::playFile:loops - How to have a delay between each loop ?

I'm using OALAudioTrack::playFile:loops to loop a sound and would like to add a delay before each loop.

As there doesn't appear to be a built-in way to specify a delay, I thought about running playFile on a separate thread (using dispatch_async), and just looping the required number of times, using [NSThread sleepForTimeInterval:ti] for the delay.

This seems to work fine, but I'm wondering if there are any other subtle (multi-threading) issues I may be missing ?

ducking doesn't work (iOS6)

No matter what I've tried, I can't get ducking to work.

Problem can be reproduced using your Session demo.

  1. Open music player on phone/ipod, start playing a song
  2. Open your demo app, go to the session demo, select ducking, play any of the sounds.. No ducking happens. It's a simple mix, which isn't ducking (but it is mixing)

I'm now back to standard-ole AVAudioPlayer, with all of its latency, for now :(

Object AL Crashes in Background Thread

My Game only uses two sounds so what I do is load them Asyncnoulsy whilst the app launches so that they are ready to play however this seems to crash occasionally.

Here is the code it is in the applicationDidLaunch App Delegate Method

//Add onto queue to excute asyncrously
dispatch_group_async(myGroup, myQueue, ^{
    //Load Sounds
    DLog(@"Loading Sounds...");

    // Kick off audio initialization before our main scene begins.
    // Note: This default init will cause OALSimpleAudio to take all 32 sources.
    [OALSimpleAudio sharedInstance];

    //Get Sound Manager Instance
    SoundManager *soundManager = [SoundManager sharedInstance];

    //Load, Set Up and Store Theme Music
    OALAudioTrack *themeMusic = [soundManager audioTrackNamed:GTDThemeMusicFileName];
    themeMusic.numberOfLoops = -1;
    [soundManager setAudioTrack:themeMusic ForKey:@"Theme"];

    //Load, Set Up and Store Countdown Music
    OALAudioTrack *countdownSound = [soundManager audioTrackNamed:GTDCountdownSoundFileName];
    [soundManager setAudioTrack:countdownSound ForKey:@"Countdown"];  

    //Mute if  enable sound setting is set to disabled
    bool soundEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableSound"];
    [OALAudioTracks sharedInstance].muted = (!soundEnabled);

    DLog(@"Finished Loading Sounds");
});

The Crash occurs on the following line:

OALAudioTrack *themeMusic = [soundManager audioTrackNamed:GTDThemeMusicFileName];

Sometimes it doesn't crash and is able to load fine.

Analyse issue

There is 1 analyze issue in Xcode 4.6.1:

ObjectAL/OpenAL/ALBuffer.m:169:2: Access to instance variable 'parentBuffer' results in a dereference of a null pointer (loaded from variable 'slice')
  • Xcode 4.6.1
  • Deployment target iOS 6.0

OALSimpleAudio playEffect does not work if you play multiple sounds with an interval of 20 or 40 millis

I have tested the latest library (2011-11-26) on iPad, iPhone 3G, 3GS, 4, 4S with iOS v3.0.x, v4.0.x, v4.3, v5.0.0, v5.0.1
It worked perfectly on all devices. Congratulations for the great job done! I have also an iPad 2 but not yet tried it on this one.

BUG: if the game plays many effects quickly, the audio output shutdowns and only small cracks can be heard until a call to stopAllEffects is made to "reset" the internal state.

  • App built using Xcode v4.2 Build 4C199 using Arch=armv6, BaseSDK=iOS 5.0, DeploymentTarget=3.0, Compiler=LLVM GCC 4.2, build:Debug.
  • App runs at 50 FPS (updated each 20 millis).
  • All the sound effects have been converted to CAF using afconvert -f caff -d LEI16@44100.
  • All the sounds are preloaded.
  • There is no background music playing.

Here is an example of playback sequence that will ALWAYS break on all devices (even 4 and 4S) before it even arrives in the middle. (loopCount, priority and volume can be ignored).

  • Am I doing something wrong by playing again the same effect before it's stopped?
  • Should the code be called from a special thread like the main thread?

playEffect index:1, sound:Sound resourceId:1046, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1029, loopCount:1, priority:1, volume:100
update count:816
...
update count:840
playEffect index:2, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
update count:841
...
update count:847
playEffect index:2, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
update count:848
playEffect index:2, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
update count:849
update count:850
update count:851
playEffect index:1, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
update count:852
update count:853
playEffect index:1, sound:Sound resourceId:1026, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:854
update count:855
update count:856
playEffect index:1, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
update count:857
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:858
update count:859
playEffect index:2, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
update count:860
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:861
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:862
update count:863
playEffect index:2, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
update count:864
update count:865
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:866
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:867
update count:868
playEffect index:2, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
update count:869
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:870
Vibrate: 500
playEffect index:2, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
update count:871
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:872
update count:873
playEffect index:2, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
update count:874
update count:875
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:876
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:877
update count:878
playEffect index:2, sound:Sound resourceId:1028, loopCount:1, priority:1, volume:100
playEffect index:1, sound:Sound resourceId:1032, loopCount:1, priority:1, volume:100
playEffect index:0, sound:Sound resourceId:1031, loopCount:1, priority:1, volume:100
update count:879
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:880
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:881
update count:882
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:883
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:884
update count:885
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:886
update count:887
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:888
update count:889
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:890
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:891
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:892
update count:893
update count:894
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:895
update count:896
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:897
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100
update count:898
update count:899
playEffect index:0, sound:Sound resourceId:1052, loopCount:1, priority:1, volume:100

sounds are not released from memory

hey ive noticed that every sound file loaded into memory (im using playEffect without preloading it first) is never being released from memory...
even worse when im using [[OALSimpleAudio sharedInstance] unloadAllEffects]; then sound is removed from preloadCache so the next time it is again loaded into memory (so in fact in the memory one file might be loaded more than once)

for my app this is a big problem, lots of sounds might cause crashes because of memory overflow

where those albuffer objects are retained beside from preloadCache?

when i did something like this in internalPreloadEffect method

[preloadCache setObject:buffer forKey:filePath];
arcsafe_release(buffer); << this is new

and than

[[OALSimpleAudio sharedInstance] stopEverything]; (without this if a sound is being played it crashes when releasing from memory)
[[OALSimpleAudio sharedInstance] unloadAllEffects];

i can really release then from memory

am i doing something wrong or is it a bug?
i was testing it on iPad 1 with iOS 5.0 onboard

interruptions handled properly?

Not sure if this is an issue; really this is more of a question. I noticed that in OALAudioSession.m, there is no special code to handle interruptions ending with the flag 'AVAudioSessionInterruptionFlags_ShouldResume'. According to the docs:

"To resume using audio after an interruption ends, you must ensure that your audio session is active. AVAudioPlayer and AVAudioRecorder instances reactivate your audio session automatically when an interruption ends. If you are using another audio technology, such as OpenAL, audio units, or audio queues, you must reactivate your audio session yourself before you can again use audio.

You can also use this method to update the user interface and application state, as necessary.

If this delegate method receives the AVAudioSessionInterruptionFlags_ShouldResume constant in its flags parameter, the audio session is immediately ready to be used.

If you implement this method, it is called instead of the endInterruption method when an interruption ends."

I don't see any special case handling to see if this flag was passed which then reactivates the session as necessary. Maybe I"m just missing it? Or is this left up to the delegate??

Bad exec crash on audioPlayerDidFinishPlaying

Hey for some reason my app is crashing in - (void) audioPlayerDidFinishPlaying:(AVAudioPlayer*) playerIn successfully:(BOOL) flag

Specifically when it's trying to post the notification. If I uncomment this things works fine. I'm only using two OALAudioTrack so nothing fancy... Any ideas.

This is where it crashes.

[[NSNotificationCenter defaultCenter] performSelectorOnMainThread:@selector(postNotification:) withObject:[NSNotification notificationWithName:OALAudioTrackFinishedPlayingNotification object:self] waitUntilDone:NO];

allowIpod doesn't work

I've set allowIpod=YES and useHardwareIfAvailable=NO. I'm using only -[OALSimpleAudio playEffect]. However, I can't start iPod playback (by using the task switcher, not activating the iPad app) while the app is running.

When I start or resume the app while iPod is already playing, it mixes my sound effects as expected. However, when I stop iPod playing, then suspend and resume the app, iPod playing is disabled again.

compiler complies about mixed synthesized and user defined properties

I currently play around with your library and got a few warnings:

 @synthesize allowIpod;

 - (void) setAllowIpod:(bool) value
 {
    allowIpod = value;
    [self updateAudioMode];
 }

The generated warning is:

warning: writable atomic property 'allowIpod' cannot pair a synthesized setter/getter with a user defined setter/getter [2]

I think you have to declare the properties nonatomic if you want to override the getter or the setter.

http://lists.apple.com/archives/xcode-users/2010/Jun/msg00190.html

ObjectALConfig.h naming inconsistency of config macros

In ObjectALConfig.h OBJECTAL_CFG_USE_BLOCKS is defined to enable blocks support.

But for example in OALSimpleAudio.h the #ifdef uses OBJECTAL_USE_BLOCKS without the CFG part. Therefore the blocks function remain unavailable.

The same problem exists for OBJECTAL_CFG_USE_COCOS2D_ACTIONS and OBJECTAL_USE_COCOS2D_ACTIONS. The other config macros are correct.

Tested with ObjectAL 2.1 download from website.

audio mixing

in OALAudioSession:setAudioMode, there are lines:

    // If the hardware is available and we want it, take it.
    if(mixing && useHardwareIfAvailable && !self.ipodPlaying)
    {
        mixing = NO;
    }

What is the reason to check status of ipdPlaying with useHardwareIfAvailable?

With this condition the current behavior is:
play external audio ⇛ play OAL audio : mixing YES
play OAL audio ⇛ play external audio : mixing NO
I think the behavior confuses end users.

Latency/Overhead of OALAudioTrack::playFileAsync compared to playFile and overhead of OALSimpleAudio ?

I need to play one or two samples at a time along with background music. I'm using iPod for background music and want to use Object-AL for the samples/effects, and have a few questions:

  1. When using playFileAsync instead of playFile, what are latency differences between the two (ie. from when the call is made to when the sound is heard), and is there higher CPU/RAM usage for either method ?

  2. I have a need for low'ish latency short sound sample playback, but also need to be able to loop some samples completely a specific number of times. As OALSimpleAudio doesn't support looping a specific number of times, I have tried OALAudioTrack::playFile:loops which works perfectly.

I'm wondering whether it would be better to just use OALAudioTrack for all my playback needs (most of my samples are LPCM uncompressed and seem to play with low enough latency WITHOUT preloading - ie. streaming), or use both OALAudioTrack (for looping) and OALSimpleAudio (for other samples) ?

How much extra overhead (RAM/CPU) is incurred from using both, compared to just using OALAudioTrack for everything ?

Thanks for this great library and open-sourcing it!

Latest build does not fade tracks

[track fadeTo:0.0 duration:0.4 target:nil selector:nil];

Only works when running a 4G. Otherwise all other devices do not fade as requested.

Delegate Complain in iOS6

First of all, I have to say Thank you very much!!!!! Great Framework.

I'm getting complain from OALAudioSession.m . Where [(AVAudioSession*)[AVAudioSession sharedInstance] setDelegate:self]; complains 'setDelegate:' is deprecated

The solution is quite easy. Just simply delete the (AVAudioSession*). I don't know how to apply a push request. So I open this issue here.

Thanks again!

AudioSessionProperty deprecated - warnings in iOS 7

AudioSessionProperty is deprecated in favor of AVAudioSession properties. Building ObjectAL with iOS 7 will bring up corresponding deprecated warnings (about 5) in OALAudioSession, first couple methods under the "Internal Use" pragma mark.

See dev forum thread: https://devforums.apple.com/message/859752#859752

I just disabled deprecated warnings for now:

pragma clang diagnostic push

pragma clang diagnostic ignored "-Wdeprecated-declarations"

// ...

pragma clang diagnostic pop // deprecated warning

Sound sometimes stop playing after app is backgrounded

We have been struggling with an issue where sometimes all the sounds stop working after an app returns from background.

When the app is backgrounded, we stop the audio session:

        [self.simpleAudio stopEverything];
        [[OALAudioSession sharedInstance] setAudioSessionActive:NO];

and resume it when the app returns to the foreground:

        [[OALAudioSession sharedInstance] setAudioSessionActive:YES];

We also prevent sound from playing in the background:

    UIApplicationState appState = [[UIApplication sharedApplication] applicationState];
    if (appState == UIApplicationStateActive) ...

But, whenever we collect the logs from a device which stops playing we see this:

Sub_AudioSessionSetActiveWithFlags: WARNING translating CMSession error: -16980
OAL Error: -[OALAudioSession activateAudioSession]: Could not activate audio session after 40 tries: Error Domain=NSOSStatusErrorDomain Code=561015905 "The operation couldn’t be completed. (OSStatus error 561015905.)"

OAL Error: +[ALWrapper openDevice:]: Could not open device (null)
OAL Error: -[ALDevice initWithDeviceSpecifier:]: <ALDevice: 0x1450d080>: Failed to create OpenAL device (null)
OAL Error: +[ALWrapper closeDevice:]: Invalid Value (error code 0x0000a004)
OAL Warning: -[OALAudioSession onAudioError:]: Received audio error notification. Resetting audio session.
OAL Error: -[OALSimpleAudio initWithSources:]: <OALSimpleAudio: 0x14547030>: Could not create OpenAL device
AudioSessionSetClientPlayState: WARNING translating CMSession error: -16980
ERROR:     [0x3ce9418c] >aurioc> 783: failed: '!pla' (enable 2, outf< 2 ch,  44100 Hz, Float32, non-inter> inf< 2 ch,      0 Hz, Float32, non-inter>)

During these failures, playEffect returns nil. We added logic to reset the session by setting it inactive, then active again after 100ms, but sounds still fail. The only way to get out of this state is to restart the app.

Is there any best practices for gracefully handling background transitions? Any other information I can provide to better help source the issue?

Also found this in logs, I suspect the disabling of the audio session is failing while sound is playing

OAL Error: -[OALAudioSession setAudioSessionActive:]: Could not deactivate audio session: Error Domain=NSOSStatusErrorDomain Code=560030580 "The operation couldn’t be completed. (OSStatus error 560030580.)"

Pitch action: pitch range is incorrect when reverse function is used

[musicChannel pitchTo:0.6f duration:3.0f target:self selector:@selector(clockMusicPitchDownEnded)];

This should pitch from 1.0f (the current pitch value) to 0.6f. I noticed that the music started playing faster when the pitch began, so I investigated. It turns out that the setPitch property setter's first value received is not 1.0f but 1.4f. So the actual pitch range goes from 1.4f to 1.0f, not from 1.0f to 0.6f.

The issue does not exist if you pitch back up. Ie this works as expected:

musicChannel.pitch = 0.6f
[musicChannel pitchTo:1.0f duration:3.0f target:nil selector:nil];

The issue exists whether Cocos2D or ObjectAL actions are used.
I'm not on the latest version but one from earlier this year, possibly January/February 2012. Definitely the ARC-enabled version.

Observations:

  • (void) updateCompletion:(float) proportionComplete
    {
    [(id<OAL_PitchProtocol>)target_ setPitch:startValue + [realFunction valueForInput:proportionComplete] * delta];
    }

startValue = 1.0
realFunction returns 1.0 (1.0 minus inputValue, inputValue is 0)
delta is 0.4
This sets the pitch to: 1.0 + 1.0 * 0.4 = 1.4
To be correct (at least for the first call) the realFunction valueForInput should have returned 0 and subsequent calls should return values slightly lower, ie -0.04f.

I believe that adding startValue is incorrect if the reverse function is used (or the reverse function returns incorrect values). The calculation would be correct if startValue were endValue (0.6) or if the reverse function returned values in the range 0.0f to -1.0f. Currently it returns values in the range 1.0f to 0.0f.

After I analyzed this, I found a solution that works for me. Instead of returning 1.0f - inputValue, the reverse function now simply returns the negated inputValue:

  • (float) valueForInput:(float) inputValue
    {
    return [function valueForInput:-inputValue];
    }

Crash on preloading sound files in iOS 7 simulator

Hi!
I had a crash on iOS 7 simulator, when I try to preload sound file. It's not depend of what kind I try to preload, background or effect sounds. On iOS 6 simulator and device with iOS 7 app works correctly.
Crash happensin init method when I want to take singleton of OALSimpleAudio :

- (id) init
{
    return [self initWithSources:kDefaultReservedSources];
}

If we look deeper, we can see in class ALWrapper, when we call method:

+ (ALCdevice*) openDevice:(NSString*) deviceName
{
    ALCdevice* device;
    @synchronized(self)
    {
        device = alcOpenDevice([deviceName UTF8String]);
        if(NULL == device)
        {
            OAL_LOG_ERROR(@"Could not open device %@", deviceName);
        }
    }
    return device;
}

deviceName is NULL.

Can anyone give me an answer how i can solve this problem?

Thanks.

Audio Tracks Demo + interruptions

Tested using Audio Tracks Demo with the latest build off GIT:

  1. Start playing all tracks
  2. Set alarm to go off in one minute
  3. Alarm goes off while listening to groovy music
  4. Clearing alarm... only one audio track continues to play (sfx track continues to play)

Also, there seems to be another related issue w/the demo:

  1. Start playing both audio tracks
  2. turn one off and turn back on
  3. Only one audio track will now play at a time. Must exit demo.

Audio does not resume after it has been suspended by iOS (iPhone 5s & iOS 7.1)

Environment: iOS 7.1, iPhone 5s

Based on the OALAudioTrack sample code and using either the bleeding edge or 2.2 version for iOS, audio output does not resume after audio is interrupted by either Siri, dictation (via keyboard), phone call, or alarm. I have also tried the last commit changes on OALAudioTrack.m which does not resolve this problem.

Reproducibility: 100% on iPhone 5s with iOS 7.1

Other environments tested:

  • iPhone 5 and iOS 7.0.2 - Not reproducible
  • iPhone 4s and iOS 7.0.4 - Not reproducible
  • iPhone 4s and iOS 7.1 - Not reproducible

The only output in the console window is as follows:
2014-04-21 21:11:13.684 {App Name Omitted}[8559:60b] !!! _NSLayoutTreeGetBaselineOffsetForGlyphAtIndex invalid glyph index 0

Note: Using OALSimpleAudio sample code generates an exception.

Let me know if I need to provide any additional information to help. Thanks.

Loading sounds from memory, not disk

I have a group of sounds (.caf files) that are already in memory and I'd like ObjectAL to play them, but not load them from disk, rather get the data from a pointer I pass.

Is this possible? I looked though the code, and it seems non-trivial, unless I'm missing something obvious.

Access violation in OALSource::DoRender(AudioBufferList*, unsigned long)

I'm regularly seeing crashes (from users) with this signature:

Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0x60521472
13 com.apple.root.default-overcommit-priority Crashed
0    libsystem_platform.dylib    _platform_memmove$VARIANT$Swift + 37
1    OpenAL      OALSource::DoRender(AudioBufferList*, unsigned long) + 2112
2    OpenAL  OALSource::SourceInputProc(void*, unsigned long*, AudioTimeStamp const*, unsigned long, unsigned long, AudioBufferList*) + 28
3    AudioToolbox    AU3DMixerEmbeddedInputElement::PullSharedInput(unsigned long, unsigned long&, AudioTimeStamp const&, unsigned long) + 156
4    AudioToolbox    AU3DMixerEmbedded::Render(unsigned long&, AudioTimeStamp const&, unsigned long) + 1438
5    AudioToolbox    AUBase::DoRenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, AUOutputElement*, unsigned long, AudioBufferList&) + 150
6    AudioToolbox    AUBase::DoRender(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long, AudioBufferList&) + 532
7    AudioToolbox    AUMethodRender(void*, unsigned long*, AudioTimeStamp const*, unsigned long, unsigned long, AudioBufferList*) + 46
8    AudioToolbox    AUInputElement::PullInput(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long) + 102
9    AudioToolbox    AUInputFormatConverter2::InputProc(OpaqueAudioConverter*, unsigned long*, AudioBufferList*, AudioStreamPacketDescription**, void*) + 212
10   AudioToolbox    AudioConverterChain::CallInputProc(unsigned long) + 328
11   AudioToolbox    AudioConverterChain::FillBufferFromInputProc(unsigned long*, CABufferList*) + 92
12   AudioToolbox    BufferedAudioConverter::GetInputBytes(unsigned long, unsigned long&, CABufferList const*&) + 114
13   AudioToolbox    Resampler2Wrapper::RenderOutput(CABufferList*, unsigned long, unsigned long&) + 128
14   AudioToolbox    BufferedAudioConverter::FillBuffer(unsigned long&, AudioBufferList&, AudioStreamPacketDescription*) + 296
15   AudioToolbox    AudioConverterChain::RenderOutput(CABufferList*, unsigned long, unsigned long&, AudioStreamPacketDescription*) + 92
16   AudioToolbox    BufferedAudioConverter::FillBuffer(unsigned long&, AudioBufferList&, AudioStreamPacketDescription*) + 296
17   AudioToolbox    AudioConverterFillComplexBuffer + 356
18   AudioToolbox    AUInputFormatConverter2::PullAndConvertInput(AudioTimeStamp const&, unsigned long&, AudioBufferList&, AudioStreamPacketDescription*, bool&) + 100
19   AudioToolbox    AUConverterBase::RenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long) + 216
20   AudioToolbox    AURemoteIO::RenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long) + 50
21   AudioToolbox    AUBase::DoRenderBus(unsigned long&, AudioTimeStamp const&, unsigned long, AUOutputElement*, unsigned long, AudioBufferList&) + 150
22   AudioToolbox    AUBase::DoRender(unsigned long&, AudioTimeStamp const&, unsigned long, unsigned long, AudioBufferList&) + 532
23   AudioToolbox    AURemoteIO::PerformIO(unsigned long, unsigned int, unsigned int, AudioTimeStamp const&, AudioTimeStamp const&, AudioBufferList const*, AudioBufferList*, int&) + 630
24   AudioToolbox    AURIOCallbackReceiver_PerformIO + 372
25   AudioToolbox    _XPerformIO + 178
26   AudioToolbox    mshMIGPerform + 124
27   AudioToolbox    MSHMIGDispatchMessage + 32
28   AudioToolbox    AURemoteIO::IOThread::Run() + 186
29   AudioToolbox    AURemoteIO::IOThread::Entry(void*) + 8
30   AudioToolbox    CAPThread::Entry(CAPThread*) + 210
31   libsystem_pthread.dylib     _pthread_body + 140
32   libsystem_pthread.dylib     _pthread_start + 102

I have zero ideas about what to do with it. It is also mentioned in the Developer Forums: https://devforums.apple.com/message/849099#849099

[ALDevice deviceWithDeviceSpecifier:nil] returns nil in iOS7?

I have a bunch of crash reports from that indicates that [ALDevice deviceWithDeviceSpecifier:nil] may return nil in some cases. All the crashes (45 reports) come from iOS 7 users, using both iPhones and iPads of various kinds.

From what I can gather, the crash is caused by a nil device, which in turn causes a nil context, which causes nil to be inserted into an array in [ALSoundSourcePool addSource:].

Does anyone else see nil devices being returned from iOS 7? I have tried to reproduce this myself, without luck, so it doesn't happen in all circumstances.

This is the stack trace leading to the crash:

Fatal Exception NSInvalidArgumentException
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
0    CoreFoundation  __exceptionPreprocess + 130
1    libobjc.A.dylib     objc_exception_throw + 38
2    CoreFoundation  CFStringConvertNSStringEncodingToEncoding
3    MyApp   -[ALSoundSourcePool addSource:]
4    MyApp   -[ALChannelSource addSource:]
5    MyApp   -[ALChannelSource initWithSources:]
6    MyApp   MultipleBufferChannelSource.m line 18
         -[MultipleBufferChannelSource initWithSources:]
7    MyApp   +[ALChannelSource channelWithSources:]
8    MyApp   AudioManager.m line 65
         -[AudioManager init]
9    MyApp   AudioManager.m line 42
         __30+[AudioManager sharedInstance]_block_invoke

Crash when setting self.currentTIme

OALAudioTrack.m:799 self.currentTime = 0 will result in a crash.

Steps to reproduce:

  1. Begin playing OALAudioTrack(s)
  2. Clear track(s)
  3. crash
 if(player)
      player.currentTime = currentTime;     <---- player is no longer valid 

Tested on 3.2

Never releasing ALBuffer data

Never mind, retain counts in ALBuffer are cool. The problem is something much deeper. At least when using SimpleIphoneAudio loading and unloading a large number of effects will result in an eventual memory explosion.

Jumping in a little deeper:
Calling:
ALSource *source = [[SimpleIphoneAudio sharedInstance] playEffect:fileName loop:loop];
[temp addObject:source];

And later calling:
for(NSString *file in ambientSounds){
[[SimpleIphoneAudio sharedInstance] unloadEffect:file];
}

for(id<SoundSource>t in temp){
    [t clear];
}

Results in a crash when calling clear. v 1.1 running iOS 3.2 and 4.1

updating to iOS 8

upgrading my app to iOS 8. Getting the following error when building for the first time

OALSuspendHandler.m
"Too many arguments to function call, expected 0, have 3"
objc_msgSend

app crash during startup

When an app using ObjectAL starts via cocos2d version 3.2, AND another app is backgrounded that uses Dhension, the app being launched crashes on startup:

Carp : *** an exception [*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil] occured while  [ running game ].
(
0   CoreFoundation                      0x037761e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x02e288e5 objc_exception_throw + 44
2   CoreFoundation                      0x03728abc -[__NSArrayM insertObject:atIndex:] + 844
3   CoreFoundation                      0x03728760 -[__NSArrayM addObject:] + 64
4   battles                             0x0007d870 -[ALSoundSourcePool addSource:] + 128
5   battles                             0x0007c47f -[ALChannelSource addSource:] + 1183
6   battles                             0x0007468d -[ALChannelSource initWithSources:] + 397
7   battles                             0x00095d2f -[OALSimpleAudio initCommon:] + 175
8   battles                             0x000961a1 -[OALSimpleAudio initWithSources:] + 353
9   battles                             0x00095c45 -[OALSimpleAudio init] + 69
10  battles                             0x00095731 +[OALSimpleAudio sharedInstanceSynch] + 129
11  battles                             0x000957dd +[OALSimpleAudio sharedInstance] + 45
12  battles                             0x000bf209 -[CCAppDelegate setupCocos2dWithOptions:] + 4009
13  battles                             0x0001b926 -[AppDelegate application:didFinishLaunchingWithOptions:] + 1046
14  UIKit                               0x00c4d14f -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
15  UIKit                               0x00c4daa1 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1810
16  UIKit                               0x00c52667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
17  UIKit                               0x00c66f92 -[UIApplication handleEvent:withNewEvent:] + 3517
18  UIKit                               0x00c67555 -[UIApplication sendEvent:] + 85
19  UIKit                               0x00c54250 _UIApplicationHandleEvent + 683
20  GraphicsServices                    0x043d0f02 _PurpleEventCallback + 776
21  GraphicsServices                    0x043d0a0d PurpleEventCallback + 46
22  CoreFoundation                      0x036f1ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
23  CoreFoundation                      0x036f19db __CFRunLoopDoSource1 + 523
24  CoreFoundation                      0x0371c68c __CFRunLoopRun + 2156
25  CoreFoundation                      0x0371b9d3 CFRunLoopRunSpecific + 467
26  CoreFoundation                      0x0371b7eb CFRunLoopRunInMode + 123
27  UIKit                               0x00c51d9c -[UIApplication _run] + 840
28  UIKit                               0x00c53f9b UIApplicationMain + 1225
29  battles                             0x000025fd main + 397
30  libdyld.dylib                       0x0331b701 start + 1
)

afaik this is a simulator only issue ... have not been to reproduce on the devices i have, but it is systematic on simulator (xcode 5.1.1, iPhone retina 4 in iOS 7.1 simulator setting)

OALSimpleAudio + interruptions

  1. Load SFX using OALSimpleAudio... No idea if you need to play them, maybe just preload. In my case they load when they played.
  2. Set the alarm for one minute.
  3. Reenter app and wait for the alarm
  4. clear the alarm
  5. Hear all sound effects play at once

Same thing happens if I do the previous steps but instead of getting an alarm interruption I set manualInterruption to YES... switch it back to NO... hear all loaded sfx play.

Follow up:
It appears to be how the shadowState is handled with simple audio objects.
Namely in this final check in ALSource::setSuspended

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.