Skip to content

Commit 42209fe

Browse files
committed
Update indexes of npy files
1 parent ade3cb3 commit 42209fe

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

Source/Plugins/BinaryWriter/BinaryRecording.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ void BinaryRecording::writeData(int writeChannel, int realChannel, const float*
504504
double multFactor = 1 / (float(0x7fff) * getDataChannel(realChannel)->getBitVolts());
505505
FloatVectorOperations::copyWithMultiply(m_scaledBuffer.getData(), buffer, multFactor, size);
506506
AudioDataConverters::convertFloatToInt16LE(m_scaledBuffer.getData(), m_intBuffer.getData(), size);
507-
508-
m_DataFiles[m_fileIndexes[writeChannel]]->writeChannel(getTimestamp(writeChannel)-m_startTS[writeChannel],m_channelIndexes[writeChannel],m_intBuffer.getData(),size);
507+
int fileIndex = m_fileIndexes[writeChannel];
508+
m_DataFiles[fileIndex]->writeChannel(getTimestamp(writeChannel) - m_startTS[writeChannel], m_channelIndexes[writeChannel], m_intBuffer.getData(), size);
509509

510510
if (m_channelIndexes[writeChannel] == 0)
511511
{
@@ -515,7 +515,8 @@ void BinaryRecording::writeData(int writeChannel, int realChannel, const float*
515515
{
516516
m_tsBuffer[i] = (baseTS + i);
517517
}
518-
m_dataTimestampFiles[m_fileIndexes[writeChannel]]->writeData(m_tsBuffer, size*sizeof(int64));
518+
m_dataTimestampFiles[fileIndex]->writeData(m_tsBuffer, size*sizeof(int64));
519+
m_dataTimestampFiles[fileIndex]->increaseRecordCount(size);
519520
}
520521
}
521522

@@ -576,12 +577,14 @@ void BinaryRecording::writeEvent(int eventIndex, const MidiMessage& event)
576577
chanFile->writeData(&chan, sizeof(uint16));
577578
}
578579
writeEventMetaData(ev.get(), rec->metaDataFile);
580+
increaseEventCounts(rec);
579581
}
580582

581583
void BinaryRecording::writeTimestampSyncText(uint16 sourceID, uint16 sourceIdx, int64 timestamp, float, String text)
582584
{
583585
text.paddedRight(' ', 256);
584586
m_syncTextFile->writeData(text.toUTF8(), 256);
587+
m_syncTextFile->increaseRecordCount();
585588
}
586589

587590

@@ -593,7 +596,7 @@ void BinaryRecording::writeSpike(int electrodeIndex, const SpikeEvent* spike)
593596
uint16 spikeChannel = m_spikeChannelIndexes[electrodeIndex];
594597

595598
int totalSamples = channel->getTotalSamples() * channel->getNumChannels();
596-
599+
597600

598601
if (totalSamples > m_bufferSize) //Shouldn't happen, and if it happens it'll be slow, but better this than crashing. Will be reset on file close and reset.
599602
{
@@ -629,8 +632,16 @@ void BinaryRecording::writeSpike(int electrodeIndex, const SpikeEvent* spike)
629632

630633
uint16 sortedID = spike->getSortedID();
631634
sortedFile->writeData(&sortedID, sizeof(uint16));
635+
increaseEventCounts(rec);
636+
}
632637

633-
writeEventMetaData(spike, rec->metaDataFile);
638+
void BinaryRecording::increaseEventCounts(EventRecording* rec)
639+
{
640+
rec->mainFile->increaseRecordCount();
641+
rec->timestampFile->increaseRecordCount();
642+
if (rec->extraFile) rec->extraFile->increaseRecordCount();
643+
if (rec->channelFile) rec->channelFile->increaseRecordCount();
644+
if (rec->metaDataFile) rec->metaDataFile->increaseRecordCount();
634645
}
635646

636647
RecordEngineManager* BinaryRecording::getEngineManager()

Source/Plugins/BinaryWriter/BinaryRecording.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace BinaryRecordingEngine
8484
NpyFile* createEventMetadataFile(const MetaDataEventObject* channel, String fileName, DynamicObject* jsonObject);
8585
void createChannelMetaData(const MetaDataInfoObject* channel, DynamicObject* jsonObject);
8686
void writeEventMetaData(const MetaDataEvent* event, NpyFile* file);
87+
void increaseEventCounts(EventRecording* rec);
8788
static String jsonTypeValue(BaseType type);
8889

8990
SpikeMode m_spikeMode;

0 commit comments

Comments
 (0)