aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_mix.c
diff options
context:
space:
mode:
authorTim Phipps <mpd@phipps-hutton.freeserve.co.uk>2010-03-21 18:21:47 +0100
committerMax Kellermann <max@duempel.org>2010-03-21 18:21:47 +0100
commite7a515c8b11c643332406d60a13ab1fe06d2b226 (patch)
treeaa7179b453b6fe7b163d1b4b807157359cb436cf /src/pcm_mix.c
parente9b75d462c4d0ffee3b3b26582800ec4f657a333 (diff)
downloadmpd-e7a515c8b11c643332406d60a13ab1fe06d2b226.tar.gz
mpd-e7a515c8b11c643332406d60a13ab1fe06d2b226.tar.xz
mpd-e7a515c8b11c643332406d60a13ab1fe06d2b226.zip
Add support for MixRamp tags
Adds mixrampdb and mixrampdelay commands. Reads MIXRAP_START and MIXRAMP_END tags from FLAC files and overlaps instead of crossfading.
Diffstat (limited to '')
-rw-r--r--src/pcm_mix.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pcm_mix.c b/src/pcm_mix.c
index 9a8aaeaca..28129608b 100644
--- a/src/pcm_mix.c
+++ b/src/pcm_mix.c
@@ -137,7 +137,16 @@ pcm_mix(void *buffer1, const void *buffer2, size_t size,
const struct audio_format *format, float portion1)
{
int vol1;
- float s = sin(M_PI_2 * portion1);
+ float s;
+
+ /* portion1 is between 0.0 and 1.0 for crossfading, MixRamp uses NaN
+ * to signal mixing rather than fading */
+ if (isnan(portion1)) {
+ pcm_add(buffer1, buffer2, size, PCM_VOLUME_1, PCM_VOLUME_1, format);
+ return;
+ }
+
+ s = sin(M_PI_2 * portion1);
s *= s;
vol1 = s * PCM_VOLUME_1 + 0.5;