summaryrefslogtreecommitdiff
path: root/src/pcm
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-03-15 23:33:21 -0700
committerRosen Penev <rosenp@gmail.com>2020-03-16 12:43:24 -0700
commit6d91b5c7b21926137c63561e313afd1fb72274f8 (patch)
treefb3424a20e839954df416e1af8316fc3ca3b9f78 /src/pcm
parentfd71514068be53a98c8f4b87d3164fd632ab24cb (diff)
fix double promotions
Found with -Wdouble-promotion Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'src/pcm')
-rw-r--r--src/pcm/Dsd2Pcm.cxx6
-rw-r--r--src/pcm/FloatConvert.hxx2
-rw-r--r--src/pcm/Mix.cxx2
-rw-r--r--src/pcm/SoxrResampler.cxx2
-rw-r--r--src/pcm/Volume.hxx2
5 files changed, 7 insertions, 7 deletions
diff --git a/src/pcm/Dsd2Pcm.cxx b/src/pcm/Dsd2Pcm.cxx
index 42f76d730..4ccbfa199 100644
--- a/src/pcm/Dsd2Pcm.cxx
+++ b/src/pcm/Dsd2Pcm.cxx
@@ -127,7 +127,7 @@ CalculateCtableValue(size_t t, int k, int e) noexcept
acc += (((e >> (7 - m)) & 1) * 2 - 1) * htaps[t * 8 + m];
}
- return acc;
+ return float(acc);
}
/* this needs to be a struct because GCC 6 doesn't have constexpr
@@ -204,9 +204,9 @@ Dsd2Pcm::CalcOutputSample(size_t ffp) const noexcept
for (size_t i = 0; i < CTABLES; ++i) {
uint8_t bite1 = fifo[(ffp -i) & FIFOMASK];
uint8_t bite2 = fifo[(ffp-(CTABLES*2-1)+i) & FIFOMASK];
- acc += ctables[i][bite1] + ctables[i][bite2];
+ acc += double(ctables[i][bite1] + ctables[i][bite2]);
}
- return acc;
+ return float(acc);
}
inline float
diff --git a/src/pcm/FloatConvert.hxx b/src/pcm/FloatConvert.hxx
index 8b01151e4..97bb09d18 100644
--- a/src/pcm/FloatConvert.hxx
+++ b/src/pcm/FloatConvert.hxx
@@ -54,7 +54,7 @@ struct IntegerToFloatSampleConvert {
typedef typename SrcTraits::value_type SV;
typedef typename DstTraits::value_type DV;
- static constexpr DV factor = 1.0 / FloatToIntegerSampleConvert<F, Traits>::factor;
+ static constexpr DV factor = 1.0f / FloatToIntegerSampleConvert<F, Traits>::factor;
static_assert(factor > 0, "Wrong factor");
static constexpr DV Convert(SV src) noexcept {
diff --git a/src/pcm/Mix.cxx b/src/pcm/Mix.cxx
index a39a85947..ed2b0f8db 100644
--- a/src/pcm/Mix.cxx
+++ b/src/pcm/Mix.cxx
@@ -221,7 +221,7 @@ pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
if (portion1 < 0)
return pcm_add(buffer1, buffer2, size, format);
- s = sin(M_PI_2 * portion1);
+ s = std::sin((float)M_PI_2 * portion1);
s *= s;
int vol1 = lround(s * PCM_VOLUME_1S);
diff --git a/src/pcm/SoxrResampler.cxx b/src/pcm/SoxrResampler.cxx
index 769445e58..e896bef7b 100644
--- a/src/pcm/SoxrResampler.cxx
+++ b/src/pcm/SoxrResampler.cxx
@@ -123,7 +123,7 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
ratio = float(new_sample_rate) / float(af.sample_rate);
FormatDebug(soxr_domain,
"samplerate conversion ratio to %.2lf",
- ratio);
+ double(ratio));
/* libsoxr works with floating point samples */
af.format = SampleFormat::FLOAT;
diff --git a/src/pcm/Volume.hxx b/src/pcm/Volume.hxx
index e38c85a71..b150a3e5d 100644
--- a/src/pcm/Volume.hxx
+++ b/src/pcm/Volume.hxx
@@ -48,7 +48,7 @@ static constexpr int PCM_VOLUME_1S = PCM_VOLUME_1;
constexpr int
pcm_float_to_volume(float volume) noexcept
{
- return volume * PCM_VOLUME_1 + 0.5;
+ return int(volume * PCM_VOLUME_1 + 0.5f);
}
constexpr float