@@ -685,9 +685,8 @@ void BinaryRecording::writeContinuousData (int writeChannel,
685685 wroteFirstSampleNumber[streamId] = true ;
686686 }
687687
688- for (int i = 0 ; i < size; i++)
689- /* Generate int sample number */
690- m_sampleNumberBuffer[i] = baseSampleNumber + i;
688+ /* Generate sequential sample numbers using SIMD-optimized fill */
689+ SIMDConverter::fillSequentialInt64 (m_sampleNumberBuffer, baseSampleNumber, size);
691690
692691 /* Write int timestamps to disc */
693692 m_dataTimestampFiles[fileIndex]->writeData (m_sampleNumberBuffer, size * sizeof (int64));
@@ -764,9 +763,10 @@ void BinaryRecording::writeSpike (int electrodeIndex, const Spike* spike)
764763 m_intBuffer.malloc (totalSamples);
765764 }
766765
767- double multFactor = 1 / (float (0x7fff ) * channel->getChannelBitVolts (0 ));
768- FloatVectorOperations::copyWithMultiply (m_scaledBuffer.getData (), spike->getDataPointer (), multFactor, totalSamples);
769- AudioDataConverters::convertFloatToInt16LE (m_scaledBuffer.getData (), m_intBuffer.getData (), totalSamples);
766+ /* Convert spike waveforms from float to int16 using SIMD-optimized conversion.
767+ Scale factor converts microvolts to int16 units: output = input / bitVolts */
768+ float scaleFactor = 1 .0f / channel->getChannelBitVolts (0 );
769+ SIMDConverter::convertFloatToInt16 (spike->getDataPointer (), m_intBuffer.getData (), scaleFactor, totalSamples);
770770 rec->data ->writeData (m_intBuffer.getData (), totalSamples * sizeof (int16));
771771
772772 int64 sampleIdx = spike->getSampleNumber ();
@@ -848,6 +848,8 @@ void BinaryRecording::writeContinuousDataBatch (const int* writeChannels,
848848 // Get starting sample position (all channels in a stream have same position)
849849 uint64 startPos = m_samplesWritten[writeChannels[0 ]];
850850
851+ // LOGD("BinaryRecording::writeContinuousDataBatch: Writing ", numSamples, " samples for ", numChannels, " channels at position ", startPos, " to file index ", fileIndex);
852+
851853 // Try batch interleaving if we have all channels for this file
852854 // The file's channel count is determined by the stream's channel count
853855 // If we have a partial batch, fall back to per-channel writes
@@ -894,8 +896,8 @@ void BinaryRecording::writeContinuousDataBatch (const int* writeChannels,
894896 wroteFirstSampleNumber[streamId] = true ;
895897 }
896898
897- for ( int s = 0 ; s < numSamples; s++)
898- m_sampleNumberBuffer[s] = baseSampleNumber + s ;
899+ /* Generate sequential sample numbers using SIMD-optimized fill */
900+ SIMDConverter::fillSequentialInt64 ( m_sampleNumberBuffer, baseSampleNumber, numSamples) ;
899901
900902 m_dataTimestampFiles[fileIndex]->writeData (m_sampleNumberBuffer, numSamples * sizeof (int64));
901903 m_dataTimestampFiles[fileIndex]->increaseRecordCount (numSamples);
@@ -921,8 +923,7 @@ void BinaryRecording::writeTimestampSyncText (uint64 streamId, int64 sampleNumbe
921923 jassert (fsn == sampleNumber);
922924
923925 m_syncTextFile->writeText (syncString + " \r\n " , false , false , nullptr );
924-
925- m_syncTextFile->flush ();
926+ // Note: flush removed - file will be flushed on close or by OS buffering
926927}
927928
928929RecordEngineManager* BinaryRecording::getEngineManager ()
0 commit comments