Search Unity

Strange audio with certain device, but not editor or other devices.

Discussion in 'Android' started by MD_Reptile, Apr 1, 2022.

  1. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I have been testing a game on various android devices, and I notice that with a ZTE Zmax Pro Z981 that the audio clips sounds deep and somewhat strange. This doesn't happen on a variety of other androids or in the editor. Just to verify it wasn't a damaged speaker, I plugged in headphones, but the sound is the same.

    Is this possibly something related to the configuration of that device, or perhaps there is a problem with the way the audio is compressed to memory? I tried turning off compress to memory on the audio clips but this made no difference.

    The sound is sort of like it adds almost a cowbell like filter which is deeper than it should be. Here is a demo, where the first device sounds normal as expected, and the second device is the ZTE with the strange sounding audio (they overlap for a moment so this is probably confusing):



    I have changed around audio settings a bit but nothing seems to make that stop - and the device plays audio normally in other apps (such as youtube), and has been factory reset, so there shouldn't be any odd settings I don't know about.
     
    Last edited: Apr 1, 2022
  2. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    What Unity, Android studio, gradle and Android OS versions?
    Seems as though the most newest are causing problems an varying ways.
    The failures could a large or small domain of error of some sorts.
    I have an Android crash scenario and there seems to be no answers on how to correct.
    Some have tried to reverse versions and that isnt working either.
    Just pointing some things out here for you and all because it is mysterious and varied failures are keeping devs in their own separate corners of grief when it could be something very simple.
    I repaired a previous Android push for the community here due to bad environment paths. It took 2 weeks for a very simple fix. But the headaches were immense to go through all the steps.
    I would be very surprised if logcat showed anything.
    Since the speaker and the ear phones are exhibiting the same distortion then that sounds like a very specific sound or device drive to that manufacturer. It would be interesting to test on a duplicate device if possible.
    Hope this helps.
    P.S. I just went back and listened again. This time it sounds like the first phone is correct. The coin drops and the sound is made like in real life. The second is silent which in the real world the machines are not quiet. I was a pinball junky at one time and used to work on these.
     
  3. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Oh, good point, forgot to mention that I'm on Unity 2021.2.17f1 - and just whatever version of the android tools that the hub downloads with it. The phone that is acting up has android 6.0.1 on it. I've had no problems on various other devices running 8.1.0, or 10, or 12...

    Haha well - I mean perhaps one sounds better or whatever but thats not the issue here - its that the first one (EDIT: original clip changed, second device the problem) doesn't sound like the sound file, or the editor, or other devices I've tested - the issue has nothing to do with the sound being played but that it isn't playing correctly.

    To try and help explain it I've replaced the video with a bit longer clip to compare in the first post. This time the first phone you see and hear - the sound is normal (as I expect it to be from the editor) - while the second phone I launch the app on, it should be clear it doesn't sound the same.
     
    Last edited: Apr 3, 2022
  4. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    For the sake of testing I tried converting all the sound effects from WAV format into MP3 - still not playing right on the ZTE.

    I tested playing a song, and could not notice a huge difference with the audio - and I also tested a short test clip of just a man talking into left side and right side, then center... and that actually sounds fairly normal. It seems to ONLY be my coin sound files that are having this effect, or at least where this problem becomes very noticeable on that ZTE. I'm gonna test this more to isolate if it has to do with the sound files themselves or just project wide sound.

    Still looking for advice or suggestions about what else to try to eliminate this inconsistent sound problem!

    EDIT:
    I found this old thread:
    https://forum.unity.com/threads/audio-quality-issue-on-mobile-platforms.285230/

    Tried that, didn't work (guess that code is deprecated and may not properly apply, I'm not sure).

    So I found another thread about audio problems:
    https://forum.unity.com/threads/audio-manager-system-sample-rate-is-ignored-on-android.486491/

    And here I see they did it differently because that setting had been deprecated, so I tried it the way they did in the first post there - and it does sound better (less cowbell effect haha), but still not identical to the way it sounds on other devices, but close enough (could be differences between speakers and whatnot at this point) - but now I can probably let it go as long as it doesn't have any unusual effects on other sounds in the game.

    Here is the code that seems to mostly work:
    Code (CSharp):
    1.         AudioConfiguration config = AudioSettings.GetConfiguration();
    2.         config.sampleRate = 48000;
    3.         AudioSettings.Reset(config);
    I can't explain what was going on exactly still, I just know the sample rate by default on the ZTE was at 24000 and on the other (normal sounding) android devices its 48000 - so uhh yeah. Case closed.
     
    Last edited: Apr 3, 2022
  5. StinkySteak

    StinkySteak

    Joined:
    Jul 7, 2017
    Posts:
    12
    I Confirm this solution works