From f5bbf06b6067ff582bd7726b2f295292dea33f70 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 12 Jan 2015 14:56:42 +0100 Subject: Added the new parameters "Setup/Miscellaneous/Volume steps" and ".../Volume linearize" --- device.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'device.c') diff --git a/device.c b/device.c index 869c34a3..f0d6d728 100644 --- a/device.c +++ b/device.c @@ -4,11 +4,12 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 3.16 2015/01/07 12:53:55 kls Exp $ + * $Id: device.c 3.17 2015/01/12 14:38:23 kls Exp $ */ #include "device.h" #include +#include #include #include #include "audio.h" @@ -918,8 +919,10 @@ void cDevice::SetAudioChannel(int AudioChannel) void cDevice::SetVolume(int Volume, bool Absolute) { int OldVolume = volume; - volume = constrain(Absolute ? Volume : volume + Volume, 0, MAXVOLUME); - SetVolumeDevice(volume); + double VolumeDelta = double(MAXVOLUME) / Setup.VolumeSteps; + double VolumeLinearize = (Setup.VolumeLinearize >= 0) ? (Setup.VolumeLinearize / 10.0 + 1.0) : (1.0 / ((-Setup.VolumeLinearize / 10.0) + 1.0)); + volume = constrain(int(floor((Absolute ? Volume : volume + Volume) / VolumeDelta + 0.5) * VolumeDelta), 0, MAXVOLUME); + SetVolumeDevice(MAXVOLUME - int(pow(1.0 - pow(double(volume) / MAXVOLUME, VolumeLinearize), 1.0 / VolumeLinearize) * MAXVOLUME)); Absolute |= mute; cStatus::MsgSetVolume(Absolute ? volume : volume - OldVolume, Absolute); if (volume > 0) { -- cgit v1.2.3