aboutsummaryrefslogtreecommitdiffstats
path: root/src/FormatConverter.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2024-11-06 20:05:57 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2024-11-06 20:05:57 +0100
commit4057beacd02eab820ccf3b7c0633f1c8a0918e24 (patch)
tree2ccc740a35099ec0a4cd6a0e69efe8e4fcabb487 /src/FormatConverter.cpp
parent7452ff0fd85da423a5be1fdc3873106160c6ccae (diff)
downloaddabmod-4057beacd02eab820ccf3b7c0633f1c8a0918e24.tar.gz
dabmod-4057beacd02eab820ccf3b7c0633f1c8a0918e24.tar.bz2
dabmod-4057beacd02eab820ccf3b7c0633f1c8a0918e24.zip
FormatConverter: Renormalise for DEXTERfixedpoint
Diffstat (limited to 'src/FormatConverter.cpp')
-rw-r--r--src/FormatConverter.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/FormatConverter.cpp b/src/FormatConverter.cpp
index 1821442..0821191 100644
--- a/src/FormatConverter.cpp
+++ b/src/FormatConverter.cpp
@@ -65,16 +65,17 @@ int FormatConverter::process(Buffer* const dataIn, Buffer* dataOut)
int16_t* out = reinterpret_cast<int16_t*>(dataOut->getData());
for (size_t i = 0; i < sizeIn; i++) {
- if (in[i] < INT16_MIN) {
+ const int32_t val = in[i] >> 7;
+ if (val < INT16_MIN) {
out[i] = INT16_MIN;
num_clipped_samples++;
}
- else if (in[i] > INT16_MAX) {
+ else if (val > INT16_MAX) {
out[i] = INT16_MAX;
num_clipped_samples++;
}
else {
- out[i] = in[i];
+ out[i] = val;
}
}
}