aboutsummaryrefslogtreecommitdiffstats
path: root/src/CrossFade.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/CrossFade.cxx (renamed from src/crossfade.c)16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/crossfade.c b/src/CrossFade.cxx
index 46a0dff30..0bdcc43d6 100644
--- a/src/crossfade.c
+++ b/src/CrossFade.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,11 +18,13 @@
*/
#include "config.h"
-#include "crossfade.h"
-#include "chunk.h"
+#include "CrossFade.hxx"
+#include "MusicChunk.hxx"
#include "audio_format.h"
#include "tag.h"
+#include <cmath>
+
#include <assert.h>
#include <string.h>
#include <stdlib.h>
@@ -82,9 +84,8 @@ static float mixramp_interpolate(char *ramp_list, float required_db)
}
/* If required db < any stored value, use the least. */
- if (isnan(last_db)) {
+ if (std::isnan(last_db))
return secs;
- }
/* Finally, interpolate linearly. */
secs = last_secs + (required_db - last_db) * (secs - last_secs) / (db - last_db);
@@ -114,13 +115,14 @@ unsigned cross_fade_calc(float duration, float total_time,
chunks_f = (float)audio_format_time_to_size(af) / (float)CHUNK_SIZE;
- if (isnan(mixramp_delay) || !(mixramp_start) || !(mixramp_prev_end)) {
+ if (std::isnan(mixramp_delay) || !mixramp_start || !mixramp_prev_end) {
chunks = (chunks_f * duration + 0.5);
} else {
/* Calculate mixramp overlap. */
mixramp_overlap = mixramp_interpolate(mixramp_start, mixramp_db - replay_gain_db)
+ mixramp_interpolate(mixramp_prev_end, mixramp_db - replay_gain_prev_db);
- if (!isnan(mixramp_overlap) && (mixramp_delay <= mixramp_overlap)) {
+ if (!std::isnan(mixramp_overlap) &&
+ mixramp_delay <= mixramp_overlap) {
chunks = (chunks_f * (mixramp_overlap - mixramp_delay));
g_debug("will overlap %d chunks, %fs", chunks,
mixramp_overlap - mixramp_delay);