Some of us are easily pleased, happy to have the thing work. Then there's me. . . I just reread this thread through from the beginning. It's been an interesting and arduous path with seemingly most everyone chipping in with pizzasgood to get here. Well, we're not there yet.L18L wrote:Glad for being able to control sound volume now
In response to a recent question given me by disciple:
As I see it there are two things still wrong with retrovol:Henry wrote:
"That the curve is so crowded at the top is perhaps not so bad as the lack of a true mute."
It has a "true mute" as far as I can tell. Am I missing something, or are you?
1. It has a linear "taper," not logarithmic. Nearly every volume control has a curve such that it "gives an approximately equal change in perceived volume for each equal slider increment."
2. It has a false mute indication, the red x popping up at the lowest visual segment, but not at zero volume.
When I pointed this out to pizzasgood in Feb 2012 he said:
Too bad he didn't do it if it was so simple. (I am not a coder, sorry.)"If anybody is interested in having it changed right now, there are only two lines of source code that would need adjusting. Otherwise, you'll have to wait until I get around to adding it proper, which is more work since I want it to be optional - I'm kind of busy lately so I might not work on it for a week or two. Also, this hasn't been tested thoroughly - it is possible that in some situations near the maximum and minimum volume levels you might have trouble getting it to completely max (or min) out. I will test that more rigorously when I implement it for real.
Anyway, the changes are to the alsa_classes.cpp file. The lines to change are 161 and 167, in the scale_out and scale_in functions.
Here is the original code: Code:
//this is used internally to scale a number to be from 0-100
int Element::scale_out(int num){
if(max-min==0){ return(num); }
return(ceil(100.0*(num-min)/(max-min)));
}
//this is the inverse of scale_out; it's used to take a 0-100 number and put it
//into the proper scale for the element to understand
int Element::scale_in(int num){
if(max-min==0){ return(num); }
return(floor((num*(max-min)/(100))+min));
}
And here is the modified code: Code:
//this is used internally to scale a number to be from 0-100
int Element::scale_out(int num){
if(max-min==0){ return(num); }
return(ceil(pow(100.0, (num-min)/(double)(max-min))));
}
//this is the inverse of scale_out; it's used to take a 0-100 number and put it
//into the proper scale for the element to understand
int Element::scale_in(int num){
if(max-min==0){ return(num); }
return(round((log(num)/log(100)*(max-min))+min));
}
And here is the diff, if you prefer that format: Code:
--- src/alsa_classes.cpp (revision 181)
+++ src/alsa_classes.cpp (working copy)
@@ -158,13 +158,13 @@
//this is used internally to scale a number to be from 0-100
int Element::scale_out(int num){
if(max-min==0){ return(num); }
- return(ceil(100.0*(num-min)/(max-min)));
+ return(ceil(pow(100.0, (num-min)/(double)(max-min))));
}
//this is the inverse of scale_out; it's used to take a 0-100 number and put it
//into the proper scale for the element to understand
int Element::scale_in(int num){
if(max-min==0){ return(num); }
- return(floor((num*(max-min)/(100))+min));
+ return(round((log(num)/log(100)*(max-min))+min));
}
//this will grab the highest value in the element
int Element::get(){
If you wanted some other scaling formula, these two functions are where you'd define it.
In the screen slider it's desirable for the end limits to represent zero (mute) and maximum sound level. If it's not possible we shouldn't say so.