summaryrefslogtreecommitdiff
path: root/apps/dsp.c
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2005-08-11 18:56:20 +0000
committerMagnus Holmgren <magnushol@gmail.com>2005-08-11 18:56:20 +0000
commit5a8eac1a5a7daa1f90af82e6d687e6c559a0d3e1 (patch)
tree34be24d921135551a46ec0c695866988f488c7c3 /apps/dsp.c
parenteab21c6cb56c7584290a15768e1412baed6e73a0 (diff)
downloadrockbox-5a8eac1a5a7daa1f90af82e6d687e6c559a0d3e1.zip
rockbox-5a8eac1a5a7daa1f90af82e6d687e6c559a0d3e1.tar.gz
rockbox-5a8eac1a5a7daa1f90af82e6d687e6c559a0d3e1.tar.bz2
rockbox-5a8eac1a5a7daa1f90af82e6d687e6c559a0d3e1.tar.xz
Added pre-amp setting for files with ReplayGain information.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7303 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/dsp.c')
-rw-r--r--apps/dsp.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 21effc5..701ffb4 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -23,13 +23,14 @@
#include "playback.h"
#include "system.h"
#include "settings.h"
+#include "replaygain.h"
#include "debug.h"
/* The "dither" code to convert the 24-bit samples produced by libmad was
* taken from the coolplayer project - coolplayer.sourceforge.net
*/
-/* 16-bit samples are scaled based on these constants. The shift should be
+/* 16-bit samples are scaled based on these constants. The shift should be
* no more than 15.
*/
#define WORD_SHIFT 12
@@ -336,7 +337,7 @@ static inline long clip_sample(long sample)
return sample;
}
-/* The "dither" code to convert the 24-bit samples produced by libmad was
+/* The "dither" code to convert the 24-bit samples produced by libmad was
* taken from the coolplayer project - coolplayer.sourceforge.net
*/
@@ -386,15 +387,15 @@ static void apply_gain(long* src[], int count)
long* d1 = (s0 == s1) ? d0 : &sample_buf[SAMPLE_BUF_SIZE / 2];
long gain = dsp.replaygain;
long i;
-
+
src[0] = d0;
src[1] = d1;
-
+
for (i = 0; i < count; i++)
{
*d0++ = FRACMUL_8(*s0++, gain);
}
-
+
if (src [0] != src [1])
{
for (i = 0; i < count; i++)
@@ -639,7 +640,7 @@ void dsp_set_replaygain(bool always)
long gain = 0;
dsp.new_gain = false;
-
+
if (global_settings.replaygain || global_settings.replaygain_noclip)
{
long peak;
@@ -648,28 +649,36 @@ void dsp_set_replaygain(bool always)
{
gain = (global_settings.replaygain_track || !dsp.album_gain)
? dsp.track_gain : dsp.album_gain;
+
+ if (global_settings.replaygain_preamp)
+ {
+ long preamp = get_replaygain_int(
+ global_settings.replaygain_preamp * 10);
+
+ gain = (long) ((((int64_t) gain * preamp)) >> 24);
+ }
}
-
+
peak = (global_settings.replaygain_track || !dsp.album_peak)
? dsp.track_peak : dsp.album_peak;
-
+
if (gain == 0)
{
/* So that noclip can work even with no gain information. */
gain = DEFAULT_REPLAYGAIN;
}
-
+
if (global_settings.replaygain_noclip && (peak != 0)
&& ((((int64_t) gain * peak) >> 24) >= DEFAULT_REPLAYGAIN))
{
gain = (((int64_t) DEFAULT_REPLAYGAIN << 24) / peak);
}
-
+
if (gain == DEFAULT_REPLAYGAIN)
{
/* Nothing to do, disable processing. */
gain = 0;
-
+
}
}