diff -u alsa-lib-1.0.20/debian/changelog alsa-lib-1.0.20/debian/changelog --- alsa-lib-1.0.20/debian/changelog +++ alsa-lib-1.0.20/debian/changelog @@ -1,3 +1,10 @@ +alsa-lib (1.0.20-3ubuntu3) karmic; urgency=low + + * debian/patches/Add-Logarithmic-Volume-Control.patch: + - Add experimental logarithmic volume control. (LP: #204898) + + -- Andy Matteson Sat, 01 Aug 2009 02:21:35 -0400 + alsa-lib (1.0.20-3ubuntu2) karmic; urgency=low * Add config file for the Creative SB-XFi series of cards, taken from git diff -u alsa-lib-1.0.20/debian/patches/series alsa-lib-1.0.20/debian/patches/series --- alsa-lib-1.0.20/debian/patches/series +++ alsa-lib-1.0.20/debian/patches/series @@ -8,0 +9 @@ +Add-Logarithmic-Volume-Control.patch only in patch2: unchanged: --- alsa-lib-1.0.20.orig/debian/patches/Add-Logarithmic-Volume-Control.patch +++ alsa-lib-1.0.20/debian/patches/Add-Logarithmic-Volume-Control.patch @@ -0,0 +1,68 @@ +Index: alsa-lib-1.0.20/src/mixer/simple_none.c +=================================================================== +--- alsa-lib-1.0.20.orig/src/mixer/simple_none.c 2009-08-01 02:18:54.772219821 -0400 ++++ alsa-lib-1.0.20/src/mixer/simple_none.c 2009-08-01 02:20:25.720470175 -0400 +@@ -41,6 +41,8 @@ + #include + #include "mixer_simple.h" + ++#define round(x) (x<0?ceil((x)-0.5):floor((x)+0.5)) ++ + #ifndef DOC_HIDDEN + + #define MIXER_COMPARE_WEIGHT_SIMPLE_BASE 0 +@@ -211,6 +213,34 @@ + return MIXER_COMPARE_WEIGHT_SIMPLE_BASE + res + idx; + } + ++static long convert_to_logscale(selem_none_t *s, int dir, long value) ++{ ++ //FILE* myf = fopen("/home/user/Desktop/convert_to_logscale", "a"); ++ //if (myf!=NULL) fprintf(myf, "normalValue: %lld\n", value); ++ long range = s->str[dir].max - s->str[dir].min; ++ double mypower = 0.7; ++ double mycoeff = pow(range, -mypower) * (double)range; ++ double myvol2 = (double)value - (double)(s->str[dir].min); ++ long logValue = (long)round(mycoeff * pow(myvol2, mypower)) + s->str[dir].min; ++ //if (myf!=NULL) fprintf(myf, "logValue: %lld\n", logValue); ++ //if (myf!=NULL) fclose(myf); ++ return logValue; ++} ++ ++static long convert_from_logscale(selem_none_t *s, int dir, long value) ++{ ++ //FILE* myf = fopen("/home/user/Desktop/convert_from_logscale", "a"); ++ //if (myf!=NULL) fprintf(myf, "logValue: %lld\n", value); ++ long range = s->str[dir].max - s->str[dir].min; ++ double mypower = 1.0/0.7; ++ double mycoeff = pow(range, -mypower) * (double)range; ++ double myvol2 = (double)value - (double)(s->str[dir].min); ++ long normalValue = (long)round(mycoeff * pow(myvol2, mypower)) + s->str[dir].min; ++ //if (myf!=NULL) fprintf(myf, "normalValue: %lld\n", normalValue); ++ //if (myf!=NULL) fclose(myf); ++ return normalValue; ++} ++ + static long to_user(selem_none_t *s, int dir, selem_ctl_t *c, long value) + { + int64_t n; +@@ -242,7 +272,8 @@ + unsigned int idx1 = idx; + if (idx >= c->values) + idx1 = 0; +- s->str[dir].vol[idx] = to_user(s, dir, c, snd_ctl_elem_value_get_integer(ctl, idx1)); ++ //s->str[dir].vol[idx] = to_user(s, dir, c, snd_ctl_elem_value_get_integer(ctl, idx1)); ++ s->str[dir].vol[idx] = convert_from_logscale(s, dir, to_user(s, dir, c, snd_ctl_elem_value_get_integer(ctl, idx1))); + } + return 0; + } +@@ -471,7 +502,8 @@ + if ((err = snd_hctl_elem_read(c->elem, ctl)) < 0) + return err; + for (idx = 0; idx < c->values; idx++) +- snd_ctl_elem_value_set_integer(ctl, idx, from_user(s, dir, c, s->str[dir].vol[idx])); ++ //snd_ctl_elem_value_set_integer(ctl, idx, from_user(s, dir, c, s->str[dir].vol[idx])); ++ snd_ctl_elem_value_set_integer(ctl, idx, convert_to_logscale(s, dir, from_user(s, dir, c, s->str[dir].vol[idx]))); + if ((err = snd_hctl_elem_write(c->elem, ctl)) < 0) + return err; + return 0;