diff options
Diffstat (limited to 'core/voice.cpp')
-rw-r--r-- | core/voice.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/core/voice.cpp b/core/voice.cpp index 090b10a3..cbf84c2a 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -17,7 +17,6 @@ #include <utility> #include <vector> -#include "albyte.h" #include "alnumeric.h" #include "alspan.h" #include "alstring.h" @@ -264,7 +263,7 @@ const float *DoFilters(BiquadFilter &lpfilter, BiquadFilter &hpfilter, float *ds template<FmtType Type> -inline void LoadSamples(float *RESTRICT dstSamples, const al::byte *src, const size_t srcChan, +inline void LoadSamples(float *RESTRICT dstSamples, const std::byte *src, const size_t srcChan, const size_t srcOffset, const size_t srcStep, const size_t /*samplesPerBlock*/, const size_t samplesToLoad) noexcept { @@ -275,7 +274,7 @@ inline void LoadSamples(float *RESTRICT dstSamples, const al::byte *src, const s } template<> -inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src, +inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const std::byte *src, const size_t srcChan, const size_t srcOffset, const size_t srcStep, const size_t samplesPerBlock, const size_t samplesToLoad) noexcept { @@ -293,8 +292,8 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src /* Each IMA4 block starts with a signed 16-bit sample, and a signed * 16-bit table index. The table index needs to be clamped. */ - int sample{src[srcChan*4] | (src[srcChan*4 + 1] << 8)}; - int index{src[srcChan*4 + 2] | (src[srcChan*4 + 3] << 8)}; + int sample{int(src[srcChan*4]) | (int(src[srcChan*4 + 1]) << 8)}; + int index{int(src[srcChan*4 + 2]) | (int(src[srcChan*4 + 3]) << 8)}; sample = (sample^0x8000) - 32768; index = clampi((index^0x8000) - 32768, 0, MaxStepIndex); @@ -326,7 +325,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src * always be less than the block size). They need to be decoded despite * being ignored for proper state on the remaining samples. */ - const al::byte *nibbleData{src + (srcStep+srcChan)*4}; + const std::byte *nibbleData{src + (srcStep+srcChan)*4}; size_t nibbleOffset{0}; const size_t startOffset{skip + 1}; for(;skip;--skip) @@ -336,7 +335,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src const size_t byteOffset{wordOffset*srcStep + ((nibbleOffset>>1)&3u)}; ++nibbleOffset; - std::ignore = decode_sample((nibbleData[byteOffset]>>byteShift) & 15u); + std::ignore = decode_sample(uint(nibbleData[byteOffset]>>byteShift) & 15u); } /* Second, decode the rest of the block and write to the output, until @@ -350,7 +349,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src const size_t byteOffset{wordOffset*srcStep + ((nibbleOffset>>1)&3u)}; ++nibbleOffset; - const int result{decode_sample((nibbleData[byteOffset]>>byteShift) & 15u)}; + const int result{decode_sample(uint(nibbleData[byteOffset]>>byteShift) & 15u)}; dstSamples[wrote++] = static_cast<float>(result) / 32768.0f; } if(wrote == samplesToLoad) @@ -361,7 +360,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src } template<> -inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte *src, +inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const std::byte *src, const size_t srcChan, const size_t srcOffset, const size_t srcStep, const size_t samplesPerBlock, const size_t samplesToLoad) noexcept { @@ -378,16 +377,16 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte * * nibble sample value. This is followed by the two initial 16-bit * sample history values. */ - const al::byte *input{src}; - const uint8_t blockpred{std::min(input[srcChan], uint8_t{6})}; + const std::byte *input{src}; + const uint8_t blockpred{std::min(uint8_t(input[srcChan]), uint8_t{6})}; input += srcStep; - int delta{input[2*srcChan + 0] | (input[2*srcChan + 1] << 8)}; + int delta{int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1]) << 8)}; input += srcStep*2; int sampleHistory[2]{}; - sampleHistory[0] = input[2*srcChan + 0] | (input[2*srcChan + 1]<<8); + sampleHistory[0] = int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1])<<8); input += srcStep*2; - sampleHistory[1] = input[2*srcChan + 0] | (input[2*srcChan + 1]<<8); + sampleHistory[1] = int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1])<<8); input += srcStep*2; const auto coeffs = al::as_span(MSADPCMAdaptionCoeff[blockpred]); @@ -440,7 +439,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte * const size_t byteShift{((nibbleOffset&1)^1) * 4}; nibbleOffset += srcStep; - std::ignore = decode_sample((input[byteOffset]>>byteShift) & 15); + std::ignore = decode_sample(int(input[byteOffset]>>byteShift) & 15); } /* Now decode the rest of the block, until the end of the block or the @@ -453,7 +452,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte * const size_t byteShift{((nibbleOffset&1)^1) * 4}; nibbleOffset += srcStep; - const int sample{decode_sample((input[byteOffset]>>byteShift) & 15)}; + const int sample{decode_sample(int(input[byteOffset]>>byteShift) & 15)}; dstSamples[wrote++] = static_cast<float>(sample) / 32768.0f; } if(wrote == samplesToLoad) @@ -463,7 +462,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte * } while(true); } -void LoadSamples(float *dstSamples, const al::byte *src, const size_t srcChan, +void LoadSamples(float *dstSamples, const std::byte *src, const size_t srcChan, const size_t srcOffset, const FmtType srcType, const size_t srcStep, const size_t samplesPerBlock, const size_t samplesToLoad) noexcept { @@ -1102,7 +1101,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi { const size_t byteOffset{blocksDone*mBytesPerBlock}; const size_t byteEnd{mNumCallbackBlocks*mBytesPerBlock}; - al::byte *data{BufferListItem->mSamples}; + std::byte *data{BufferListItem->mSamples}; std::copy(data+byteOffset, data+byteEnd, data); mNumCallbackBlocks -= blocksDone; mCallbackBlockBase += blocksDone; |