Skip to content

Commit 733ef3c

Browse files
committed
Implement SIMD conversion in BinaryRecording.cpp
1 parent 08317f2 commit 733ef3c

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

Source/Processors/RecordNode/BinaryFormat/BinaryRecording.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#include "BinaryRecording.h"
25+
#include "SIMDConverter.h"
2526

2627
#include "../../Settings/DataStream.h"
2728
#include "../../Settings/InfoObject.h"
@@ -651,10 +652,10 @@ void BinaryRecording::writeContinuousData (int writeChannel,
651652
m_bufferSize = size;
652653
}
653654

654-
/* Convert signal from float to int w/ bitVolts scaling */
655-
double multFactor = 1 / (float (0x7fff) * getContinuousChannel (realChannel)->getBitVolts());
656-
FloatVectorOperations::copyWithMultiply (m_scaledBuffer.getData(), dataBuffer, multFactor, size);
657-
AudioDataConverters::convertFloatToInt16LE (m_scaledBuffer.getData(), m_intBuffer.getData(), size);
655+
/* Convert signal from float to int16 w/ bitVolts scaling using SIMD-optimized conversion.
656+
The scale factor converts microvolts to int16 units: output = input / bitVolts */
657+
float scaleFactor = 1.0f / getContinuousChannel (realChannel)->getBitVolts();
658+
SIMDConverter::convertFloatToInt16 (dataBuffer, m_intBuffer.getData(), scaleFactor, size);
658659

659660
/* Get the file index that belongs to the current recording channel */
660661
int fileIndex = m_fileIndexes[writeChannel];

Tests/Processors/RecordNodeTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ class RecordNodeTests : public testing::Test {
206206
}
207207

208208
static int16_t minValPossible() {
209-
// The min value is actually -32767 in the math in RecordNode, not -32768 like the "true" min for int16_t
210-
return (std::numeric_limits<int16_t>::min)() + 1;
209+
// The SIMDConverter correctly uses the full int16 range [-32768, 32767]
210+
return (std::numeric_limits<int16_t>::min)();
211211
}
212212

213213
static int16_t maxValPossible() {

0 commit comments

Comments
 (0)