No and this is what is sad and embarassing: I just coded something stupid and happily wrote the same... as said, I'll probably stop for a while
I just went for the simplest (or stupidest) but I think this does not matter much. The span of 25 is very arbitrary anyway. Do you really think that having the same ratio whatever the volume is will produce such an unpleasant effect, i.e. balance will sound good at some volume but bad at others?
Thx
Results 51 to 60 of 64
Thread: Balance
-
2021-03-01, 18:47 #51
- Join Date
- May 2008
- Location
- Canada
- Posts
- 6,937
LMS 8.1.x on Odroid-C4 - SqueezeAMP!, 5xRadio, 5xBoom, 2xDuet, 1xTouch, 1xSB3. Sonos PLAY:3, PLAY:5, Marantz NR1603, Foobar2000, ShairPortW, 2xChromecast Audio, Chromecast v1 and v2, Squeezelite on Pi, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5, RivaArena 1 & 3
-
2021-03-01, 19:09 #52
- Join Date
- May 2006
- Location
- Silicon Valley
- Posts
- 644
Philippe, your mistake is one that anybody could have made, anybody, easy to do. It is NOT a big deal whatsoever!
Things like this happen all the time. When you commit code, we are your QA/Testing department, and we love to do it!
I remember one of my "company name removed" stories, about somebody driving a probe into the surface of Mars waaaaaaaaay too fast, due to a trivial math errorThat blemish mankind left on Mars might be there for millions of years. And now, I would like to introduce you to some self-driving automobiles!
Last edited by Ron F.; 2021-03-01 at 19:20.
Living Room: SB Touch + DIY PSU > CI Audio VDA.2 DAC + VAC.1 PSU > VRX.1 cables > Emotiva XSP-1 Gen 2 preamp + XPA-DR2 amp > Blue Jeans cables > B&W 804 speakers
Laptop: System76 Galago + Ubuntu 16.04 + Squeezelite + Vivaldi/Material Skin > Emotiva Little Ego DAC > Grado PS500 headphones
Bedroom: RPi Zero W + Squeezelite > miniBOSS DAC HAT > Bose SoundLink Revolve
Phone: Pixel 3a + SB Player + Material APK > Senn IE80 earbuds
Server: Puget Systems Serenity + Ubuntu 18.04 + LMS 8.2
-
2021-03-01, 19:21 #53
- Join Date
- Jun 2017
- Posts
- 415
Philippe, I don't want to make light of your distress. I sort of understand, even though I'm not capable of doing the work you're doing on LMS. I think you certainly should take a break, not as punishment, but just to have an opportunity to take a few deep breaths and think about things other than code for a while.
But with all that, I'm still the sort of guy who can't resist a setup like this, so I hope you'll at least get a smile out of it:
Code:Relax, man! It's just a mistake! No need to get all UNBALANCED about it!
LMS 8 nightly running on Raspberry Pi OS. Mostly virtual players, occasionally with SB Radio, Boom or Classic.
-
2021-03-01, 19:56 #54
I'm not saying that the ratio matters, 25 is fine. It's the values that are being sent by the server do not increase or decrease in a linear manner. They follow the progression of that list of numbers and there are 101 values. So, for example, it you set the volume to 96, instead of sending 65536 * 0.96 = 62914, it sends 52224. So when the player receives the value, instead of just dividing the raw value by 65536 to get the gain, it looks for the closest value in the array and uses the index of the item as the gain.
Edit: I was assuming 100% volume, so that formula was wrong.Last edited by wt0; 2021-03-01 at 20:37.
--------------
Squeezebox apps for webOS, Android and Windows Phone, http://www.angrygoatapps.com
-
2021-03-01, 20:50 #55
You should convert gainL/gainR to and integer using the table, apply the gain adjustment to that value then use it as the index in the table to find to correct fixed point value.
So for lets say volume is set to 96 and balance is 5, gainL would be 52224 and gain adjustment would be (25-5)/25 = 0.80. Find 52224 in the table which will give you and index of 96. Multiply 96 by 0.80 to get 76.8. I usually just floor the value to 76. Then use 76 as the index to get value in the table which is 16640.--------------
Squeezebox apps for webOS, Android and Windows Phone, http://www.angrygoatapps.com
-
2021-03-01, 22:18 #56
- Join Date
- May 2008
- Location
- Canada
- Posts
- 6,937
I'm probably thick again but then I don't think this is the right thing to do then. The 0..100 to 16 bits is not tabulated but interpolated using parameters that are defined by squeezebox2.pm or its descendants (e.g. squeezeplay.pm and boom.pm define it differently). So if I force tabulation, I'll void what other descendants might do. Also, in your example, 5 means only use (25-5)/25=80% of volume for Left and 100% for Right but does not mean 20992 should be sent as gainL.
If I really want comply to the segmented volume curve, the balance ratio should be applied to the dB volume (0..100) and then the get_volume and dBToFixed applied individually (i.e. 5 means I apply 80% of the required (0..100) volume to Left and still 100% to Right). Now, I never paid too much attention to that domain of audio, but is a log balance the right thing to do? I though back in the old days of analogue, linear potentiometers were used because we want a finer sensitivity of the balance around the center.
Code:if (defined($newvolume)) { my $balance = $prefs->client($client)->get('balance') || 0; my $left = $balance > 0 ? (25 - $balance) / 25 : 1; my $right = $balance < 0 ? (25 + $balance) / 25 : 1; # Old style volume: my $oldGainL = $volume_map[int($volume*$left)]; my $oldGainR = $volume_map[int($volume*$right)]; my ($newGainL, $newGainR); # Negative volume = muting if ($volume <= 0) { $newGainL = $newGainR = 0; } else { my $db = $client->getVolume($volume*$left, $client->getVolumeParameters()); $newGainL = $client->dBToFixed($db); $db = $client->getVolume($volume*$right, $client->getVolumeParameters()); $newGainR = $client->dBToFixed($db); } my $dvc = $prefs->client($client)->get('digitalVolumeControl'); if ( !defined $dvc ) { $dvc = $Slim::Player::Player::defaultPrefs->{digitalVolumeControl}; } my $preamp = 255 - int( 2 * ( $prefs->client($client)->get('preampVolumeControl') || 0 ) ); my $data; if (defined($client->controllerSequenceId())) { $data = pack('NNCCNNNa6', $oldGainL, $oldGainR, $dvc, $preamp, $newGainL, $newGainR, ($client->controllerSequenceNumber() || 0), $client->controllerSequenceId()); } elsif (defined($client->sequenceNumber())) { $data = pack('NNCCNNN', $oldGainL, $oldGainR, $dvc, $preamp, $newGainL, $newGainR, $client->sequenceNumber()); } else { $data = pack('NNCCNN', $oldGainL, $oldGainR, $dvc, $preamp, $newGainL, $newGainR); } $client->sendFrame('audg', \$data); }
Last edited by philippe_44; 2021-03-01 at 22:25.
LMS 8.1.x on Odroid-C4 - SqueezeAMP!, 5xRadio, 5xBoom, 2xDuet, 1xTouch, 1xSB3. Sonos PLAY:3, PLAY:5, Marantz NR1603, Foobar2000, ShairPortW, 2xChromecast Audio, Chromecast v1 and v2, Squeezelite on Pi, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5, RivaArena 1 & 3
-
2021-03-01, 22:30 #57
- Join Date
- May 2008
- Location
- Canada
- Posts
- 6,937
LMS 8.1.x on Odroid-C4 - SqueezeAMP!, 5xRadio, 5xBoom, 2xDuet, 1xTouch, 1xSB3. Sonos PLAY:3, PLAY:5, Marantz NR1603, Foobar2000, ShairPortW, 2xChromecast Audio, Chromecast v1 and v2, Squeezelite on Pi, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5, RivaArena 1 & 3
-
2021-03-01, 23:14 #58
Yeah, I was wrong. I realized that i was assuming 100% volume. I suggested something else afterward.
I'm not really sure what's right, I'm not really an expert in analogue. I made the suggestion mostly so that the coding on my end would be more consistent, so I won't have to convert the balance adjusted values differently than the normal volume values.
You're probably OK to ignore SqueezeSlave. I highly doubt that anyone still uses it. Can you even get SqueezeSlave anymore?--------------
Squeezebox apps for webOS, Android and Windows Phone, http://www.angrygoatapps.com
-
2021-03-02, 02:53 #59
- Join Date
- Oct 2005
- Location
- Ireland
- Posts
- 20,304
This may be a minefield. IIRC when developers were defining/modifiying the curve - a lot of user feedback was that fine control at very low volume was needed esp when listening at night/early morning typically in bed.
When channels are not balanced then at some point in low volume one channel will not be heard at all. Users will have to accept that or else you'll have a complicated solution.
-
2021-03-02, 03:34 #60
- Join Date
- Jan 2010
- Location
- Hertfordshire
- Posts
- 6,578
Will balance be maintained as volume is changed?
Sent from my Pixel 3a using Tapatalk