jech / galene

The Galène videoconference server
https://galene.org
MIT License
900 stars 119 forks source link

Option for High(er) Quality Audio #130

Closed jakobkilian closed 2 years ago

jakobkilian commented 2 years ago

Hey! Thanks again for this great tool, I am so grateful to be able to use it! One feature would make me very very happy. I will try to describe it shortly:

I have often had the situation where I wanted to share a piece of music. This works well (e.g. via line-in or internal rounding), but the quality is relatively poor. On the one hand because of the 32 kbit bitrate (?) and on the other because Galene (presumably) tries to normalise the volume and the level therefore varies constantly and is therefore sometimes very loud and sometimes very quiet.

My suggestion: A dropdown option for one client to stream audio in high(er) quality. No need for lossless, but a bit better to get the music...

Thanks a lot in advance.

jech commented 2 years ago

Could you please apply the following patch, and see how you like the audio quality? We used to have a setting called studio mode that would do that, but nobody was using it; let me know if it is useful for you, and I'll reinstate it.

diff --git a/static/galene.js b/static/galene.js
index 6480189..dae316c 100644
--- a/static/galene.js
+++ b/static/galene.js
@@ -1280,6 +1280,14 @@ async function addLocalMedia(localId) {
     let audio = settings.audio ? {deviceId: settings.audio} : false;
     let video = settings.video ? {deviceId: settings.video} : false;

+    if(audio) {
+        audio = {};
+        audio.echoCancellation = false;
+        audio.noiseSuppression = false;
+        audio.channelCount = 2;
+        audio.latency = 0.01;
+        audio.autoGainControl = false;
+    }
+
     if(video) {
         let resolution = settings.resolution;
         if(resolution) {
jakobkilian commented 2 years ago

Hi jech, thanks a lot for sharing the patch! I have just found time to test it and it is pretty much what I imagined. I would definitely use it on a regular basis if there would be an UI option and I think I will install an instance including the patch to use it right away. However, the quality could still be better to really listen to music. Is there an easy way to tweak the bitrate used for the audio stream, like it is done with the video bitrate in other parts of static.js? That would be awesome. Never mind if this is getting to complicated. best, J

jech commented 2 years ago

I would definitely use it on a regular basis if there would be an UI option

Sure, no problem adding a bunch of checkboxes to the side menu.

However, the quality could still be better to really listen to music. Is there an easy way to tweak the bitrate used for the audio stream, like it is done with the video bitrate in other parts of static.js?

It is easy to reduce the bitrate (which is what we do for the video), but I haven't found any useful way to increase it.

jech commented 2 years ago

It seems I was wrong. What happens if, in addition to the previous patch, you apply the following:

diff --git a/static/galene.js b/static/galene.js
index 9b1fca0..4d6244b 100644
--- a/static/galene.js
+++ b/static/galene.js
@@ -1189,7 +1189,11 @@ function setUpStream(c, stream) {
                     scaleResolutionDownBy: 2,
                     maxBitrate: simulcastRate,
                 });
-        }
+        } else {
+            encodings.push({
+                maxBitrate: 512000,
+            });
+        };
         let tr = c.pc.addTransceiver(t, {
             direction: 'sendonly',
             streams: [stream],
jakobkilian commented 2 years ago

Thx a lot! Can't make out a quality loss anymore. A more important thing that I noticed is, that audio is mono only. Again the question (couldn't figure it out from the .js): is this a setting only or a structural thing that can not be changed quickly?

jech commented 2 years ago

Done in 3c98e1522927be78ad94bb78fde66f89aab13eda

jech commented 2 years ago

The patch I sent you was trying to enable stereo, for some reason it didn't do anything. Perhaps more experimentation is needed.

jakobkilian commented 2 years ago

kk, I will also try to get a bit deeper into it and will inform you, if I find a possible way.