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

Erratic sound clipping on iOS - first part of sound isn't played

Contributor ,
Aug 04, 2013 Aug 04, 2013

Copy link to clipboard

Copied

Hi All,

On my iPhone I'm seeing (actually, hearing) a problem where the beginnings of sounds aren't being played. These are MP3 files that the app has downloaded and saved on the device. They are being loaded and played like this:

        var file:File = new File(url);
        var request:URLRequest = new URLRequest(file.url);
        var context:SoundLoaderContext = new SoundLoaderContext(500, true);
        var sound:Sound = new Sound(request, context);
        sound.addEventListener(IOErrorEvent.IO_ERROR, onSoundLoadError);
        sound.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSoundLoadError);
        var transform:SoundTransform = new SoundTransform(soundVolumeAdjustmentFactor);
        _soundChannel = _sound.play(0, 1, transform);
        _soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);

This is happening in a Flex mobile app. I'm not seeing it on Android, on the desktop AIR simulator, or on my 5th generation iPod Touch - only on my iPhone 4.

The problem is somewhat random/erratic - as to when / which audios / degree of clipping - but is easy to reproduce in my app. I haven't tried creating a sample, bare bones app that demonstrates the problem yet - I'm hoping that one of you will have dealt with this and can provide an easy solution.     I've already put several days into trying to solve this at this point, and have done a lot of googling.

I'm seeing clipping of anything from a fraction of a second up to cases where the first 10 seconds of an audio isn't played. Typically my files range from as short as a fraction of a second to several seconds, but I'm using a longer (12 second) file for testing purposes, which is what allows me to see cases where a full 10 seconds of audio is ignored. This 10-second case only happens in the first file that's played after I start up the app.

The only thing that I've found that helps is to a) create the Sound and SoundTransform, b) play the sound in a loop at zero volume (new SoundTransform(0)), c) wait a while (1 second) using Timer, then d) play the sound again with volume turned up. This improves the situation but doesn't solve it.

  • The problem becomes much more predictable - i.e. less random and erratic. It happens to the same degree to the same files in the sequence of files that I'm playing.
  • The problem decreases, e.g. the maximum clipping that I'm seeing is 3-4 seconds, and it happens in a smaller percentage of the files that I play.

Once I do this, the problem seems to affect specific files more than others. In other words, it consistently impacts certain files but not others, regardless of their position in the sequence of play. The problem-prone and problem-free files look similar to me when I open them in Audacity. Mystery upon mystery.

Any ideas on what is causing this, or how to prevent it? Is this a known bug? Is there an error in my code?

Thanks,

Douglas

TOPICS
Development

Views

1.8K

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 ,
Aug 07, 2013 Aug 07, 2013

Copy link to clipboard

Copied

I've discovered that this 'sound clipping' problem only occurs after I use Microphone.

All I have to do is set a class property to an instance of the mic, like this:

_microphone = Microphone.getMicrophone()

then enable it like this:

_microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, onNewRecordingSampleData)

From then on, even after I remove the event listener, the app mangles audios played as described in the previous post.

Is there something else that I should be doing to disable the mic?

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
Adobe Employee ,
Aug 09, 2013 Aug 09, 2013

Copy link to clipboard

Copied

Hi Douglas,

I am trying to create a sample application using above information  provided on iPhone4(v6.1.3) with AIR SDK availabe at http://www.adobe.com/devnet/air/air-sdk-download.html and unfortunately it could not be reproduce yet. I have attached the zip file at https://www.dropbox.com/s/q41l58vin6h4foh/MicrophoneSound.zip , please have a look on the .as file and let me know if this is not the same case or I have missed something.

Regards,

Nimit

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 ,
Aug 12, 2013 Aug 12, 2013

Copy link to clipboard

Copied

Hi Nimit,

Thanks for responding on this thread. You hadn't added an event listener to the mic, and I only have the problem when the mic is activated by adding an event listener. But I've done a bit of work and 'enhanced' your example a bit, and I'm still not seeing the problem.

At this point we have two options. One is for me to work on creating a minimal case of an app with this problem. This will probably take a few (more) days of my time, but I'm willing to do it.

The other would be for you to download my app. It's open source and publicly available at http://code.google.com/p/languagementor/. It's not a trivial app (10K+ lines of code). I don't know if this would work for you on a practical level - but I'm guessing that you have ways to see what's happening 'under the hood' and you might be able to quickly diagnose why audios aren't playing.

What do you think? If the second option would work for you, you'll find a ReadMe file with setup instructions at the root of the /trunk/languagementor folder, and I can provide you with very specific 'bug repro' steps that you can follow once you have the app on an iPhone 4.

Thanks,

Douglas

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
Adobe Employee ,
Aug 12, 2013 Aug 12, 2013

Copy link to clipboard

Copied

Thanks Douglas for trying the sample application. And yes, I will try to setup your shared source and run it on an iPhone4.

Meanwhile, I request you to create a minimal case of the application to reproduce the problem. This will help us to alot.

Regards,

Nimit

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 ,
Aug 13, 2013 Aug 13, 2013

Copy link to clipboard

Copied

Hi Nimit,

> I will try to setup your shared source and run it on an iPhone4.

Great. Thanks.

I just committed some changes that make the code a little simpler, so if you've already checked code out I suggest that you do an update.

If you have any problems setting it up, let me know.

If you don't - and get the app running on the iPhone - also let me know. I'll send you specific 'problem repro steps'. Feel free to contact me offline via my Adobe ID email - I'm not sure that readers of this list are interested in these details.

> Meanwhile, I request you to create a minimal case of the application to reproduce the problem.

I'm already working on it. 

Douglas

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 ,
Aug 15, 2013 Aug 15, 2013

Copy link to clipboard

Copied

Hi Nimit & All,

It looks as though I've found the problem, or at least how to recreate and avoid the problem.

Code that does the following will cause sound clipping on iPhone 4:

  1. Get a reference to Microphone
  2. Add an event listener for SampleDataEvent.SAMPLE_DATA
  3. Remove listener (it doesn't look like you actually need to do anything in the listener method, though of course you will in most cases)
  4. Do one or more synchronous calls to your SQLite DB - the more calls you make, the more sound will be clipped, i.e. not played.
  5. Play audio. Beginning of audio will be clipped.

Workaround: Get your data from the DB before you start playing audio. 

Nimit - I don't think that I'm going to have time to create a minimal case app. Such an app would have to have a DB with a bunch of data, and perhaps a fair amount of audio. (I'm not sure whether the audio can be simple embedded files or needs to be downloaded audio stored on the file system, as is the case in my app.) I'd be happy to work with you to show you this behavior in my app, as mentioned in a previous post. If this interests you, I suggest that you use SVN revision 900, as later revisions include the workaround mentioned above. Let me know if I can be helpful in this process.

Thanks,

Douglas

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
Adobe Employee ,
Aug 15, 2013 Aug 15, 2013

Copy link to clipboard

Copied

Yes, this is look interesting and we need to look at the code once. Yes, we will check this with revision 900 and later. Mean while, I request you to open a new bug report on this over at https://bugbase.adobe.com?  When adding the bug, please include as much as information like iPhone4 specific or not. This will help us in our investigation.

Once added, please post back with the URL so that others affected can add their comments and votes.

Regards,

Nimit

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 ,
Aug 17, 2013 Aug 17, 2013

Copy link to clipboard

Copied

> open a new bug report ... post back 

Will do, though it may be a few days before I get to this - I'm in the midst of some stuff that is occupying virtually all of 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
Contributor ,
Aug 21, 2013 Aug 21, 2013

Copy link to clipboard

Copied

> request you to open a new bug report on this over at ... please post back with the URL

Done.

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

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 ,
Aug 26, 2013 Aug 26, 2013

Copy link to clipboard

Copied

LATEST

Update: I've been able to work around most of these problems in my app through a combination of these strategies:

  • Minimize calls to DB by caching data
  • Perform calls to DB as early as possible, so that as much time as possible passes before playing audio
  • Create a pause, using Timer, before playing audio. These pauses range from .5-6 seconds. Fortunately this is acceptable in the context of my app, but obviously it wouldn't be in many other apps.

One remaining big problem: I haven't been able to ensure that button clicks play. Obviously, it isn't acceptable to have even a .5 second pause between the time when the user taps the button and the time when the click occurs, so for now my app attempts to play the click immediately, and some clicks simply don't get played. This is NOT a good user experience.

I request that Adobe fix this ASAP. 

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