-
Notifications
You must be signed in to change notification settings - Fork 801
Channel balance correction. #682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I see the check failed. I do not know how to correct the problem. The code works for me correctly on a latest raspbian on a raspberry pi 4. |
|
I should probably explain the idea behind using this feature: Let's say an amplifier outputs left channel a little bit louder, i.e. the sound is shifted to the left. Then I start librespot with:
Then when I change the volume in my spotify client, the final volume in alsamixer is 1 dB less on the left channel than on the right channel. Ultimately, if I set the volume to max (100%), the left channel plays at -1 dB and the right channel plays at 0 dB, solving the amplifier potentiometer problem. |
Just run Btw is it possible that your commit mail address does not match your github mail address? |
When I run it on my raspberry pi, the command succeeds with no errors.
Maybe, I am sorry for that. |
And hopefully, some files have changed now. If so, just commit them. Otherwise I don't know what happens here. |
|
Every change I made is in the commit. It compiles and works for me with no problem whatsoever. Is there anything else I can try to solve the problem? |
|
I don't doubt it compiles, it's just the formatting that does not match the rules. Usually, |
|
You were right! Thank you! I didn't know it worked like that. This is my first time with rust. Hopefully it works now :) |
|
With thanks for your contribution, I am doubting several points:
Now in the scenario that this should be in core:
|
I thought outputting directly to ALSA's
Both are definitely valid points, unfortunately outside of my scope of skills I'm afraid. |
Today you are right that doing digital volume control in Alsa gives the highest transparency. After #660 this will not matter anymore if you set output to 32 or 24 bits. Other "intermediate" sinks like GStreamer and PulseAudio add some "weight" and probably a tiny bit of latency due to buffering. You probably won't notice on even the lowest denominator of hardware.
I'll look into cubic Edit: pointy hat to me, I had not noticed log volume control to be in spirc. |
Thank you.
Maybe if someone would be so nice and write up an example of how to level balance using ALSA, or some other backend, ideally with highest transparency possible. I couldn't find any other solution. Luckily this little idea I came up with works, but it wouldn't work with a DAC that does not have volume control (for example, my Aune X8 DAC has no volume control). I have no idea how I would level balance with that DAC. |
It's not pretty but you could split the left and right channels and then route them though 2 separate sofvol ALSA plugins naming them "Left" and "Right" (or really whatever you want) and them merge them again into another softvol named "PCM" (important most apps expect the main volume to be named "PCM or "Master") if you want balance and volume control for a DAC with no such hardware controls. And as @roderickvd said with 24 or 32 bit you loose nothing as far as fidelity with software volume control in fact it's objectively better than any sort of hardware volume control. Edit: Scratch that I'm pretty sure the softvol plugin is capable of balance control without crazy routing. I have a DAC without hardware volume control. I'll be back in a bit. |
|
Here is a script I wrote a while back that allows you to add software volume to a DAC that lacks hardware volume control. As I suspected it works that same as hardware controls as far as left/right balance control so There are also command snippets to find your card, list it's available sampling rates and formats, and the available sample rate converters. It's pretty self-explanatory just paste it into https://gist.github.com/JasonLG1979/f29cb0f14218a3b20db5d32c2cfae5ed If you want to rename the volume control for what ever reason and you want to delete the old control you'll need to do that manually as ALSA doesn't do it automatically. This page has instructions on how to delete unused software controls: https://dquinton.github.io/debian-install/helps/18-volume-boost.html |
|
I'm not sure librespot is the place for this. Given that we're trying to go down the path of less audio processing, this feature feels unnecessary, especially given that it can, and probably should be handled downstream, mainly because the imbalance in this case is itself coming from user equipment as opposed to something that librespot does. |
|
I'm gonna go ahead and close this PR. While I certainly appreciate your work, I think it is beyond the scope of this project to do DSP to work around equipment issues downstream. @JasonLG1979 left instructions how to do this in Alsa, earlier I posted an option on GStreamer. |
This is a very simple addition to librespot which allows users to correct channel balance without any quality loss directly through alsa mixer, as long as their DAC allows such feature.
I am running a FiiO E10K DAC, which outputs its analogue signal into a Xduoo MT-602 tube amp. The amplifier, being a quite cheap unit, has a very slight channel imbalance, which bugs me a lot.
This is a very neat way of correcting such channel imbalance.