diff options
| -rw-r--r-- | doc/todo | 3 | ||||
| -rw-r--r-- | polyp/Makefile.am | 6 | ||||
| -rw-r--r-- | polyp/polyplib-version.h.in | 4 | ||||
| -rw-r--r-- | polyp/sample.c | 16 | ||||
| -rw-r--r-- | polyp/sample.h | 6 | ||||
| -rw-r--r-- | polyp/voltest.c | 12 | 
6 files changed, 45 insertions, 2 deletions
@@ -1,6 +1,7 @@  *** $Id$ ***  *** 0.6 **** +- latency interpolation  - per-channel volume  - unix socket directories include user name  - add sample directory @@ -22,7 +23,7 @@  backends for:  - portaudio  (semi-done) +- gstreamer (semi-done)  - alsa-lib  - sdl -- gstreamer (semi-done)  - OSS (esddsp style) diff --git a/polyp/Makefile.am b/polyp/Makefile.am index 94d3373c..10e1c6cb 100644 --- a/polyp/Makefile.am +++ b/polyp/Makefile.am @@ -33,7 +33,7 @@ AM_LDADD=$(PTHREAD_LIBS) -lm  AM_LIBADD=$(PTHREAD_LIBS) -lm  EXTRA_DIST = default.pa.in daemon.conf.in client.conf.in depmod.py esdcompat.sh.in -bin_PROGRAMS = polypaudio pacat pactl paplay +bin_PROGRAMS = polypaudio pacat pactl paplay voltest  bin_SCRIPTS = esdcompat.sh  noinst_PROGRAMS = \  		mainloop-test \ @@ -408,6 +408,10 @@ mainloop_test_SOURCES = mainloop-test.c  mainloop_test_CFLAGS = $(AM_CFLAGS)  mainloop_test_LDADD = $(AM_LDADD) libpolyp-mainloop-@PA_MAJORMINOR@.la libpolyp-@PA_MAJORMINOR@.la +voltest_SOURCES = voltest.c sample.c +voltest_CFLAGS = $(AM_CFLAGS) +voltest_LDADD = $(AM_LDADD) +  cpulimit_test_SOURCES = cpulimit-test.c cpulimit.c util.c log.c  cpulimit_test_CFLAGS = $(AM_CFLAGS)  cpulimit_test_LDADD = $(AM_LDADD) libpolyp-mainloop-@PA_MAJORMINOR@.la diff --git a/polyp/polyplib-version.h.in b/polyp/polyplib-version.h.in index 75798693..c2442b52 100644 --- a/polyp/polyplib-version.h.in +++ b/polyp/polyplib-version.h.in @@ -27,6 +27,8 @@  /** \file   * Define header version */ +PA_C_DECL_BEGIN +  /** Return the version of the header files. Keep in mind that this is  a macro and not a function, so it is impossible to get the pointer of  it. */ @@ -40,4 +42,6 @@ const char* pa_get_library_version(void);   * PA_API_VERSION undefined.  */  #define PA_API_VERSION @PA_API_VERSION@ +PA_C_DECL_END +  #endif diff --git a/polyp/sample.c b/polyp/sample.c index 8c30386b..7048311c 100644 --- a/polyp/sample.c +++ b/polyp/sample.c @@ -125,6 +125,22 @@ double pa_volume_to_dB(pa_volume_t v) {      return 20*log10((double) v/PA_VOLUME_NORM);  } +#define USER_DECIBEL_RANGE 30 + +double pa_volume_to_user(pa_volume_t v) { +    double dB = pa_volume_to_dB(v); + +    return dB < -USER_DECIBEL_RANGE ? 0 : dB/USER_DECIBEL_RANGE+1; +} + +pa_volume_t pa_volume_from_user(double v) { + +    if (v <= 0) +        return PA_VOLUME_MUTED; +     +    return pa_volume_from_dB((v-1)*USER_DECIBEL_RANGE); +} +  void pa_bytes_snprint(char *s, size_t l, unsigned v) {      if (v >= ((unsigned) 1024)*1024*1024)          snprintf(s, l, "%0.1f GB", ((double) v)/1024/1024/1024); diff --git a/polyp/sample.h b/polyp/sample.h index 7e810386..4ab0b565 100644 --- a/polyp/sample.h +++ b/polyp/sample.h @@ -110,6 +110,12 @@ pa_volume_t pa_volume_from_dB(double f);  /** Convert volume from linear level to decibel.  \since 0.4 */  double pa_volume_to_dB(pa_volume_t v); +/** Convert volume to scaled value understandable by the user (between 0 and 1). \since 0.6 */ +double pa_volume_to_user(pa_volume_t v); + +/** Convert user volume to polypaudio volume. \since 0.6 */ +pa_volume_t pa_volume_from_user(double v); +  #ifdef INFINITY  #define PA_DECIBEL_MININFTY (-INFINITY)  #else diff --git a/polyp/voltest.c b/polyp/voltest.c new file mode 100644 index 00000000..a06d4ca2 --- /dev/null +++ b/polyp/voltest.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +#include <polyp/sample.h> + +int main() { +    int p; +    for (p = 0; p <= 200; p++) { +        pa_volume_t v = pa_volume_from_user((double) p/100); +        double dB = pa_volume_to_dB(v); +        printf("%3i%% = %u = %0.2f dB = %u = %3i%%\n", p, v, dB, pa_volume_from_dB(dB), (int) (pa_volume_to_user(v)*100)); +    } +}  | 
