mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 08:50:02 +02:00
coding standard - else clause
This commit is contained in:
parent
4372410fa7
commit
66ec43c066
4 changed files with 24 additions and 47 deletions
|
@ -148,8 +148,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3
|
||||||
// We always allow copying fewer frames than we have allocated
|
// We always allow copying fewer frames than we have allocated
|
||||||
_frameCount = frameCount;
|
_frameCount = frameCount;
|
||||||
_channelCount = channelCount;
|
_channelCount = channelCount;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
qDebug() << "Audio framing error: _channelCount="
|
qDebug() << "Audio framing error: _channelCount="
|
||||||
<< _channelCount
|
<< _channelCount
|
||||||
<< "channelCountMax="
|
<< "channelCountMax="
|
||||||
|
@ -163,7 +162,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3
|
||||||
_frameCount = std::min(_frameCount,_frameCountMax);
|
_frameCount = std::min(_frameCount,_frameCountMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool frameAlignment16 = (_frameCount & 0x0F) == 0;
|
bool frameAlignment16 = false; // (_frameCount & 0x0F) == 0;
|
||||||
|
|
||||||
if (copyOut) {
|
if (copyOut) {
|
||||||
S* dst = frames;
|
S* dst = frames;
|
||||||
|
@ -191,8 +190,7 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3
|
||||||
*dst++ = _frameBuffer[0][14];
|
*dst++ = _frameBuffer[0][14];
|
||||||
*dst++ = _frameBuffer[0][15];
|
*dst++ = _frameBuffer[0][15];
|
||||||
}
|
}
|
||||||
}
|
} else if (_channelCount == 2) {
|
||||||
else if (_channelCount == 2) {
|
|
||||||
for (uint32_t i = 0; i < _frameCount; i += 16) {
|
for (uint32_t i = 0; i < _frameCount; i += 16) {
|
||||||
*dst++ = _frameBuffer[0][0];
|
*dst++ = _frameBuffer[0][0];
|
||||||
*dst++ = _frameBuffer[1][0];
|
*dst++ = _frameBuffer[1][0];
|
||||||
|
@ -228,16 +226,14 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3
|
||||||
*dst++ = _frameBuffer[1][15];
|
*dst++ = _frameBuffer[1][15];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (uint32_t i = 0; i < _frameCount; ++i) {
|
for (uint32_t i = 0; i < _frameCount; ++i) {
|
||||||
for (uint32_t j = 0; j < _channelCount; ++j) {
|
for (uint32_t j = 0; j < _channelCount; ++j) {
|
||||||
*dst++ = _frameBuffer[j][i];
|
*dst++ = _frameBuffer[j][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if(typeid(T) == typeid(float32_t) &&
|
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
|
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][14] * scale);
|
||||||
*dst++ = (S)(_frameBuffer[0][15] * scale);
|
*dst++ = (S)(_frameBuffer[0][15] * scale);
|
||||||
}
|
}
|
||||||
}
|
} else if (_channelCount == 2) {
|
||||||
else if (_channelCount == 2) {
|
|
||||||
for (uint32_t i = 0; i < _frameCount; i += 16) {
|
for (uint32_t i = 0; i < _frameCount; i += 16) {
|
||||||
*dst++ = (S)(_frameBuffer[0][0] * scale);
|
*dst++ = (S)(_frameBuffer[0][0] * scale);
|
||||||
*dst++ = (S)(_frameBuffer[1][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);
|
*dst++ = (S)(_frameBuffer[1][15] * scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (uint32_t i = 0; i < _frameCount; ++i) {
|
for (uint32_t i = 0; i < _frameCount; ++i) {
|
||||||
for (uint32_t j = 0; j < _channelCount; ++j) {
|
for (uint32_t j = 0; j < _channelCount; ++j) {
|
||||||
*dst++ = (S)(_frameBuffer[j][i] * scale);
|
*dst++ = (S)(_frameBuffer[j][i] * scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assert(0); // currently unsupported conversion
|
assert(0); // currently unsupported conversion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else { // copyIn
|
||||||
else { // copyIn
|
|
||||||
S* src = frames;
|
S* src = frames;
|
||||||
|
|
||||||
if(typeid(T) == typeid(S)) { // source and destination types are the same, copy in
|
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][14] = *src++;
|
||||||
_frameBuffer[0][15] = *src++;
|
_frameBuffer[0][15] = *src++;
|
||||||
}
|
}
|
||||||
}
|
} else if (_channelCount == 2) {
|
||||||
else if (_channelCount == 2) {
|
|
||||||
for (uint32_t i = 0; i < _frameCount; i += 16) {
|
for (uint32_t i = 0; i < _frameCount; i += 16) {
|
||||||
_frameBuffer[0][0] = *src++;
|
_frameBuffer[0][0] = *src++;
|
||||||
_frameBuffer[1][0] = *src++;
|
_frameBuffer[1][0] = *src++;
|
||||||
|
@ -378,16 +369,14 @@ inline void AudioFrameBuffer< T >::copyFrames(uint32_t channelCount, const uint3
|
||||||
_frameBuffer[1][15] = *src++;
|
_frameBuffer[1][15] = *src++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (uint32_t i = 0; i < _frameCount; ++i) {
|
for (uint32_t i = 0; i < _frameCount; ++i) {
|
||||||
for (uint32_t j = 0; j < _channelCount; ++j) {
|
for (uint32_t j = 0; j < _channelCount; ++j) {
|
||||||
_frameBuffer[j][i] = *src++;
|
_frameBuffer[j][i] = *src++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if(typeid(T) == typeid(float32_t) &&
|
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
|
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][14] = ((T)(*src++)) / scale;
|
||||||
_frameBuffer[0][15] = ((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) {
|
for (uint32_t i = 0; i < _frameCount; i += 16) {
|
||||||
_frameBuffer[0][0] = ((T)(*src++)) / scale;
|
_frameBuffer[0][0] = ((T)(*src++)) / scale;
|
||||||
_frameBuffer[1][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;
|
_frameBuffer[1][15] = ((T)(*src++)) / scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (uint32_t i = 0; i < _frameCount; ++i) {
|
for (uint32_t i = 0; i < _frameCount; ++i) {
|
||||||
for (uint32_t j = 0; j < _channelCount; ++j) {
|
for (uint32_t j = 0; j < _channelCount; ++j) {
|
||||||
_frameBuffer[j][i] = ((T)(*src++)) / scale;
|
_frameBuffer[j][i] = ((T)(*src++)) / scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assert(0); // currently unsupported conversion
|
assert(0); // currently unsupported conversion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,8 +88,7 @@ inline void AudioEditBuffer<T>::linearFade(uint32_t start, uint32_t stop, bool s
|
||||||
if (slope) { // 0.0 to 1.0f in delta increments
|
if (slope) { // 0.0 to 1.0f in delta increments
|
||||||
delta = 1.0f / (float32_t)count;
|
delta = 1.0f / (float32_t)count;
|
||||||
gain = 0.0f;
|
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;
|
delta = -1.0f / (float32_t)count;
|
||||||
gain = 1.0f;
|
gain = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,7 @@ inline void AudioGain::render(AudioBufferFloat32& frameBuffer) {
|
||||||
samples[0][i + 14] *= _gain;
|
samples[0][i + 14] *= _gain;
|
||||||
samples[0][i + 15] *= _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) {
|
for (uint32_t i = 0; i < frameBuffer.getFrameCount(); i += 16) {
|
||||||
samples[0][i + 0] *= _gain;
|
samples[0][i + 0] *= _gain;
|
||||||
|
@ -100,12 +99,10 @@ inline void AudioGain::render(AudioBufferFloat32& frameBuffer) {
|
||||||
samples[1][i + 14] *= _gain;
|
samples[1][i + 14] *= _gain;
|
||||||
samples[1][i + 15] *= _gain;
|
samples[1][i + 15] *= _gain;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assert("unsupported channel format");
|
assert("unsupported channel format");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
for (uint32_t j = 0; j < frameBuffer.getChannelCount(); ++j) {
|
for (uint32_t j = 0; j < frameBuffer.getChannelCount(); ++j) {
|
||||||
for (uint32_t i = 0; i < frameBuffer.getFrameCount(); i += 1) {
|
for (uint32_t i = 0; i < frameBuffer.getFrameCount(); i += 1) {
|
||||||
|
|
|
@ -87,12 +87,10 @@ inline void AudioPan::render(AudioBufferFloat32& frameBuffer) {
|
||||||
samples[1][i + 14] *= _gainRight;
|
samples[1][i + 14] *= _gainRight;
|
||||||
samples[1][i + 15] *= _gainRight;
|
samples[1][i + 15] *= _gainRight;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assert("unsupported channel format");
|
assert("unsupported channel format");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (uint32_t i = 0; i < frameBuffer.getFrameCount(); i += 1) {
|
for (uint32_t i = 0; i < frameBuffer.getFrameCount(); i += 1) {
|
||||||
samples[0][i] *= _gainLeft;
|
samples[0][i] *= _gainLeft;
|
||||||
samples[1][i] *= _gainRight;
|
samples[1][i] *= _gainRight;
|
||||||
|
@ -107,16 +105,13 @@ inline void AudioPan::updateCoefficients() {
|
||||||
if (_pan >= ONE_MINUS_EPSILON) { // full right
|
if (_pan >= ONE_MINUS_EPSILON) { // full right
|
||||||
_gainLeft = 0.0f;
|
_gainLeft = 0.0f;
|
||||||
_gainRight = 1.0f;
|
_gainRight = 1.0f;
|
||||||
}
|
} else if (_pan <= ZERO_PLUS_EPSILON) { // full left
|
||||||
else if (_pan <= ZERO_PLUS_EPSILON) { // full left
|
|
||||||
_gainLeft = 1.0f;
|
_gainLeft = 1.0f;
|
||||||
_gainRight = 0.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;
|
_gainLeft = 1.0f / SQUARE_ROOT_OF_2;
|
||||||
_gainRight = 1.0f / SQUARE_ROOT_OF_2;
|
_gainRight = 1.0f / SQUARE_ROOT_OF_2;
|
||||||
}
|
} else { // intermediate cases
|
||||||
else { // intermediate cases
|
|
||||||
_gainLeft = cosf( TWO_PI * _pan );
|
_gainLeft = cosf( TWO_PI * _pan );
|
||||||
_gainRight = sinf( TWO_PI * _pan );
|
_gainRight = sinf( TWO_PI * _pan );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue