Voice crackling / clicking on iOS

Numa
Numa
edited April 2020 in Photon Voice
Hi!

Whenever we chat, the audio is crackling constantly (1-2 times per second). We can understand each other fine but it sounds like someone is typing on a very loud keyboard as we speak. This seems to only happen with the Photon type microphone. Unity type is fine but the echo is impossible so not an option for us (unless you know of a way to fix the Unity type mic echo?).

I'm using photon type microphone and VoIP preset, Voice 2.13, Unity 2019.2.21f1
Server protocol is set to UDP.
Prepare iOS for recording: enabled
Force iOS Speakers when Recording: enabled

I have tried:
- removing the Mic Amplifier (as suggested in another post): no effect
- frames 10/20/40ms: no effect
- bitrate from 30k to 10k: no effect
- sampling rate 48k, 24k, 16k, 12k: no effect
- VAD threshold: 0.01, 0.05, 0.1: no effect
- reliable mode: no effect

I don't think it is a bandwidth problem (100mbps wifi network)

I saw some older post talking about "Play Delay ms", does it still exist? is it the VAD Delay (ms) ? What about Update Interval(ms)?

Would love to fix or even reduce the crackling a bit!

Thanks

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Numa,

    Could you record this "constant crackling" so we get a perfect idea of the issue?
    Does this happen in the Unity Editor?
    Doe this happen when using headphones / earpieces?

    Does this happen with the demo scenes?
    In DemoVoiceUI we make use of WebRtcAudioDsp which has some options like VAD, Noise Suppression and AGC, could you try those? you could add WebRtcAudioDsp to your scene as well (same GameObject as Recorder).

    "Play Delay" is a Speaker setting.
  • Played with all the DSP settings, no change.
    It happens in the demo scene too, here's a fun recording:
    https://drive.google.com/file/d/1hKW3XJFSxBJDiIq_k3XlgblI-Rke8u-m/view?usp=sharing
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Numa,

    Thank you for taking the time to record the video

    My colleague @vadim has tried to reproduce and has the following comments and suggestions to try:

    - DebugEcho is disabled, so the issue could be from the other device recording, not sure which device are you using for that. So maybe use voice from the iPhone only with DebugEcho enabled.
    - Take a look at the logs, optionally increase log level for the Recorder, Speaker (prefab) and VoiceConnection. See if you can spot a warning.
    - All WebRtcAudioDsp options are enabled which could lead to eating up a lot of the CPU and also it is not recommended to use WebRtcAudioDsp's VAD with Photon MicrophoneType (there is a warning in the Unity Editor already, we will hide the option from the build in the future when Photon MicrophoneType is chosen). So maybe disable all DSP options first and add AEC or Noise Suppression or AGC if you want later.
  • thanks, I'll try that and get back to you.
  • Numa
    Numa
    edited April 2020
    Hi,
    I tried with one iphone only with DebugEcho ON (very handy btw!) and the same problem still occurs.
    This is with all default settings in the demo + Photon microphone + all the DSP options disabled. I speak, and I hear that crackling sound like the recording I posted.
    I got these warnings:
    [AudioInEnumerator] PhotonVoice: Can't create instance of AudioInEnumerator: Current platform is not supported by AudioInEnumerator.
    [Scripts.WebRtcAudioDsp] WebRTCAudioProcessor AEC: output sampling rate 24000 != 48000 capture sampling rate. For better AEC, set audio source (microphone) and audio output samping rates to the same value.
    

    Where do I set the output sampling rate? I can't find anything on the speaker script.

    I also get a lot of these warnings:
    [PV] Remote AudioOpus v#2 ch#0 p#2 evNumer: 97 playerVoice.lastEvNumber: 93 missing: 3 r/b 38
    [PV] Remote AudioOpus v#2 ch#0 p#2 evNumer: 142 playerVoice.lastEvNumber: 139 missing: 2 r/b 31
    [PV] Remote AudioOpus v#2 ch#0 p#2 evNumer: 6 playerVoice.lastEvNumber: 4 missing: 1 r/b 32
    [PV] Remote AudioOpus v#2 ch#0 p#2 evNumer: 246 playerVoice.lastEvNumber: 243 missing: 2 r/b 34

    Are you able to reproduce this on your end?
  • bump
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Numa,

    you can ignore the warning.
    Make sure you have a good internet connection and you connect to the closest Photon region.
    Then check the loss counters, maybe it's high and causes the clicking.
    Check VoiceConnection.FramesLostPerSecond / FramesLostPercent or total: VoiceConnection.VoiceClient.FramesLost.
    Otherwise, update to latest Photon Voice version as it contains an optimization fix for iOS Photon MicrophoneType.
    If the issue persists it could be due to CPU usage being high, what devices did you try this on?
  • This happens on an iPhone XS in your demo scene, 100% of the time, even with one user only (echo debug ON) as soon as the demo starts, so I'd be surprised if it was due to performance.
  • Numa
    Numa
    edited April 2020
    It turns out that warning was important:
    [AudioInEnumerator] PhotonVoice: Can't create instance of AudioInEnumerator: Current platform is not supported by AudioInEnumerator.
    [Scripts.WebRtcAudioDsp] WebRTCAudioProcessor AEC: output sampling rate 24000 != 48000 capture sampling rate. For better AEC, set audio source (microphone) and audio output samping rates to the same value.
    
    Unity's default output sampling rate was different to the iphone's recording rate and it looks like the conversion was causing the problems. What I did was set Unity's output rate to 48k (Project Settings -> Audio -> System sample rate) to match the iPhone microphone and now the audio is great!

    This should probably be in your doc somewhere :smile:
  • Numa - did you set it to 0? or did you set it to 48k?

    We seem to have the same issue - iphone x,8,6 sounds similar to what you describe, but on desktop/iphone 11 it sounds great
  • Numa
    Numa
    edited April 2020
    It was set to 0, I set it to 48000. Maybe it should get set at runtime depending on the platform / device.
  • Hmm - ok
    Mine was set to 16000, I changed it to 0 and now it works better on iphone 6.
    iphone 8 I still get this weird crackly popping noise...
    Something seems funky....
  • mm weird! You could have a look online and see what frequency each device records at. Or turn on the logging for all the photon voice components and look for warnings similar to mine when running the app in xcode, if there's a mismatch it'll tell you what you should set it to.