diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bsinc_tables.cpp | 6 | ||||
-rw-r--r-- | core/converter.cpp | 23 | ||||
-rw-r--r-- | core/except.h | 3 | ||||
-rw-r--r-- | core/hrtf.cpp | 24 | ||||
-rw-r--r-- | core/mastering.h | 2 | ||||
-rw-r--r-- | core/voice.cpp | 9 |
6 files changed, 31 insertions, 36 deletions
diff --git a/core/bsinc_tables.cpp b/core/bsinc_tables.cpp index 03eb4341..6e3ee338 100644 --- a/core/bsinc_tables.cpp +++ b/core/bsinc_tables.cpp @@ -127,11 +127,9 @@ struct BSincHeader { uint total_size{}; constexpr BSincHeader(uint Rejection, uint Order) noexcept + : width{CalcKaiserWidth(Rejection, Order)}, beta{CalcKaiserBeta(Rejection)} + , scaleBase{width / 2.0} { - width = CalcKaiserWidth(Rejection, Order); - beta = CalcKaiserBeta(Rejection); - scaleBase = width / 2.0; - uint num_points{Order+1}; for(uint si{0};si < BSincScaleCount;++si) { diff --git a/core/converter.cpp b/core/converter.cpp index fb293ee2..b3ff5b0a 100644 --- a/core/converter.cpp +++ b/core/converter.cpp @@ -24,26 +24,23 @@ static_assert((BufferLineSize-1)/MaxPitch > 0, "MaxPitch is too large for Buffer static_assert((INT_MAX>>MixerFracBits)/MaxPitch > BufferLineSize, "MaxPitch and/or BufferLineSize are too large for MixerFracBits!"); -/* Base template left undefined. Should be marked =delete, but Clang 3.8.1 - * chokes on that given the inline specializations. - */ template<DevFmtType T> -inline float LoadSample(DevFmtType_t<T> val) noexcept; +constexpr float LoadSample(DevFmtType_t<T> val) noexcept = delete; -template<> inline float LoadSample<DevFmtByte>(DevFmtType_t<DevFmtByte> val) noexcept -{ return val * (1.0f/128.0f); } -template<> inline float LoadSample<DevFmtShort>(DevFmtType_t<DevFmtShort> val) noexcept -{ return val * (1.0f/32768.0f); } -template<> inline float LoadSample<DevFmtInt>(DevFmtType_t<DevFmtInt> val) noexcept +template<> constexpr float LoadSample<DevFmtByte>(DevFmtType_t<DevFmtByte> val) noexcept +{ return float(val) * (1.0f/128.0f); } +template<> constexpr float LoadSample<DevFmtShort>(DevFmtType_t<DevFmtShort> val) noexcept +{ return float(val) * (1.0f/32768.0f); } +template<> constexpr float LoadSample<DevFmtInt>(DevFmtType_t<DevFmtInt> val) noexcept { return static_cast<float>(val) * (1.0f/2147483648.0f); } -template<> inline float LoadSample<DevFmtFloat>(DevFmtType_t<DevFmtFloat> val) noexcept +template<> constexpr float LoadSample<DevFmtFloat>(DevFmtType_t<DevFmtFloat> val) noexcept { return val; } -template<> inline float LoadSample<DevFmtUByte>(DevFmtType_t<DevFmtUByte> val) noexcept +template<> constexpr float LoadSample<DevFmtUByte>(DevFmtType_t<DevFmtUByte> val) noexcept { return LoadSample<DevFmtByte>(static_cast<int8_t>(val - 128)); } -template<> inline float LoadSample<DevFmtUShort>(DevFmtType_t<DevFmtUShort> val) noexcept +template<> constexpr float LoadSample<DevFmtUShort>(DevFmtType_t<DevFmtUShort> val) noexcept { return LoadSample<DevFmtShort>(static_cast<int16_t>(val - 32768)); } -template<> inline float LoadSample<DevFmtUInt>(DevFmtType_t<DevFmtUInt> val) noexcept +template<> constexpr float LoadSample<DevFmtUInt>(DevFmtType_t<DevFmtUInt> val) noexcept { return LoadSample<DevFmtInt>(static_cast<int32_t>(val - 2147483648u)); } diff --git a/core/except.h b/core/except.h index eec876db..90e3346e 100644 --- a/core/except.h +++ b/core/except.h @@ -14,11 +14,12 @@ class base_exception : public std::exception { protected: base_exception() = default; - ~base_exception() override; auto setMessage(const char *msg, std::va_list args) -> void; public: + ~base_exception() override; + [[nodiscard]] auto what() const noexcept -> const char* override { return mMessage.c_str(); } }; diff --git a/core/hrtf.cpp b/core/hrtf.cpp index d97bbb9d..a3faee49 100644 --- a/core/hrtf.cpp +++ b/core/hrtf.cpp @@ -252,11 +252,11 @@ void HrtfStore::getCoeffs(float elevation, float azimuth, float distance, float }}; /* Calculate the blended HRIR delays. */ - float d{mDelays[idx[0]][0]*blend[0] + mDelays[idx[1]][0]*blend[1] + mDelays[idx[2]][0]*blend[2] - + mDelays[idx[3]][0]*blend[3]}; + float d{float(mDelays[idx[0]][0])*blend[0] + float(mDelays[idx[1]][0])*blend[1] + + float(mDelays[idx[2]][0])*blend[2] + float(mDelays[idx[3]][0])*blend[3]}; delays[0] = fastf2u(d * float{1.0f/HrirDelayFracOne}); - d = mDelays[idx[0]][1]*blend[0] + mDelays[idx[1]][1]*blend[1] + mDelays[idx[2]][1]*blend[2] - + mDelays[idx[3]][1]*blend[3]; + d = float(mDelays[idx[0]][1])*blend[0] + float(mDelays[idx[1]][1])*blend[1] + + float(mDelays[idx[2]][1])*blend[2] + float(mDelays[idx[3]][1])*blend[3]; delays[1] = fastf2u(d * float{1.0f/HrirDelayFracOne}); /* Calculate the blended HRIR coefficients. */ @@ -580,7 +580,7 @@ std::unique_ptr<HrtfStore> LoadHrtf00(std::istream &data, const char *filename) for(auto &hrir : coeffs) { for(auto &val : al::span<float2>{hrir.data(), irSize}) - val[0] = readle<int16_t>(data) / 32768.0f; + val[0] = float(readle<int16_t>(data)) / 32768.0f; } for(auto &val : delays) val[0] = readle<uint8_t>(data); @@ -658,7 +658,7 @@ std::unique_ptr<HrtfStore> LoadHrtf01(std::istream &data, const char *filename) for(auto &hrir : coeffs) { for(auto &val : al::span<float2>{hrir.data(), irSize}) - val[0] = readle<int16_t>(data) / 32768.0f; + val[0] = float(readle<int16_t>(data)) / 32768.0f; } for(auto &val : delays) val[0] = readle<uint8_t>(data); @@ -750,7 +750,7 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) return nullptr; } - fields[f].distance = distance / 1000.0f; + fields[f].distance = float(distance) / 1000.0f; fields[f].evCount = evCount; if(f > 0 && fields[f].distance <= fields[f-1].distance) { @@ -799,7 +799,7 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) for(auto &hrir : coeffs) { for(auto &val : al::span<float2>{hrir.data(), irSize}) - val[0] = readle<int16_t>(data) / 32768.0f; + val[0] = float(readle<int16_t>(data)) / 32768.0f; } } else if(sampleType == SampleType_S24) @@ -838,8 +838,8 @@ std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) { for(auto &val : al::span<float2>{hrir.data(), irSize}) { - val[0] = readle<int16_t>(data) / 32768.0f; - val[1] = readle<int16_t>(data) / 32768.0f; + val[0] = float(readle<int16_t>(data)) / 32768.0f; + val[1] = float(readle<int16_t>(data)) / 32768.0f; } } } @@ -1010,7 +1010,7 @@ std::unique_ptr<HrtfStore> LoadHrtf03(std::istream &data, const char *filename) return nullptr; } - fields[f].distance = distance / 1000.0f; + fields[f].distance = float(distance) / 1000.0f; fields[f].evCount = evCount; if(f > 0 && fields[f].distance > fields[f-1].distance) { @@ -1402,7 +1402,7 @@ HrtfStorePtr GetLoadedHrtf(const std::string &name, const uint devrate) { for(size_t j{0};j < 2;++j) { - const float new_delay{std::round(hrtf->mDelays[i][j] * rate_scale) / + const float new_delay{std::round(float(hrtf->mDelays[i][j]) * rate_scale) / float{HrirDelayFracOne}}; max_delay = maxf(max_delay, new_delay); new_delays[i][j] = new_delay; diff --git a/core/mastering.h b/core/mastering.h index 35480176..08f3678e 100644 --- a/core/mastering.h +++ b/core/mastering.h @@ -64,7 +64,7 @@ struct Compressor { ~Compressor(); void process(const uint SamplesToDo, FloatBufferLine *OutBuffer); - [[nodiscard]] auto getLookAhead() const noexcept -> int { return static_cast<int>(mLookAhead); } + [[nodiscard]] auto getLookAhead() const noexcept -> uint { return mLookAhead; } DEF_PLACE_NEWDEL diff --git a/core/voice.cpp b/core/voice.cpp index d2645b7f..1272b202 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -954,7 +954,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi fracPos += dstBufferSize*increment; const uint srcOffset{fracPos >> MixerFracBits}; fracPos &= MixerFracMask; - intPos += srcOffset; + intPos += static_cast<int>(srcOffset); /* If more samples need to be loaded, copy the back of the * resampleBuffer to the front to reuse it. prevSamples isn't @@ -1018,7 +1018,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi if(mFlags.test(VoiceHasHrtf)) { - const float TargetGain{parms.Hrtf.Target.Gain * (vstate == Playing)}; + const float TargetGain{parms.Hrtf.Target.Gain * float(vstate == Playing)}; DoHrtfMix(samples, samplesToMix, parms, TargetGain, Counter, OutPos, (vstate == Playing), Device); } @@ -1064,8 +1064,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi /* Update voice positions and buffers as needed. */ DataPosFrac += increment*samplesToMix; - const uint SrcSamplesDone{DataPosFrac>>MixerFracBits}; - DataPosInt += SrcSamplesDone; + DataPosInt += static_cast<int>(DataPosFrac>>MixerFracBits); DataPosFrac &= MixerFracMask; uint buffers_done{0u}; @@ -1121,7 +1120,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi if(BufferListItem->mSampleLen > static_cast<uint>(DataPosInt)) break; - DataPosInt -= BufferListItem->mSampleLen; + DataPosInt -= static_cast<int>(BufferListItem->mSampleLen); ++buffers_done; BufferListItem = BufferListItem->mNext.load(std::memory_order_relaxed); |