Android Sound Stability..

I have built my Star-Fighter game (works 100% in iOS), for Android and am having Sound Issues. there is BG music looping when menu loads, but as soon as a SFX plays, the BG loop stops (or crashes, IDK whats going on), until the game starts/ends when th…

Viewing 1 to 20 (20 Total)
Android Sound Stability..

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

I have built my Star-Fighter game (works 100% in iOS), for Android and am having Sound Issues.

there is BG music looping when menu loads, but as soon as a SFX plays, the BG loop stops (or crashes, IDK whats going on), until the game starts/ends when the event is triggered to start the music loop again.

Its very annoying and feels unstable..

Any ideas?

Tags:
Posted on April 10, 2012 at 8:18 PM

altef

altef
Total Posts: 105
Joined: February 25, 2012

Re: Android Sound Stability..

does logcat say anything? (in Android SDK\platform-tools try adb logcat GameActivity *:s, or maybe just adb logcat - there could be a lot of text)

Posted on April 10, 2012 at 11:57 PM

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

Re: Android Sound Stability..

How does that work? do you run the app and debug from a PC? or can you view the logs on the phone/tablet itself?

Posted on April 11, 2012 at 12:00 AM

altef

altef
Total Posts: 105
Joined: February 25, 2012

Re: Android Sound Stability..

I usually have my phone plugged in via usb, and then have two console windows open.
One of them I run nme test application.nmml android in, and the other i use for logcat. Then as things get logged they show up in the second window.

(In case you're interested: trace's on android are Log.i("trace", messsage);, and I assume nme test - android runs its own logcat call to display those. If you just call adb logcat, without any filtering arguments those traces will be visible in both windows.)

Posted on April 11, 2012 at 12:07 AM

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

Re: Android Sound Stability..

ahh okay

I havent debugged directly on a device before, so its new to me.

Normally for iOS I use TestFlight to remotely deploy, and for Android have been uploading the APK to gmail, and downloading to the device(s) for testing.

Posted on April 11, 2012 at 12:14 AM

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

Re: Android Sound Stability..

I just ran both apps on my partners IDEOS X5 (3.8inch, 800mhz Android 2.3) and when it plays a sound/starts music, it lags for a brief second.. something is definitely up with it.

When running them on my HP Touchpad (Android 4.0.3, 9.7inch, 1.8ghz dual core), the lag wasn't noticeable, but still would stop the previously playing sound..

Posted on April 11, 2012 at 12:16 AM

singmajesty

singmajesty
Total Posts: 2146
Joined: August 25, 2011

Re: Android Sound Stability..

Are you sure your sounds are "sounds", and not "music"?

There's a distinction in most platforms between the two -- Android will only play one "music" track at a time, but can play multiple "sounds" at once. They are different APIs, and I believe MP3 is only supported for music, while WAV and maybe OGG are supported for the sounds.

NME automatically flags file extensions as either sound or music... if you added multiple mp3s they'd both be flagged as music, and would replace each other when playing. This is similar to how SDL_mixer works for the NME desktop, webOS and BlackBerry targets.

You can explicitly specify whether a file is sound or music by adding 'type="music"' or 'type="sound"' to the assets node. You can use multiple assets nodes, so you should be able to make a node which includes the files you need, sets the type, etc.

Posted on April 13, 2012 at 8:27 PM

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

Re: Android Sound Stability..

Yes they are all mp3 files (music and sound)... so I make the sounds as WAV instead, it should solve my problem?

Posted on April 14, 2012 at 12:07 AM

singmajesty

singmajesty
Total Posts: 2146
Joined: August 25, 2011

Re: Android Sound Stability..

Yep, if you switch the sounds over to WAV, I bet it will work.

Under the hood, NME uses Android's MusicPlayer and SoundPool APIs for music and sound. Here is someone who briefly explains the difference:

http://www.stealthcopter.com/blog/2010/08/android-soundpool-vs-medi...

Posted on April 14, 2012 at 1:20 AM

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

Re: Android Sound Stability..

yup fixed it great. Performance is better now too.

I tried using my multi touch code for iOS on android, which didn't work.

The TouchPointID always returns 0, whereas iOS returns the touch point

Any hints to anything to fix?

Posted on April 14, 2012 at 1:47 AM

altef

altef
Total Posts: 105
Joined: February 25, 2012

Re: Android Sound Stability..

Hmm... I'm getting touchPointID values back up until I run out of fingers. (Thanks, btw. I had no idea this was how multi touch worked.)

What happens if you just try this:

class Main
{

static public function main()
{
var stage = Lib.current.stage;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
// entry point
stage.addEventListener( TouchEvent.TOUCH_BEGIN, onTouchBegin ) ;
}

static function onTouchBegin( e:TouchEvent ) {
trace("touch: " + e.touchPointID );
}

}

Posted on April 14, 2012 at 2:03 AM

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

Re: Android Sound Stability..

in my initailize code I have the following which I use for iOS to enable multi-touch:

mMultiTouch = nme.ui.Multitouch.supportsTouchEvents;
if (mMultiTouch) nme.ui.Multitouch.inputMode = nme.ui.MultitouchInputMode.TOUCH_POINT;

So am using this for android also.. do you think I need to comment it out? would it affect it?

Posted on April 14, 2012 at 8:18 AM

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

Re: Android Sound Stability..

hmm interesting.. I had changed some conditions in my move event function, and it fixed my issue.. so multi-touch is working yay!.

Just one last issue remaining now..

Using Textfields (editable and non-editable), they aren't showing in android but are in iOS/Flash.

The editable one is able to click into and bring up the Onscreen keyboard, but no visible text is show..

Any ideas?

Posted on April 14, 2012 at 8:26 AM

Philippe

Philippe
Total Posts: 261
Joined: September 08, 2011

Re: Android Sound Stability..

Try using font "_sans" in case of text issues.

Posted on April 14, 2012 at 9:07 AM

singmajesty

singmajesty
Total Posts: 2146
Joined: August 25, 2011

Re: Android Sound Stability..

I think there may have been a minor issue that was preventing embedded fonts from working properly on Android.

We'll be releasing a 3.3.1 beta, soon, so that might be a good time to check and see if the issue is resolved smiling

Posted on April 14, 2012 at 12:43 PM

NZCoderGuy

NZCoderGuy
Total Posts: 67
Joined: December 08, 2011

Re: Android Sound Stability..

"_sans" as my font? how do I go about doing that?

Posted on April 15, 2012 at 7:07 AM

altef

altef
Total Posts: 105
Joined: February 25, 2012

Re: Android Sound Stability..

I beleive TextFormat takes (as its first parameter) a fontName:String. Try something like this:

var textField = new TextField();
var format = new TextFormat("_sans", 12, 0x000000 );
textField.defaultTextFormat = format;

Posted on April 15, 2012 at 7:11 AM

Philippe

Philippe
Total Posts: 261
Joined: September 08, 2011

Re: Android Sound Stability..

@altef: you're correct about the TextFormat use.

However embedFonts does nothing for C++ targets - it's needed for Flash if you're using an embedded fonts (and obviously not needed for _sans).

Posted on April 15, 2012 at 2:04 PM

altef

altef
Total Posts: 105
Joined: February 25, 2012

Re: Android Sound Stability..

Man, I was sure that embed fonts when using "_sans" stopped my textfields from displaying in android, and then removing it fixed them!

But I just tested, and you're right - they both worked fine with! (I'll edit my other post so as not to mislead any future readers!)

Posted on April 15, 2012 at 2:33 PM

mourlamstudios

mourlamstudios
Total Posts: 152
Joined: February 12, 2012

Re: Android Sound Stability..

singmajesty -

Will you be looking into the leaks with textfields in iOS as well with the 3.3.1 beta?

Posted on April 16, 2012 at 8:26 AM