JoJoBond / 3LAS

Low Latency Live Audio Streaming
GNU General Public License v2.0
90 stars 23 forks source link

iOS 15.7.3 No volume control & mute #22

Closed RuhanSA079 closed 1 year ago

RuhanSA079 commented 1 year ago

Hello, Seems like after loading a audio stream (PCM) from my Raspberry Pi, that the audio plays flawlessly, and with minimal latency, which I like.

The only problem now, is that my iOS device is producing an occasional click, does not manifest on the other WebRTC clients such as on Linux and Android. I tested iOS's Safari, Chrome and Firefox apps, which it seems to manifest. Sounds something iOS related? It will click once or twice every now and then. Do you have an idea on why that could happen? I tested with a Bluetooth audio device as well, seems to be present there, too.

Besides this, seems like the volume control is not working on my iOS device. It works fine on the other platforms. Any idea how I can fix this?

JoJoBond commented 1 year ago

Hi,

playback wise I would also suspect it to be an issue with iOS. Since when using WebRTC, there is very little you actually touch regarding audio data. You could try stripping the functionality down to a bare minimum and see if that helps. Regarding controls: Can you try changing the audio tag in the index.html to show controls <audio id="audioTag" controls></audio>, and check if the volume control of the audio tag works as expected?

RuhanSA079 commented 1 year ago

Hi,

playback wise I would also suspect it to be an issue with iOS. Since when using WebRTC, there is very little you actually touch regarding audio data. You could try stripping the functionality down to a bare minimum and see if that helps. Regarding controls: Can you try changing the audio tag in the index.html to show controls <audio id="audioTag" controls></audio>, and check if the volume control of the audio tag works as expected?

Hello there. It seems after the modification of the <audio id="audioTag" controls></audio> HTML tag, iOS gives me a small play/pause button, text with "Live Broadcast", a speaker and a "casting" button. Tapping the speaker icon, seems to mute the volume, and tapping it again unmutes it. Urgh, why does Apple seem to do things differently, gives me constant headaches.

I even tried the document.getElementById("audioTag").volume = xx call in the mute and unmute functions in the main.js file, even that does not work, unless I'm doing something wrong?

RuhanSA079 commented 1 year ago

Upon further testing on Linux and Android, there seems to be a "click" noise too. Let me see if I can test with a wav or mp3 file, to see if its got to do with 'ffmpeg' or the sound capture card I'm using.

JoJoBond commented 1 year ago

You could also try to run ffmpeg with a sine generator as shown in the test.bat file (commented out). Regarding volume control I found this: https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW11

On iOS devices, the audio level is always under the user’s physical control. The volume property is not settable in JavaScript. Reading the volume property always returns 1.

RuhanSA079 commented 1 year ago

You could also try to run ffmpeg with a sine generator as shown in the test.bat file (commented out). Regarding volume control I found this: https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW11

On iOS devices, the audio level is always under the user’s physical control. The volume property is not settable in JavaScript. Reading the volume property always returns 1.

Will test the sine function, thanks. Around the volume control/mute controls, I added these to my mute and unmute events: OnMuteButtonClick(_ev) -> document.getElementById("audioTag").muted = true; OnUnmuteButtonClick(_ev) -> document.getElementById("audioTag").muted = false; Sad about the volume control, but really does not bother me that much, but at-least the mute works.

JoJoBond commented 1 year ago

Good to know about the iOS issue. I will have to modify the controls to match the behaviour.

RuhanSA079 commented 1 year ago

I narrowed down the clicking noise to the USB audio "grabber" card, goes by many names. Was only $10. It's one of these: https://digitnow.com/products/digitnow-usb-audio-capture-card-grabber-for-vinyl-cassette-tapes-to-digital-mp3-converter-support-mac-windows-10-8-1-8-7-vista-xp

I replicated the issue by plugging it in my Linux machine, and played a clean test 500hz test tone from my Android smartphone, used arec -r -d <pa device source ID> --latency-msec=1 | pacat -d <pa device sink ID> --latency-msec=1 to play the audio to my speakers (HDMI display with onboard speakers), and I heard the clicks. I think I shouldn't have blamed it on iOS squarely.

Updated the issue's title. Since I'm using a Raspberry Pi 3, I thought to make this a headless 3LAS system for the live translation of the church's service for some of the congregants.

Do you know of any other better alternative USB/i2s audio-in cards that can work for my use-case? I'm just trying to get some audio in from a line-level audio output, to 3LAS.

JoJoBond commented 1 year ago

My use case is similar. But we have a dedicated x86-64 server to host everything. We use a RME HDSP (Hammerfall DSP) 9652. I would first try to check if you have a sample rate conversion issue. Input sample rate must be 48kHz. I don't know your budget, but if you are looking for an affordable ADC the Zoom U-22 is OK (windows drivers are terrible). ESI Neva Uno is also quite good, but more pricey. The Raspberry will be limited on the number of clients it can serve (I would estimate about 10-15 max). I will try to reproduce the issue in the coming day.

RuhanSA079 commented 1 year ago

My use case is similar. But we have a dedicated x86-64 server to host everything. We use a RME HDSP (Hammerfall DSP) 9652. I would first try to check if you have a sample rate conversion issue. Input sample rate must be 48kHz. I don't know your budget, but if you are looking for an affordable ADC the Zoom U-22 is OK (windows drivers are terrible). ESI Neva Uno is also quite good, but more pricey. The Raspberry will be limited on the number of clients it can serve (I would estimate about 10-15 max). I will try to reproduce the issue in the coming day.

I tested the sample rates, were clicking on 44.1kHz and 48kHz. Defs a USB soundcard issue. Even had some audio dropouts on 44.1kHz. Seems the ESI Neva Uno looks like something we might need, not too pricey, (budget is allowing that) the only problem is get one locally. Or, would look to install on a older x86 board with onboard line-in, maybe could repurpose my ageing computer gathering dust. I'm not worried about the number of clients, I doubt it will be more than 10.

This whole system is to avoid a 1000 USD system, which I cannot justify the cost for 4 or 5 people going to use the system once in a week, 2 hours at a time.

Thanks.

JoJoBond commented 1 year ago

Those ADC were just examples, devices that I know work fine. If you buy something from a 'name brand' you should be good as well. E.g. M-Audio, ESI, Zoom, Behringer, Swissonic, Miditech, Presonus, Sirius, Roland, Rode, Steinberg, Mackie, Sure, Native Instruments, Focusrite etc.

JoJoBond commented 1 year ago

We ran our system again over the weekend with no problems. I was able to confirm the issue with iOS. Please check up commit 8db12b8a7f9e6cfdfbbb9b5d94e2ea4813ae7dd3 and see if it solves the issue.

RuhanSA079 commented 1 year ago

We ran our system again over the weekend with no problems. I was able to confirm the issue with iOS. Please check up commit 8db12b8 and see if it solves the issue.

Hi, seems to be working on my iOS 15.7.3 iPhone 7. Thanks for the fix.