Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] dxr3 logarithmic volume (was Re: tiny bug in volume bar )
- To: vdr@linuxtv.org, cpunk@reactor.de
- Subject: [vdr] dxr3 logarithmic volume (was Re: tiny bug in volume bar )
- From: Jon Burgess <mplayer@jburgess.uklinux.net>
- Date: Mon, 15 Sep 2003 17:45:49 +0100
- Content-type: multipart/mixed; boundary="------------070408030105030401040402"
- In-reply-to: <E19tHpe-0006Vr-00@necessity.reactor.de>
- References: <3F4B2F17.9030408@trollmaster.net> <3F50B0E9.DE2D38E0@cadsoft.de> <E19tHpe-0006Vr-00@necessity.reactor.de>
- Reply-to: vdr@linuxtv.org
- Sender: vdr-bounce@linuxtv.org
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5b) Gecko/20030827
Steffen Beyer wrote:
Another bug, probably DXR3 related: the volume level changes linearly
instead of logarithmically, i.e. the heard volume change per bar width
decreases from left to right.
Try the patch attached. It works for me with vdr-1.2.5pre2 + dxr3-0.2.1
It requires a floating point calculation to calculate the gain factor,
but at least it manipulates the audio buffer using integer math. Perhaps
it could be improved by only re-calculating it when the volume level
changes.
You should avoid low volumes since the software scaling loses quality
e.g. when the output level is scaled by 256, the 16 bit output device
only provides 8 bits of effective audio data.
Even better would be an mixer plugin to control a specific OSS/ALSA
mixer. The output of my dxr3 card goes via motherboard audio mixer which
can be controlled using the ALSA Line1 mixer without any software scaling.
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