Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] [PATCH] Logarithmic volume control for DXR3 plugin



Here is the patch I wrote to make the volume control logarithmic instead of linear. This is a more natural sounding way of controlling the volume. Perhaps it could be added to the next version?

Thanks,
Jon


--- dxr3abstractiondevice.c~	2003-08-10 17:11:14.000000000 +0100
+++ dxr3abstractiondevice.c	2003-09-14 13:47:31.171073704 +0100
@@ -14,6 +14,7 @@
 #include <time.h>
 #include <pthread.h>
 #include <string>
+#include <math.h>
 
 #include "dxr3vdrincludes.h"
 
@@ -245,8 +246,9 @@
     if (m_volume == 0) {
         memset(pcmbuf, 0, size);  
     } else if (m_volume != 255) {
+	int factor = (int)pow (2.0, (double)m_volume/16) - 1;
         for (int i = 0; i < size / (int)sizeof(short); i++) {
-            pcmbuf[i] = (((int)pcmbuf[i]) * m_volume) / 256;
+            pcmbuf[i] = (((int)pcmbuf[i]) * factor) / 65536;
         }
     }
 }

Home | Main Index | Thread Index