• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Sound lag on Android

Contributor ,
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

I am testing an Android app I am making in AIR and I'm noticing that there is ~300-500ms of lag between when a sound effect is supposed to play and when it actually plays. There are no other performance problems. This is occurring in an action game running at 60fps so the audio delay is very noticeable and irritating. I searched around for solutions but didn't find much out. More details:

I am playing the sound effects using the built-in sound classes, namely SoundChannel. The sound effects were created as WAV files with no gap at the beginning, imported into CS6, and exported as symbols (with MP3 encoding) in an SWF. This prevents them from having the dreaded MP3 gap at the beginning and there is no delay on the computer. The device in question is an HTC One.

Is there any way around this or is it just a major problem in AIR?

TOPICS
Development

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 19, 2014 Jun 19, 2014

Android has delayed audio. Kindle Fire in particular has very delayed audio. This has been reported to the Flash/AIR teams for years. We should be so lucky as to have only 10-100 mS of delay.

Votes

Translate

Translate
Guest
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

I would try creating an MP3 and importing that instead of having Flash create an MP3 at runtime from a WAV file. Also, when looking at the Sound Properties of the MP3 in the library, change the compression type to raw, uncheck "Convert stereo to mono" and change the sample rate to match the MP3s original encoding. You should see at the bottom of the window it saying the sound file will be "100% of original" so it isn't double compressing. Let me know if that changes anything.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

Hi Waded,

Are you familiar with the fact that saving a sound effect as an MP3 adds 50-100ms of silence to the beginning of the file? However the CS IDE has some method of bundling your sounds as MP3s without the gap at the beginning, necessary for gapless music loops etc. The trick I described is a standard method of saving a file as an MP3 in a Flash project where you don't use the CS IDE. 50-100ms less lag but still noticeable

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

I am not familiar with that about MP3s. I was always taught though to try and use as few "Export for ActionScript" objects as possible unless you provided a real class to be attached to it since it isn't really OOP to use that method and that you should just load in the sound files through the Sound object and play them that way. I've never heard of that being a standard way of saving MP3s in Flash. Did you try the idea I suggested? Also, you're original question never said anything about a perfect loop being needed. Just that the delay was an issue.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

Hi Waded,

Thanks for the reply. If you save a sound file as an MP3 and then open it in an audio editor you will indeed see there is a small gap at the beginning. Thus your method is guaranteed to have latency, noticeable even on the computer, as well as preventing gapless looping. The method I have described normally allows you to store your sound files as MP3s without gaps which allows for instant playback and seamless looping on the PC. However for some reason it's experiencing latency on the Android device. Perhaps someone with more experience in the sound department would care to comment?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

In creating MP3s I have never noticed the latency of which you speak and the only references I can find to back up what you say is Adobe products doing it on export of MP3 audio files. So it isnt even guaranteed to have the latency if you tried some other software that can create MP3 files. With that being said, I will ask my question again. Did you even try my suggestion or are you just assuming it wont work? And since you are dismissing my help altogether just because I dont work in audio very much, I doubt anyone else is going to want to help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

Wade, the first thing I did was try embedding my own MP3 files directly, rather than putting them into an SWF as symbols, but there was a noticeable delay even on the computer. MP3s have a gap at the beginning and that's just how the format is. Instead of trying to argue I should "try it your way", you could make the basic effort to load an MP3 in an audio editor (you can try a free one such as Audacity) and see there is always a short gap at the beginning. I am dismissing your suggestions because you are simply wrong.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

Android has delayed audio. Kindle Fire in particular has very delayed audio. This has been reported to the Flash/AIR teams for years. We should be so lucky as to have only 10-100 mS of delay.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 19, 2014 Jun 19, 2014

Copy link to clipboard

Copied

Wade, in response to your deleted comment, I don't know how old you are or your background but this is a mixed environment with both amateurs and professionals. Your seem to have assumed the attitude that someone asking a question is obligated to try out whatever half-baked solution comes to your mind first, without regard to your relative levels of experience. I am not sure why you wanted me to try out your suggestion when by your own admission you don't know much about what you are talking about. Frankly it is somewhat insulting, as you might be insulted if someone with no Flash experience tried to give you bad advice and ignored your explanation of why they were wrong. I am not claiming to be an expert, I've posted my fair share of dumb questions here, but I am also not a total novice. I don't really have time to humor your suggestions borne from a lack of knowledge on the subject. Remember, the forum is a two-way street; even though I asked the initial question, you had an opportunity to learn something new about development here, but you passed it up to play ego games.

Thank you Colin, it's not good news but at least it's an answer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 20, 2014 Jun 20, 2014

Copy link to clipboard

Copied

Previous post was done in haste, so that is why it was removed. But not having much experience does not automatically mean my suggestions are complete garbage and may have had merit based on your original post. And not much experience doesn't automatically mean that I have never successfully used the idea I gave you. I could not find any sources online backing up what you say about a delay at the beginning of a MP3 file so that is why I didn't bother with it. Can you provide citation for that? Again you are assuming you know better than I do and are assuming my idea wouldn't work because you are assuming that any MP3 you create will have a delay at the beginning. Besides, if you know that an MP3 will have an exact delay at the beginning, you could load the MP3 with the Sound object and give it an offset of the delay when you play the MP3. That way, the only delay you would have is how long the system takes to play it. You claim this forum is a place for people to come and learn something, yet you seem unwilling to learn and entertain an idea that I have successfully used in the past that would have taken you all of 5 minutes to change out a few WAV files for an MP3. Did you even try your app on another device to make sure it isn't just an HTC One issue?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 20, 2014 Jun 20, 2014

Copy link to clipboard

Copied

Waded, it is not my fault you are too lazy to do basic research on your own. https://forums.adobe.com/message/4638107   And again, you could open up any MP3, zoom in, and see the gap at the beginning. The method I described of importing the audio already removes the silence at the beginning, thus there is no reason to play the file with an offset, and I cannot play the sound effects early when they are in response to user input.

Again, you have made this into an ego game where you think I am obligated to follow your suggestions. I am going to ignore you from this point because you are wasting my time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 21, 2014 Jun 21, 2014

Copy link to clipboard

Copied

You keep using the word ego but I do not think you know what that means. I asked for a simple citation after the only thing find anything from an initial search was from the Adobe forums saying Adobe products did that. You say I have an ego because I did not go through the effort of downloading and installing software just to put an MP3 under the microscope, yet you were unwilling to try any of the ideas I gave you. So who has the ego? And as to my suggestion with the Sound class and offset, I never said anything about playing them early. I said using the one of the Sound object to play the MP3 with an offset. If you actually bothered looking at the API Reference or knew what you were doing, then you might have had a solution as the play() method of the Sound object has a parameter to offset the start time of the MP3. So you would play the sound effect at the same moment you would normally, but the sound would start playing X milliseconds into the file to skip over the delay since you would know what the delay of the MP3 file would be. And according to this thread, you still have the issue of up to a half second delay.

Even if you were still having the problem after trying an MP3, then your app must not be optimized at all and is just having performance issues or it is a issue unique to the HTC One. You might know the answer to that if you bothered to test the app on a different device.

Sound - Adobe ActionScript® 3 (AS3 ) API Reference

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 21, 2014 Jun 21, 2014

Copy link to clipboard

Copied

The method I described of importing the audio already removes the silence at the beginning, thus there is no reason to play the file with an offset

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 21, 2014 Jun 21, 2014

Copy link to clipboard

Copied

LATEST

I added a note to the bug report about this, which had been closed because of lack of response from anyone. But that’s not surprising, I only found the report by chance:

https://bugbase.adobe.com/index.cfm?event=bug&id=2878728

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines