Use correct types

This commit is contained in:
Geoffrey Merck 2020-05-08 17:12:30 +02:00
parent 18bc0a75b8
commit c81d13395b
2 changed files with 17 additions and 17 deletions

View File

@ -23,29 +23,29 @@
CFMDownsampler::CFMDownsampler(uint16_t length) : CFMDownsampler::CFMDownsampler(uint16_t length) :
m_ringBuffer(length),//length might need tweaking m_ringBuffer(length),//length might need tweaking
m_samplePack(0), m_samplePack(0U),
m_samplePackBytes(0), m_samplePackPointer(0U),
m_packIndex(0), m_packIndex(0U),
m_downSampleIndex(0) m_downSampleIndex(0U)
{ {
m_samplePackBytes = &m_samplePack; m_samplePackPointer = &m_samplePack;
} }
void CFMDownsampler::addSample(q15_t sample) void CFMDownsampler::addSample(q15_t sample)
{ {
//only take one of three samples //only take one of three samples
if(m_downSampleIndex == 0) { if(m_downSampleIndex == 0U) {
switch(m_packIndex){ switch(m_packIndex){
case 0: case 0:
m_samplePack = int32_t(sample) << 12; m_samplePack = uint32_t(sample) << 12;
break; break;
case 1:{ case 1:{
m_samplePack |= int32_t(sample); m_samplePack |= uint32_t(sample);
//we did not use MSB; skip it //we did not use MSB; skip it
m_ringBuffer.put(m_samplePackBytes[1]); m_ringBuffer.put(m_samplePackPointer[1U]);
m_ringBuffer.put(m_samplePackBytes[2]); m_ringBuffer.put(m_samplePackPointer[2U]);
m_ringBuffer.put(m_samplePackBytes[3]); m_ringBuffer.put(m_samplePackPointer[3U]);
m_samplePack = 0;//reset the sample pack m_samplePack = 0;//reset the sample pack
} }
@ -55,11 +55,11 @@ void CFMDownsampler::addSample(q15_t sample)
break; break;
} }
m_packIndex++; m_packIndex++;
if(m_packIndex >= 2)//did we pack to samples ? if(m_packIndex >= 2U)//did we pack to samples ?
m_packIndex = 0; m_packIndex = 0U;
} }
m_downSampleIndex++; m_downSampleIndex++;
if(m_downSampleIndex >= 3) if(m_downSampleIndex >= 3U)
m_downSampleIndex = 0; m_downSampleIndex = 0U;
} }

View File

@ -33,8 +33,8 @@ public:
private: private:
CFMDownsampleRB m_ringBuffer; CFMDownsampleRB m_ringBuffer;
int32_t m_samplePack; uint32_t m_samplePack;
int32_t *m_samplePackBytes; uint32_t *m_samplePackPointer;
uint8_t m_packIndex; uint8_t m_packIndex;
uint8_t m_downSampleIndex; uint8_t m_downSampleIndex;