SimpleAudioEngine in Cocos2d no sound

Home Forums OpenEars SimpleAudioEngine in Cocos2d no sound

Viewing 7 posts - 1 through 7 (of 7 total)

  • Author
    Posts
  • #1017450
    artcube
    Participant

    After adding openears to my Cocos2d project, playing a sound on a device using SimpleAudioEngine gives no error but plays no sound. Works fine in simulator.

    Even initializing openears causes this issue without saying anything.

    This is the call:

    [[SimpleAudioEngine sharedEngine] playEffect:POPING_SOUND pitch:1.0f pan:0.0 gain:1.0];

    As long as I initialize:

    self.fliteController = [[FliteController alloc] init];

    No sound comes out. I should mention the POPING_SOUND is a wav file.

    Thanks for the help, I really like the engine but it needs to work with sound.

    #1017451
    Halle Winkler
    Politepix

    Welcome,

    The underlying issue is that OpenEars’ sound requirements add up to an additional audio engine’s worth of code, so there is probably an unwanted interaction between OpenEars’ audio session handling and SimpleAudioEngine. A search through this forum for “audiosession” and/or “allowmixing” should turn up some explanations of how to turn on mixing for different audio streams/sessions, which would be the first troubleshooting step. This issue:

    https://www.politepix.com/forums/topic/openears-avplayer-issue/

    Probably has very similar underpinnings, so it is probable worth a read to debug the issue you’re seeing.

    #1020311
    BenoitFreslon
    Participant

    Hello,

    I got the same problem.

    Did you find a workaround?

    Thanks.

    #1020320
    Halle Winkler
    Politepix

    Welcome,

    OpenEars isn’t expected to work alongside another audio engine, since they will be addressing the same resources.

    #1020322
    BenoitFreslon
    Participant

    I just found a workaround to resume sounds in cocos2d.

    I added this line of code:

        NSError *error;
        [[AVAudioSession sharedInstance]
         setCategory:AVAudioSessionCategorySoloAmbient error:&error];
    #1020323
    Halle Winkler
    Politepix

    Do you then set the audio session back to one that OpenEars can use for speech recognition?

    #1020324
    BenoitFreslon
    Participant

    I try to stop all active OpenEars delegate like this:

    - (void) stop {
        if (self.openEarsEventsObserver) {
            self.openEarsEventsObserver.delegate = nil;
            self.openEarsEventsObserver = nil;
        }
        if (self.pocketsphinxController)  {
            [self.pocketsphinxController stopListening];
            self.pocketsphinxController = nil;
        }
        
        NSError *error;
        [[AVAudioSession sharedInstance]
         setCategory:AVAudioSessionCategorySoloAmbient error:&error];
    } 
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.