Sound (but not music) crashes on Android [SOLVED]

I have the following two sounds in my config:
[Music]
Music       = music.ogg
Loop        = true
KeepInCache = true
Volume      = 0.7

[ShootEffect]
Sound       = shoot.ogg
Loop        = false
KeepInCache = true
Volume      = 0.7

The following code plays music fine on an Android device:
orxSOUND *pstMusic = orxSound_CreateFromConfig("Music");
orxSound_Play(pstMusic);

The following code crashes an Android device:
orxSOUND *pstShoot = orxSound_CreateFromConfig("ShootEffect");
orxSound_Play(pstShoot);

The error according to catlog is:
[SOUND] [orxSound.c:orxSound_createFromConfig():629] Can't create sound <ShootEffect>: invalid content.
[ASSERT] [orxSound.c:orxSound)Play():1043] [ASSERT] : <(_pstSound != orxNULL) && (((((orxStructure *)(_pstSound))->u64GUID & orxSTRUCTURE_GUID


As an experiment in my config, I changed my ShootEffect from Sound to Music:
[ShootEffect]
Music       = shoot.ogg
Loop        = false
KeepInCache = true
Volume      = 0.7

And this plays in the game. Only once of course because it is music, but it proves the point that the sound file is fine and that it is locatable by orx.

My SVN version is a month old. hg getting the latest from bitbucket but it will take some time to get it all down. In the meantime, is this a known issue or have I made a mistake?

Comments

  • edited October 2012
    mmhh...

    what if your reencode this .ogg in .mp3 ?
  • edited October 2012
    Hi lydesik, mp3 doesn't work either but a different message this time...
    [SOUND][orxSoundSystem.c:orxSoundSystem_Android_LoadSample():429] Can't load sound sample <shoot.mp3>: unsupported format.
    

    Desktop version is also not happy with the mp3's and has a slightly different message:
    [SOUND] [orxSound.c:orxSound_LoadSample():188] Failed to add sound to hashtable.
    [SOUND] [orxSound.c:orxSound_CreateFromConfig():629] Can't create sound <ShootEffect>: invalid content.
    
  • edited October 2012
    There's no MP3 support on the computer versions due to patent issues, unfortunately.

    It's only supported on iOS and Android.
  • edited October 2012
    Cool, thanks, Iarwain. That stops the desktop part clouding the issue.

    I can only guess that there may be something about my sample format that is upsetting android when played as a sound as opposed to music.

    They're 44100hz 16-bit stereo oggs/mp3s. I am not aware of any format recommendations.
  • edited October 2012
    oops my bad, mp3 wont work either on android (it works for music but not for sounds)

    it's very weird, never had such issue

    I've just pushed a small fix, but I don't think it will fix your issue...

    lydesik
  • edited October 2012
    can you test if you have the "bounce" sfx in the demo app?
  • edited October 2012
    Good idea!

    Some interesting results:

    I re-tried the orx bounce demo (with the bip.ogg sound file) on the Motorola Xoom and all is fine.

    I swapped the bip.ogg for my shoot.ogg and renamed it to bip.ogg. When running the demo, I get no sound effect, but several messages:
    [SOUND] [orxSound.c:orxSound_CreateFromConfig():629] Can't create sound <Bip>: invalid content.
    [SOUND] [orxSoundPointer.c:orxSoundPointer_AddSoundFromConfig():951] Could not find object named 'Bip' in config.
    

    The difference above, these errors don't crash the demo. But either way, is doesn't like my ogg file.

    Despite the error, the 'Bip' section is clearly there in the config. All that has changed is the content of the bip.ogg.

    Next experiment, changing my shoot.ogg to be copy of the bip.ogg file (in my game).

    Low and behold I hear the sound, but then the game crashes, and the Xoom starts shutting down due to the battery. So now I can't prove if the crash was the result of the battery until the morning when I get back to work where the charger is.

    So assuming that all is fine, comparing the difference between the files:

    shoot.ogg
    Format : OGG
    File size : 64.4 KiB
    Duration : 3s 529ms

    Overall bit rate : 149 Kbps
    Format : Vorbis
    Format settings, Floor : 1
    Bit rate mode : Constant
    Bit rate : 160 Kbps
    Channel(s) : 2 channels
    Sampling rate : 44.1 KHz
    Stream size : 68.9 KiB
    Writing library : libVorbis 1.2 (UTC 2007-06-22)

    bip.ogg
    Format : OGG
    File size : 6.10 KiB
    Duration : 165ms

    Overall bit rate : 303 Kbps
    Format : Vorbis
    Format settings, Floor : 1
    Bit rate mode : Constant
    Bit rate : 96.0 Kbps
    Channel(s) : 1 channel
    Sampling rate : 44.1 KHz
    Stream size : 1.93 KiB (32%)
    Writing library : libVorbis (Schaufenugget) (20101101 (Schaufenugget))

    The interesting differences (potential issues) are highlighted in red above.

    My guess is that it is down to either a file size or duration limitation, the number or channels, or the library that wrote the file.

    I'll toy with my file and match the differences tomorrow night to find out what it is.
  • edited October 2012
    btw: I'm using the same lib as orx for desktop (stb_vorbis)

    the only diffrence is that I'm loading the whole file in a byte aray before asking stb_vorbis to decompress it in the sample buffer.

    so if your shoot.ogg file works on desktop, that can means only two thing.

    1) for some weird reason, the file is not loaded correctly, so stb_vorbis fails to decompress it
    2) std_vorbis.c is not compiled correctly on android.

    could you attach the file in this thread so I can test/debug what's going on here.

    lydesik
  • edited October 2012
    Sound file is attached.

    I got the Xoom charged and tried the build again. The sounds do play, so that part is comfirmed. But I fire too many at once and that does crash the game. Anyway, one thing a time, we can sort that part out later.

    https://forum.orx-project.org/uploads/legacy/fbfiles/files/shoot.zip
    shoot 62.8K
  • edited October 2012
    Turns out that it is the 2 channel sound samples that are the cause. I converted to mono and all is fine. Except that it crashes after a couple of samples are triggered.

    I'll check how the demo triggers the samples and do the same.
  • edited October 2012
    Just tested with the new mono sounds and with the demo's way of playing sounds and all work is working beautifully.

    For those who want to see what I have ended up doing to keep android happy:
    [ShootEffect]
    Sound       = /my/path/to/shoot.ogg
    Loop        = false
    KeepInCache = true
    RefDistance = 0.0 ;This is important so that your mono sounds are loud (that's a rough explanation - see the wiki for the proper description)
    Volume      = 0.5
    

    And instead of doing this in an event:
    orxSound_Play(pstShoot);
    

    do this instead:
    orxObject_AddSound(orxOBJECT(heroObject), "ShootEffect");	
    

    Thank you, lydesik for helping me think this problem through.

    Not sure if these issues are bugs, ie too many orxSound_Play()'s crashing android and stereo samples crashing android, but at least I can call this thread solved.
  • edited October 2012
    Ok great,

    I'll create an assign myself the issues, (don't know when I'll be able to fix them)
  • edited October 2012
    Sausage, if you want to get notified when there's an update on this case, you can add yourself as a watcher for those issues here: http://code.orx-project.org/orx/issues?status=new&status=open
  • edited October 2012
    That's very handy, will do.
Sign In or Register to comment.