Closed LW-archlinux closed 7 years ago
Audio output works, but there are issues with volume control. It's absent. When Firefox detects PulseAudio it asks it to control sound volume. At the moment apulse have no volume control at all, and therefore volume controls on audio players in Firefox don't work.
I want to address that issue before declaring another release.
I hope it's not a big deal to change volume by ALSA and implement PA API. Am I right?
I hope it's not a big deal to change volume by ALSA and implement PA API. Am I right?
Well, yes and no.
I did a web search, but found no way of controlling volume of a single pcm context. There is a softvol plugin, but I can't figure out how to use it in software. Its entry points are exposed by libasound.so.2, but there are no function prototypes in headers, so that's internal fragile interface. Also there are conceptual difficulties with controls. As far as I understand, user must create and destroy controls. So, I'm confused.
On the other hand, volume changing could be done manually by multiplying each sample value by a number. That's tedious, error-prone, slow. But clear, at least. :-)
And one more thing. Last time I tried to implement volume-related API part, Skype turned volume to almost zero, and effectively stopped capturing any sound. That's why part wasn't implemented two years ago.
check how alsamixer works :)
check how alsamixer works :)
It's required to have per-context, or at least per-process volume control. Say, there are two applications running, using PulseAudio API. One says "I want my volume set to 100%", other says: "I want my volume set to 15%". Can ALSA mixers do that? Last time I checked, there were no per-process volume control in alsamixer
.
Am I missing something? Could you elaborate on that, please?
Implemented volume scaling in software, per-context. Far from optimal, but should work.
Also just made a release: https://github.com/i-rinat/apulse/releases/tag/v0.1.8
@i-rinat Thank you so much for this release! I just tested it here (GoboLinux, Firefox 52 32-bit, apulse 0.1.8, no PulseAudio installed) and testing a YouTube video, Firefox plays the audio perfectly, but the video becomes choppy (like <10fps) and a little jittery. The CPU consumption doesn't seem to be a lot higher (the four virtual cores in my dual-core hyperthreaded i7-4500U laptop stabilize at about 20% each, with or without apulse).
Let me know if you need more information, and if I should open a separate issue. Thanks!
Let me know if you need more information, and if I should open a separate issue.
I've just tested it, and also see the issue. Created #45 to track it.
I've always been taught that you should use some sort of logarithmic function instead of multiplying by constant when dealing with audio volume. Of course, if the values are already logarithmic (based on decibels, for instance) that wouldn't matter.
But, if using a constant produces less fine volume control, maybe looking up some logarithmic functions for audio amplitude would be appropriate.
@trlkly, as far as I understand, PulseAudio volumes are linear inside, despite documentation says they are logarithmic. But there are special functions available in API, that translate slider position from [0, 1] to internal volume, and backwards, from internal volume values to slider position. And surprisingly, functions used are not logarithm or exponent. It's cube and cubic root.
PulseAudio does this after http://www.robotplanet.dk/audio/audio_gui_design/, so I decided to use similar formulas.
There are could be errors in implementation, since I'm not an expert in audio processing. I did some experiments though, and think that current formulas are fine. Better than just using linear mapping.
There were couple of bugs, so here is another bugfix release: https://github.com/i-rinat/apulse/releases/tag/v0.1.9
Mozilla decided to deprecate alsa support from firefox 52. I used arch linux aur apulse-git[1] package, and tested with firefox-52.0-1 .
[2] was used to test things, and apulse-git succesfully made firefox believe pulseaudio was present. Every test succeeded.
I intend to install apulse on several other AL systems i help maintain, but convincing the owners would be easier with a recent stable release.
Thank you for this program.
[1] https://aur.archlinux.org/packages/apulse-git/ [2] https://hpr.dogphilosophy.net/test/