Bizarre audio problem

Discussion and feedback on Construct 2

Post » Mon Sep 07, 2015 10:56 pm

Hello there, (I am updating this thread as I find out more info)

Got a very serious and bizarre audio problem on a released iOS app that has several symptoms (while only running on device):

    1) Can only be described as all sounds in the "Sounds" folder (SFX) becoming downpitched and low Q/bitcrushed.

    2) Device will sometimes emit a loud BZZT or POP (no such sound exists in game) and after this, audio as a whole usually doesn't work, SOMETIMES EVEN IF you close the app and restart it. To get audio to work again you need to load another app to get some sound to play and then open ours again which forces it to work. It's as if something is temporarily BREAKING on the device.

    3) Audio can just not work.

    EDIT: 4) Forgot to mention that if you press the home button to come out of the game (but game is still running in background), when you re-enter the game EVERY SFX that has been played so far inside that layout will play at the same time. Can be repeated.

All of these problems generally happen quite randomly (and less than 50% of the time in our tests) with a slightly higher chance happening when a new layout is loaded or a new audio track plays, or after an Admob advert has been watched. Restarting the app can sometimes even cause or fix these problems!

Only tested this on iOS so far but it does happen across different iOS devices (iPhone, iPad). The fact we had a few players tell us is pretty worrying.

Some maybe relevant technical details (since I cannot provide CAPX):

    - 6 music tracks, on average 45s long for each.
    - 18 SFX files.
    - The most demanding layout will play all of these bar one music track.
    - Even so, the problems can still occur in the menu layout which is much less performance heavy.
    - EDIT: Minifying script changes nothing.

We haven't got the slightest clue what's causing it, hence why I posted in General. So far we've suspected:

    - Bad audio code (done a complete overhaul, read below)
    - Bad audio performance (maybe something to do with bandwith or overloading the audio thing on the device, hence bitcrushing esque noise)
    - Construct bug
    - We updated Construct (EDIT: tests have now shown this is unlikely a cause)
- Something to do with the HTML5 limitation that requires a tap to trigger audio. Can sometimes emit the BZZT or POP on the first touch.

I will now elaborate on a few of these below to try to give you as much info as pos. Brace for wall of text:

We're leaning away from it being a problem in our code as we've since re-coded the whole audio system in the game to be more efficient, and the problem still exists. But just in case someone spots anything weird, here's the old audio system we had:
The audio system always had to be a bit dodgy in the first place. We export as Cordova out of Construct and we use Intel XDK to wrap it as an app. Now, with this workflow, I've read Crosswalk cannot fire a "Set Silent" or similar event and I do remember we had problems with this way back in early dev. So we had to find ways around that to mute music and SFX independently.
Our game is essentially an endless reaction game, and as you score higher you go through "zones" within the same game layout that each have a different audio track. Each audio track was composed to the second according to how long it would take to transition to the next zone. So when you hit a new zone, track 1 is already tailing off and track 2 begins. Due to latency issues/HTML5 only playing things when the screen has been touched, we had to set all music tracks to play on start of layout and then immediately pause all of them if they hadn't been set to muted (in that case, they were just stopped), meaning when we needed to play a certain one, we would tell which one to resume and it would play instantly as the screen had been touched way earlier in the game. This led us to think all this paused audio was sort of hogging resources. Oh and I forgot to mention, for all the SFX, when muted we would add a mute effect to every single one. Doesn't seem too efficient, adding a mute EFFECT? Which is why we did the following:

All SFX now are inside a function in its own event sheet that gets included where needed in the project. No SFX ever has a mute effect any more, the function behaves in a way that just listens for when a SFX is needed, picks the appropriate SFX, and only plays it IF muting is OFF. A lot more efficient right? I have no idea why we didn't do that in the first place.
As for the music, it now works as a sort of relay system, so that 2 tracks are only ever loaded at once instead of 5. So at the start of the layout track 1 and 2 are set to play but then 2 gets immediately paused. When 1 finishes, 2 resumes, 3 is set to play and then paused. And so on. So is it safe to say the sound in the game and the way it's coded is not the problem? We (maybe) think so! An update to the game that incorporates this new system will be pushed tomorrow (not that it fixes the problem...).

Finally, we built the majority of the game in Construct version 200 and since about a month ago we've updated and are using the latest versions. We cannot help but wonder... is it related? We don't think we had these problems before then... Did any updates since 200 address or cause any audio issues?


Anyway we haven't had the time to replicate the problem yet (nor do we even know how...).

Apologies for lack of details, but given the nature of the problem... what can I do? I do apologize for not uploading a CAPX but we obviously don't want to give people our game. You can find the game on the App Store (search for Fallen). We would greatly appreciate if anyone could try and reproduce the bug and post their thoughts. Try opening/closing the app and muting/un-muting to try and get it to trigger. You'll know it when it happens! It will be updated to version 1.0.1 probably within the week. That version will have the new audio code as described above.

Long post... but looking forward to see if anyone has any ideas!

EDIT: We've opened an old build built with version 200 and and exported with the new and old sound code and the problems STILL OCCUR.
B
9
S
2
G
1
Posts: 19
Reputation: 660

Post » Tue Sep 08, 2015 10:04 pm

New post for a revelation on the problem:

It's very likely the Intel XDK could be doing it. Made a blank app with some heavy audio usage in it and have experienced the 3rd and 4th points at the top of my previous post.
B
9
S
2
G
1
Posts: 19
Reputation: 660

Post » Thu Sep 10, 2015 10:16 am

I also get the audio corruption infrequently on my ipad4, since I'm currently using intelxdk preview I assumed it was an issue downloading/streaming the audio. Very worrying if its happening on live apps too.
I consistently get the play every audio in the level on app resume also (annoying)
Bugs for Intel XDK maybe.
B
13
S
4
Posts: 65
Reputation: 875

Post » Thu Sep 17, 2015 5:58 pm

I'm having no joy with the audio corruption, but something @Ignaci mentioned in another thread (thanks!) gave me the idea of setting the audio to silent on browser suspend and back on with resume and a 2 second wait and this stopped all the horrible playback of all sfx effects at once bug.
You have to put in a long enough wait for the duration of your longest sample, for me 2 seconds was enough.
It's not great but better than the alternative!
B
13
S
4
Posts: 65
Reputation: 875

Post » Thu Sep 17, 2015 7:54 pm

majesticAsFk wrote:I'm having no joy with the audio corruption, but something @Ignaci mentioned in another thread (thanks!) gave me the idea of setting the audio to silent on browser suspend and back on with resume and a 2 second wait and this stopped all the horrible playback of all sfx effects at once bug.
You have to put in a long enough wait for the duration of your longest sample, for me 2 seconds was enough.
It's not great but better than the alternative!


I am very glad that this helped You!
Positive, inspiring and jazzy games!

www.crystalgames.space

Enjoy!
B
17
S
8
G
3
Posts: 174
Reputation: 3,455

Post » Fri Sep 18, 2015 2:05 am

I'm also having a very similar problem. Sometimes when I open the app the audio is very distorted, like a bit-crusher type sound. Even closing the app from the app switcher and re-opening it doesn't help. The only way to fix it is by resetting my iPhone. I'm currently using XDK, I'm going to try switching over to phonegap and see if it makes any difference.
B
6
S
1
Posts: 50
Reputation: 500

Post » Sat Sep 19, 2015 11:40 am

I think that this problem might be caused by some kind of sample rate error. It sounds to me like the kind of bit crushing / aliasing sounds that you would get when connecting an 48kHz output into a 44.1kHz input. I was wondering if it could be anything to do with a 48kHz sample rate being set after watching a video on the phone? Or maybe even taking a phone call sets the device to a different sample-rate?

Is there any way to reset the audio engine, perhaps using javascript? I've been doing a bit of research on it but it's all a bit too complicated for me. If there was a way to do this then maybe it could help the problem of having no sound after re-opening the app too.
Last edited by shortwave on Sun Sep 20, 2015 8:10 pm, edited 1 time in total.
B
6
S
1
Posts: 50
Reputation: 500

Post » Sun Sep 20, 2015 7:29 pm

Every time I've had this issue it has been switching from an audio heavy app to my game so you might be on the right lines. Though frustratingly I'm not able to reproduce it on demand.
I'd be interested to know your experiences with other export methods.
B
13
S
4
Posts: 65
Reputation: 875

Post » Sun Sep 20, 2015 8:09 pm

Hi, just letting you know I've switched over to Cordova CLI now (which is great and easier than I was expecting), but still getting the same problem with audio. Sometimes no audio at all on re-opening the app, and sometimes really bad bit-crusher type distortion. Only way to fix it is with a restart, or to open another app which plays audio and then switch back to my app (this only works some of the time, maybe related to the sample rate again?). I've now tried frameless browser, phonegap build, intel xdk and cordova cli, and it happens in all of them, next one to check is cocoon, I'll let you know how it goes...
B
6
S
1
Posts: 50
Reputation: 500

Post » Fri Oct 16, 2015 7:46 pm

I've just had the audio corruption presented exactly the same as before using C2 preview so it is not an export bug.

I could repeat it with every preview at the time, closing all the apps in the background fixed the issue, this included rayman run - an obviously audio heavy game.
B
13
S
4
Posts: 65
Reputation: 875

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Sockratease and 4 guests