AgoraIO-Community / Agora-Audio-Example-iOS

4 stars 5 forks source link

Remote speaker volume is always > 0. Why? #2

Open otymartin opened 3 years ago

otymartin commented 3 years ago

@maxxfrazer In my implementation of the reportAudioVolumeIndicationOfSpeakers delegate method, the volume of the remote user is always greater than 0. On that remote user's local device, it rightfully shows their volume as 0

Here are some logs below

As you can can see below on the local device of the listener, the remote user's volume is never zero forcing my UI to indicate that they are speaking when they are not. Sometimes the total volume is 0 while the speaker's own volume is shown as greater than 0 - I dont know how that worksπŸ€·β€β™€οΈ

On the speakers local device, the callback works perfectly. Their volume is 0 when not speaking.

Here is my initialization method.

        agora = AgoraRtcEngineKit.sharedEngine(withAppId: Key.agoraBuildAppId, delegate: self)
        agora?.enableAudioVolumeIndication(250, smooth: 3, report_vad: true)
        agora?.setAudioProfile(.musicHighQuality, scenario: .gameStreaming)
        agora?.setChannelProfile(.liveBroadcasting)
        agora?.registerLocalUserAccount(currentUser.id, appId: Key.appId.agoraBuild)

LOCAL USER'S LOG'S ON REMOTE SPEAKER'S VOLUME

15:24:12.731 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 135: Total Volume: 140
15:24:12.983 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 22: Total Volume: 11
15:24:15.586 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 84: Total Volume: 88
15:24:15.848 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 45: Total Volume: 28
15:24:16.100 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 8: Total Volume: 11
15:24:16.380 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 46: Total Volume: 49
15:24:16.627 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 18: Total Volume: 11
15:24:16.884 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 67: Total Volume: 70
15:24:17.142 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 49: Total Volume: 14
15:24:17.395 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 48: Total Volume: 53
15:24:23.134 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 28: Total Volume: 35
15:24:23.392 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 7: Total Volume: 7
15:24:25.717 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 18: Total Volume: 18
15:24:26.511 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 7: Total Volume: 7
15:24:28.859 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 115: Total Volume: 140
15:24:29.115 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 102: Total Volume: 102
15:24:29.363 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 0
15:25:08.365 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 22: Total Volume: 25
15:25:08.617 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 2: Total Volume: 0
15:26:21.938 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
15:26:22.200 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 7
15:26:22.474 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:26:22.733 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
15:26:59.125 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
15:26:59.383 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 7
15:26:59.638 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 7
15:26:59.919 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 8: Total Volume: 11
15:27:00.168 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:27:00.422 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:27:00.682 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:27:00.938 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:27:01.220 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:28:49.376 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 15: Total Volume: 18
15:28:49.631 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:28:56.116 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:28:56.391 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
15:28:57.159 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
15:29:06.014 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
15:29:06.269 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:29:06.783 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 3: Total Volume: 7
15:29:20.566 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
15:29:20.819 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 7
15:29:21.118 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 0
15:29:21.352 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
otymartin commented 3 years ago

More debugging of this issue.

On this device is Martin listening to the volume of his own sound I whistled and the volume went up to 230 before going back to 0

15:39:40.809 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 230: Total Volume: 230
15:39:41.044 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 52: Total Volume: 52
15:39:41.300 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 39: Total Volume: 39
15:39:41.557 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 8: Total Volume: 8
15:39:41.792 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 0: Total Volume: 0
15:39:42.047 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 4: Total Volume: 4
15:39:42.302 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 1
15:39:42.557 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 1
15:39:42.793 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 0: Total Volume: 0
15:39:43.051 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 1
15:39:43.307 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 0: Total Volume: 0
15:39:43.560 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 0: Total Volume: 0
15:39:43.796 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 0: Total Volume: 0
15:39:44.052 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 0: Total Volume: 0
15:39:44.307 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 0: Total Volume: 0

On the remote client device listening on me whistle, the volume callback was 220 before coming down to 1. It refuses to hit 0. Also on the remote client, the callbacks stop whenever there is no sound while on the local device, the callbacks continue even if the sound is 0. Dont know if thats a feature or bug.

15:39:41.046 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 220: Total Volume: 196
15:39:41.305 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 115: Total Volume: 42
15:39:41.559 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 50: Total Volume: 39
15:39:41.813 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 14: Total Volume: 18
15:39:42.346 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 2: Total Volume: 4
15:39:42.603 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
15:39:42.860 πŸ’š DEBUG RoomViewModel.observeSpeakers():507 - Martin Volume 1: Total Volume: 4
plutoless commented 3 years ago

the audio data received from remote is encoded/decoded so it might be affected. i would say ignore any volume which is lower than 5, that's usually very close to mute.

otymartin commented 3 years ago

Thanks @plutoless - I noticed a pattern where for local user, the remote user's volume settled at 1,2,3 or 4 at max so I was contemplating ignoring volumes < 5 however didn't have any confidence in that solution until you endorsed it.

:)

otymartin commented 3 years ago

Hi @plutoless @maxxfrazer On playing around with this solution, the problem persists. The volume now gets stuck at higher numbers. Is there any other solution for this issue - kinda makes reportAudioVolumeIndicationOfSpeakers unusable.

Stuck at 7

20:13:13.823 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 4
20:13:16.426 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 1
20:13:44.759 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 7

Stuck at 5

20:14:20.126 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 63
20:14:20.382 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 67
20:14:20.643 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 19
20:14:20.914 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 5

Stuck at 43

20:14:49.758 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 4
20:14:50.804 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 46
20:14:51.060 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 88
20:14:51.315 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin l | 109
20:14:51.593 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 105
20:14:51.847 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 87
20:14:52.108 πŸ’š DEBUG RoomViewModel.observeSpeakers():506 - Martin | 43

And so forth....This is random. other times it goes down below 5.

maxxfrazer commented 3 years ago

@plutoless any further advice on this? I don't know what else to suggest.

Other than adding an RTM layer to the app and sending the local values to the rest of the channel directly, which would work but shouldn't be necessary.

plutoless commented 3 years ago

as i said a very small value can also indicate no volume, this should work in most of cases.

otymartin commented 3 years ago

@plutoless Problem is once I set 4 as the "no volume" threshold, the volume indicator started getting stuck at higher numbers like 7, ...43 e.t.c..

plutoless commented 3 years ago

interesting. do you have the log files? and how did you print the value? if it raise to 43 it usually means it does have this high volume.

otymartin commented 3 years ago

@plutoless Need some time to produce new logs. Will post once I have