Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound is very low on iPhone #131

Closed
AvinashP opened this issue Nov 15, 2018 · 20 comments
Closed

Sound is very low on iPhone #131

AvinashP opened this issue Nov 15, 2018 · 20 comments

Comments

@AvinashP
Copy link

I have integrated Dissonance with Photon Unity Networking. Most of the settings are kept to default. I have set Channel volume to max (2) in Voice Broadcast Trigger. The sound is super low on iPhone. Unless we use earphones, it's not audible.

I tried to set Audio Quality to HIgh, but still no effect. Am I missing something?
What could be the issue?

@martindevans
Copy link
Member

  • Have you tried this with several microphones (on a different platform if possible)? That will narrow down if this is a recording error (recorded sound is too low) or a playback error (playback sound is too low).
  • Can you reproduce this error when running in the editor, or is it only when running on the iPhone?
  • Are you using a custom playback prefab? If so, is the level too low on the custom AudioSource?
  • If you play another sound with an AudioSource is it at a more reasonable level?

As a quick workaround for this you could try using a custom playback prefab, sending the voice to a mixer and applying a compressor to boost the quiet sound. This probably shouldn't be necessary though!

By the way sorry for the slow reply - I typed this out yesterday but forgot to send it until now!

@AvinashP
Copy link
Author

Hi, Thanks for your response.
The issue is only happening on iPhone. It works perfectly on Android.

  • I tried using playback prefab with an audio mixer. No effect on the sound.

I found that there is some issue with iPhone speaker and Unity
Issue:
https://issuetracker.unity3d.com/issues/ios-audio-will-be-played-from-earspeaker-if-microphone-dot-start-is-used
Fix:
https://github.com/10people/UnitySpeakerFix

Can you take a look because I can not see the code of Dissonance plugin?
We need to call
iPhoneSpeaker.CheckiOSPrepare();
before
Microphone.Start()

Then
iPhoneSpeaker.ForceToSpeaker()
after
Microphone.End()

@martindevans
Copy link
Member

I found that there is some issue with iPhone speaker and Unity

Ah yes that issue has been a persistent problem for Dissonance. I'm excited to see that it's now marked as "fix in review" - hopefully that will finally be fixed in 2019.x.

Can you take a look because I can not see the code of Dissonance plugin?

I'm not sure what you mean - Dissonance is always distributed with the complete source code.

We need to call....

To insert those calls I would suggest creating a custom microphone capture class for Dissonance. You should be able to inherit from Assets/Plugins/Dissonance/Core/Audio/Capture/BasicMicrophoneCapture.cs and simply insert your calls into the StartCapture and StopCapture methods in the correct places. Something like this:

class FixedIosMicrophoneCapture
  : BasicMicrophoneCapture
{
    override WaveFormat StartCapture(string name)
    {
        // Do this before mic is started
        iPhoneSpeaker.CheckiOSPrepare();

        // Now invoke the usual mic starting behaviour
        return base.StartCapture(name);
    }

    override void StopCapture()
    {
        // Invoke normal mic ending behaviour
        base.StopCapture();

        // Do this after mic is stopped
        iPhoneSpeaker.ForceToSpeaker();
    }
}

To do this you will need to modify the methods in the base class to be virtual.

@AvinashP
Copy link
Author

AvinashP commented Nov 22, 2018

I implemented new Component. It's still not working. Either the fix provided in UnitySpeakerFix is not working or there is some other issue. I am using Unity 2018.2.5f1. I will try it in a sample project. Can you please try it on your side as well.

I wonder why no one else has faced this issue with Dissonance on iPhone.

public class MGMicrophoneCapture : BasicMicrophoneCapture {

    public override WaveFormat StartCapture(string inputMicName)
    {
        // Do this before mic is started
        iPhoneSpeaker.CheckiOSPrepare();

        // Now invoke the usual mic starting behaviour
        return base.StartCapture(inputMicName);
    }

    public override void StopCapture()
    {
        // Invoke normal mic ending behaviour
        base.StopCapture();

        // Do this after mic is stopped
        iPhoneSpeaker.ForceToSpeaker();
    }
}

@martindevans
Copy link
Member

Can you please try it on your side as well.

Unfortunately I can't, I don't own an iPhone :(

Either the fix provided in UnitySpeakerFix is not working or there is some other issue.

Do you have the issue described by UnitySpeakerFix? i.e. When Dissonance is started audio switches to the earphone. If so I know other people have had this issue and UnitySpeakerFix has worked for them, so we'll need to look into that.

If not then is the problem that audio stays on the iOS speakers, but is extremely quiet? If so how does other (non-voice) audio sound if you create a blank scene without Dissonance and just an AudioSource playing some music? How about if you add a button which just calls Microphone.Start(), does the audio change when you press the button?

@AvinashP
Copy link
Author

AvinashP commented Nov 27, 2018

Do you have the issue described by UnitySpeakerFix?

I am not too sure if that's the same issue because the fix is not working. I can't hear voice chat either on the speaker or earphones. It perfectly works on Android. We have other issue of too mcuh Echo there.

How about if you add a button which just calls Microphone.Start(), does the audio change when you press the button?

I tried it and it does reduce the volume of overall game. Everything plays well and loud as soon as I start Dissonance on a button tap (which calls Microphone.Start). Overall volume becomes very low. I can't hear any voice chat.

@martindevans
Copy link
Member

Do you have the issue described by UnitySpeakerFix?

What I mean by this is do you have the problem that when Microphone.Start is called Unity audio switches to earpiece speaker? So sound changes from here (primary speaker):

iphone_6_speakerphone_loudspeaker_repair_2

to here (earpiece speaker):

iphone-6-ear-speaker-replacement-lovefone-london_large

That's the problem UnitySpeakerFix is designed to fix.

@AvinashP
Copy link
Author

I got the sound working by Removing UnitySpeakerFix and enabling "Prepare for iOS recording" and "Force iOS Speaker while recording" unity build settings.

image

Now the issue is Echo. I have recorded the video of my game with Voice Chat enabled. Below are the Dissonance Voice Settings.

image

Here is dropbox link to video

https://www.dropbox.com/s/j9hs1chuvq7at90/VoiceChatWithEcho_480p.mov?dl=0

can you please suggest what might be wrong or i need to change something. This also happens on Android. It would be best if you had any working sample for iOS or Android.

@martindevans
Copy link
Member

enabling "Prepare for iOS recording" and "Force iOS Speaker while recording" unity build settings.

I've not seen those settings before, it looks like they were added in 2018.1. I'll update the documentation to note that you should enable these if you're using an appropriate Unity version. Thanks for telling me about that 👍

Can you confirm if the Mute button on the iPhone still works after you have done this? (#95)

Now the issue is Echo.

Have you checked out the section on iOS at the bottom of the AEC docs?

This also happens on Android

Unfortunately we have encountered a confirmed bug in Unity itself which is breaking the AEC on Android (#110). We're still waiting for Unity to fix that.

You should consider lowering Audio Duck Attenuation to a lower value, this is worthwhile on any platform with speakers+microphone even when AEC is working. It automatically reduces the volume of remote voices when the local voice is being transmitted.

@AvinashP
Copy link
Author

AvinashP commented Dec 10, 2018

I have still not been able to make Echo cancellation work.

Can you confirm if the Mute button on the iPhone still works after you have done this?

Mute button doesn't work after enabling these settings.

Have you checked out the section on iOS at the bottom of the AEC docs?

I implemented Audio mixing and passing all voice and sound through this channel. I used AudioPluginInterface.h to resolve "Echo Cancellation could not be found" issue.

I used Unity Pd plugin as well but same results. I am attaching screenshots of my settings

image

image

Here is Unity Pd
image

@martindevans
Copy link
Member

  • Does the echo cancellation work in editor?
  • I don't know much about UnityPD. What exactly does that do?

@AvinashP
Copy link
Author

AvinashP commented Jan 15, 2019

Sorry for late post on this. We shipped our game without voice chat. Now i am trying it back again.

Does the echo cancellation work in editor?

I tried playing a sound on Audio Source which was going through mixer having Dissonance echo Cancellation. It worked. Below is the screenshot
image

Then i tried between iPhone and editor. I could hear the voice clearly on editor. Below is the screenshot of Audio mixer on Editor for this scenario
image

I don't know much about UnityPD. What exactly does that do?

Someone mentioned this in Issue #80.

I am not gettting any worning in xCode logs and the setup seems correct. Its still not working between iOS devices.

Can you please try one iOS sample? I know you don't have a device but if you could arrange one to just run once. You would know the issue. I am sure this is not working for anyone on iOS. Or if it is then please share any demo or link to the game.

@martindevans
Copy link
Member

That reference to UnityPD was the way they've integrated their plugin into the Unity Audio pipeline. I included some instructions here (at the bottom of the page) based on that - have you tried that?

@AvinashP
Copy link
Author

Yes, I have integrated required code to load audio plugins correctly. Here is the code required for Xcode

#import "AudioPluginInterface.h"

  • (void)preStartUnity
    {
    NSLog(@"////////PRESTART UNITY OVERRIDE////////");
    UnityRegisterAudioPlugin(&UnityGetAudioEffectDefinitions);
    }

I have created a sample voice chat Unity project with Photon Unity networking. It's having same issue.
I have sent you google drive link to [email protected]. Please take a look.

@martindevans
Copy link
Member

Thanks for the reproduction project, that will be very helpful. I'll get @TomGillen to borrow an iOS device to have a look into this as soon as possible.

@AvinashP
Copy link
Author

Thanks for the reproduction project, that will be very helpful. I'll get @TomGillen to borrow an iOS device to have a look into this as soon as possible.

Hi Martin, is there any progress on this. Let me know if you need any help running and exporting that demo project. Below is the link of plugin fix you need to put in Xcode project

DissonancePluginFix.zip

@TomGillen
Copy link
Contributor

Thanks for that; I've just found time to take a look at this now.

@martindevans
Copy link
Member

Tom and I have been looking over this yesterday and today and we haven't been able to reproduce the problem.

We commented out the UnityRegisterAudioPlugin to disable the AEC and there was a lot more echo (echo was crystal clear and quite loud). Commenting it back in significantly reduced the echo to the level of quiet background murmur.

Tom suggested this could be a test setup problem - if the second device can hear the first person speaking (i.e. the two test devices are within hearing range of each other) then the echo canceller will never converge because it can hear the remote speaker on the local mic (also you will get terrible feedback loops which the AEC will not try to resolve). Could this be the problem?

@AvinashP
Copy link
Author

AvinashP commented Feb 2, 2019

Hi,

You are correct. Feedback loop is the issue. If we test it from different locations (or rooms). Echo cancellation works. When we are in audible range or playing game from same room, feedback loop makes it terrible.

Thanks a lot for your support. And sorry for this long thread.

@martindevans
Copy link
Member

Hi Avinash, I'm glad we finally managed to sorted this out for you!

I'll close this thread now. If you're happy with our support please consider giving us a review on the asset store, it really helps us out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants