From 66ec43c06615b276acb81e17751309c3273c164c Mon Sep 17 00:00:00 2001 From: Craig Hansen-Sturm Date: Mon, 22 Sep 2014 11:04:21 -0700 Subject: [PATCH] coding standard - else clause --- libraries/audio/src/AudioBuffer.h | 44 +++++++++------------------ libraries/audio/src/AudioEditBuffer.h | 3 +- libraries/audio/src/AudioGain.h | 9 ++---- libraries/audio/src/AudioPan.h | 15 +++------ 4 files changed, 24 insertions(+), 47 deletions(-) diff --git a/libraries/audio/src/AudioBuffer.h b/libraries/audio/src/AudioBuffer.h index b0d9d7da8e..b8ff1635a8 100644 --- a/libraries/audio/src/AudioBuffer.h +++ b/libraries/audio/src/AudioBuffer.h @@ -148,8 +148,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 // We always allow copying fewer frames than we have allocated _frameCount = frameCount; _channelCount = channelCount; - } - else { + } else { qDebug() << "Audio framing error: _channelCount=" << _channelCount << "channelCountMax=" @@ -163,7 +162,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 _frameCount = std::min(_frameCount,_frameCountMax); } - bool frameAlignment16 = (_frameCount & 0x0F) == 0; + bool frameAlignment16 = false; // (_frameCount & 0x0F) == 0; if (copyOut) { S* dst = frames; @@ -191,8 +190,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 *dst++ = _frameBuffer[0][14]; *dst++ = _frameBuffer[0][15]; } - } - else if (_channelCount == 2) { + } else if (_channelCount == 2) { for (uint32_t i = 0; i < _frameCount; i += 16) { *dst++ = _frameBuffer[0][0]; *dst++ = _frameBuffer[1][0]; @@ -228,16 +226,14 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 *dst++ = _frameBuffer[1][15]; } } - } - else { + } else { for (uint32_t i = 0; i < _frameCount; ++i) { for (uint32_t j = 0; j < _channelCount; ++j) { *dst++ = _frameBuffer[j][i]; } } } - } - else { + } else { if(typeid(T) == typeid(float32_t) && typeid(S) == typeid(int16_t)) { // source and destination aare not the same, convert from float32_t to int16_t and copy out @@ -264,8 +260,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 *dst++ = (S)(_frameBuffer[0][14] * scale); *dst++ = (S)(_frameBuffer[0][15] * scale); } - } - else if (_channelCount == 2) { + } else if (_channelCount == 2) { for (uint32_t i = 0; i < _frameCount; i += 16) { *dst++ = (S)(_frameBuffer[0][0] * scale); *dst++ = (S)(_frameBuffer[1][0] * scale); @@ -301,21 +296,18 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 *dst++ = (S)(_frameBuffer[1][15] * scale); } } - } - else { + } else { for (uint32_t i = 0; i < _frameCount; ++i) { for (uint32_t j = 0; j < _channelCount; ++j) { *dst++ = (S)(_frameBuffer[j][i] * scale); } } } - } - else { + } else { assert(0); // currently unsupported conversion } } - } - else { // copyIn + } else { // copyIn S* src = frames; if(typeid(T) == typeid(S)) { // source and destination types are the same, copy in @@ -341,8 +333,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 _frameBuffer[0][14] = *src++; _frameBuffer[0][15] = *src++; } - } - else if (_channelCount == 2) { + } else if (_channelCount == 2) { for (uint32_t i = 0; i < _frameCount; i += 16) { _frameBuffer[0][0] = *src++; _frameBuffer[1][0] = *src++; @@ -378,16 +369,14 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 _frameBuffer[1][15] = *src++; } } - } - else { + } else { for (uint32_t i = 0; i < _frameCount; ++i) { for (uint32_t j = 0; j < _channelCount; ++j) { _frameBuffer[j][i] = *src++; } } } - } - else { + } else { if(typeid(T) == typeid(float32_t) && typeid(S) == typeid(int16_t)) { // source and destination aare not the same, convert from int16_t to float32_t and copy in @@ -414,8 +403,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 _frameBuffer[0][14] = ((T)(*src++)) / scale; _frameBuffer[0][15] = ((T)(*src++)) / scale; } - } - else if (_channelCount == 2) { + } else if (_channelCount == 2) { for (uint32_t i = 0; i < _frameCount; i += 16) { _frameBuffer[0][0] = ((T)(*src++)) / scale; _frameBuffer[1][0] = ((T)(*src++)) / scale; @@ -451,16 +439,14 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3 _frameBuffer[1][15] = ((T)(*src++)) / scale; } } - } - else { + } else { for (uint32_t i = 0; i < _frameCount; ++i) { for (uint32_t j = 0; j < _channelCount; ++j) { _frameBuffer[j][i] = ((T)(*src++)) / scale; } } } - } - else { + } else { assert(0); // currently unsupported conversion } } diff --git a/libraries/audio/src/AudioEditBuffer.h b/libraries/audio/src/AudioEditBuffer.h index 2761eee97c..f93d338e47 100644 --- a/libraries/audio/src/AudioEditBuffer.h +++ b/libraries/audio/src/AudioEditBuffer.h @@ -88,8 +88,7 @@ inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool s if (slope) { // 0.0 to 1.0f in delta increments delta = 1.0f / (float32_t)count; gain = 0.0f; - } - else { // 1.0f to 0.0f in delta increments + } else { // 1.0f to 0.0f in delta increments delta = -1.0f / (float32_t)count; gain = 1.0f; } diff --git a/libraries/audio/src/AudioGain.h b/libraries/audio/src/AudioGain.h index a321ec2eba..1d54d76f7f 100644 --- a/libraries/audio/src/AudioGain.h +++ b/libraries/audio/src/AudioGain.h @@ -63,8 +63,7 @@ inline void AudioGain::render(AudioBufferFloat32& frameBuffer) { samples[0][i + 14] *= _gain; samples[0][i + 15] *= _gain; } - } - else if (frameBuffer.getChannelCount() == 2) { + } else if (frameBuffer.getChannelCount() == 2) { for (uint32_t i = 0; i < frameBuffer.getFrameCount(); i += 16) { samples[0][i + 0] *= _gain; @@ -100,12 +99,10 @@ inline void AudioGain::render(AudioBufferFloat32& frameBuffer) { samples[1][i + 14] *= _gain; samples[1][i + 15] *= _gain; } - } - else { + } else { assert("unsupported channel format"); } - } - else { + } else { for (uint32_t j = 0; j < frameBuffer.getChannelCount(); ++j) { for (uint32_t i = 0; i < frameBuffer.getFrameCount(); i += 1) { diff --git a/libraries/audio/src/AudioPan.h b/libraries/audio/src/AudioPan.h index ea5e90a7f7..2fe8c5cc28 100644 --- a/libraries/audio/src/AudioPan.h +++ b/libraries/audio/src/AudioPan.h @@ -87,12 +87,10 @@ inline void AudioPan::render(AudioBufferFloat32& frameBuffer) { samples[1][i + 14] *= _gainRight; samples[1][i + 15] *= _gainRight; } - } - else { + } else { assert("unsupported channel format"); } - } - else { + } else { for (uint32_t i = 0; i < frameBuffer.getFrameCount(); i += 1) { samples[0][i] *= _gainLeft; samples[1][i] *= _gainRight; @@ -107,16 +105,13 @@ inline void AudioPan::updateCoefficients() { if (_pan >= ONE_MINUS_EPSILON) { // full right _gainLeft = 0.0f; _gainRight = 1.0f; - } - else if (_pan <= ZERO_PLUS_EPSILON) { // full left + } else if (_pan <= ZERO_PLUS_EPSILON) { // full left _gainLeft = 1.0f; _gainRight = 0.0f; - } - else if ((_pan >= ONE_HALF_MINUS_EPSILON) && (_pan <= ONE_HALF_PLUS_EPSILON)) { // center + } else if ((_pan >= ONE_HALF_MINUS_EPSILON) && (_pan <= ONE_HALF_PLUS_EPSILON)) { // center _gainLeft = 1.0f / SQUARE_ROOT_OF_2; _gainRight = 1.0f / SQUARE_ROOT_OF_2; - } - else { // intermediate cases + } else { // intermediate cases _gainLeft = cosf( TWO_PI * _pan ); _gainRight = sinf( TWO_PI * _pan ); }