Skip to content

Commit

Permalink
Move float scaling value into constant. Fixes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
dturner committed Feb 12, 2018
1 parent 3082e83 commit f6586af
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/common/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace oboe {

constexpr float kScaleI16ToFloat = (1.0f / 32768.0f);

void convertFloatToPcm16(const float *source, int16_t *destination, int32_t numSamples) {
for (int i = 0; i < numSamples; i++) {
float fval = source[i];
Expand All @@ -40,7 +42,7 @@ void convertFloatToPcm16(const float *source, int16_t *destination, int32_t numS

void convertPcm16ToFloat(const int16_t *source, float *destination, int32_t numSamples) {
for (int i = 0; i < numSamples; i++) {
destination[i] = source[i] * (1.0f / 32768.0f);
destination[i] = source[i] * kScaleI16ToFloat;
}
}

Expand Down

0 comments on commit f6586af

Please sign in to comment.