Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Source/Processors/RecordNode/BinaryFormat/BinaryRecording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,19 +672,18 @@ void BinaryRecording::writeSpike (int electrodeIndex, const Spike* spike)
increaseEventCounts (rec);
}

void BinaryRecording::writeTimestampSyncText (uint64 streamId, int64 sampleNumber, float sourceSampleRate, String text)
void BinaryRecording::writeTimestampSyncText(DataStream* stream, int64 sampleNumber, double timestamp, String text)
{
if (! m_syncTextFile)
return;

String syncString = text + ": " + String (sampleNumber);
LOGD (syncString);

int64 fsn = firstSampleNumber[streamId];

if(streamId > 0)
if(stream != nullptr){
int64 fsn = firstSampleNumber[stream->getStreamId()];
jassert (fsn == sampleNumber);

}
m_syncTextFile->writeText (syncString + "\r\n", false, false, nullptr);

m_syncTextFile->flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BinaryRecording : public RecordEngine
void writeSpike (int electrodeIndex, const Spike* spike);

/** Writes timestamp sync texts */
void writeTimestampSyncText (uint64 streamId, int64 sampleNumber, float sampleRate, String text);
void writeTimestampSyncText (DataStream* stream, int64 sampleNumber, double timestamp, String text);

/** Sets an engine parameter (in this case TTL word writing bool) */
void setParameter (EngineParameter& parameter);
Expand Down
5 changes: 5 additions & 0 deletions Source/Processors/RecordNode/RecordEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ int RecordEngine::getLocalIndex (int channel) const
return localChannelMap[channel];
}

Array<const DataStream*> RecordEngine::getDataStreams() const
{
return recordNode->getDataStreams();
}

int RecordEngine::getNumRecordedDataStreams() const
{
return recordNode->getTotalRecordedStreams();
Expand Down
7 changes: 5 additions & 2 deletions Source/Processors/RecordNode/RecordEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class PLUGIN_API RecordEngine
/** Write a spike to disk */
virtual void writeSpike (int electrodeIndex, const Spike* spike) = 0;

/** Handle the timestamp sync text messages*/
virtual void writeTimestampSyncText (uint64 streamId, int64 timestamp, float sourceSampleRate, String text) = 0;
/** Handle the timestamp sync text messages. */
virtual void writeTimestampSyncText (DataStream* stream, int64 sampleNumber, double timestamp, String text) = 0;

// ------------------------------------------------------------
// VIRTUAL METHODS
Expand Down Expand Up @@ -145,6 +145,9 @@ class PLUGIN_API RecordEngine
/** Gets the number of recorded data streams */
int getNumRecordedDataStreams() const;

/** Gets all the data streams, regardless of whether they have any recordable channels */
Array<const DataStream*> getDataStreams() const;

/** Gets the number of recorded continuous channels */
int getNumRecordedContinuousChannels() const;

Expand Down
14 changes: 13 additions & 1 deletion Source/Processors/RecordNode/RecordThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,19 @@ void RecordThread::writeData (const AudioBuffer<float>& dataBuffer,
if (SystemEvent::getBaseType (event) == EventBase::Type::SYSTEM_EVENT)
{
String syncText = SystemEvent::getSyncText (event);
m_engine->writeTimestampSyncText (SystemEvent::getStreamId (event), SystemEvent::getSampleNumber (event), 0.0f, SystemEvent::getSyncText (event));
auto streamId = SystemEvent::getStreamId (event);
DataStream* stream = recordNode->getDataStream(streamId);
int64 sampleNumber = SystemEvent::getSampleNumber (event);

double timestamp;
if (stream == nullptr){
timestamp = 0;
} else if(recordNode->synchronizer.streamGeneratesTimestamps (stream->getKey())){
timestamp = static_cast<double>(sampleNumber) / stream->getSampleRate();
} else {
timestamp = recordNode->synchronizer.convertSampleNumberToTimestamp (stream->getKey(), sampleNumber);
}
m_engine->writeTimestampSyncText (stream, sampleNumber, timestamp, SystemEvent::getSyncText (event));
}
else
{
Expand Down