Skip to content

Commit b4150a3

Browse files
committed
Merge branch 'write-gen-ts' into development-juce8
2 parents 55fe439 + 6115f1d commit b4150a3

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,11 +903,20 @@ void RecordNode::process (AudioBuffer<float>& buffer)
903903

904904
float totalFifoUsage = 0.0f;
905905

906+
double first, second;
907+
906908
if (numSamples > 0)
907909
{
908-
double first = synchronizer.convertSampleNumberToTimestamp (streamKey, sampleNumber);
909-
double second = synchronizer.convertSampleNumberToTimestamp (streamKey, sampleNumber + 1);
910-
910+
if (!stream->generatesTimestamps())
911+
{
912+
first = synchronizer.convertSampleNumberToTimestamp (streamKey, sampleNumber);
913+
second = synchronizer.convertSampleNumberToTimestamp (streamKey, sampleNumber + 1);
914+
}
915+
else
916+
{
917+
first = getFirstTimestampForBlock (streamId);
918+
second = first + 1 / stream->getSampleRate();
919+
}
911920
dataQueue->writeSynchronizedTimestamps (
912921
first,
913922
second - first,

Source/Processors/Settings/DataStream.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ DataStream::DataStream (DataStream::Settings settings)
3434
: InfoObject (InfoObject::Type::DATASTREAM_INFO),
3535
ParameterOwner (ParameterOwner::Type::DATASTREAM),
3636
m_sample_rate (settings.sample_rate),
37+
m_generates_timestamps (settings.generates_timestamps),
3738
device (nullptr)
3839
{
3940
setName (settings.name);
@@ -88,6 +89,11 @@ float DataStream::getSampleRate() const
8889
return m_sample_rate;
8990
}
9091

92+
bool DataStream::generatesTimestamps() const
93+
{
94+
return m_generates_timestamps;
95+
}
96+
9197
int DataStream::getChannelCount() const
9298
{
9399
return continuousChannels.size();

Source/Processors/Settings/DataStream.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class PLUGIN_API DataStream : public InfoObject,
8080
String identifier;
8181

8282
float sample_rate;
83+
bool generates_timestamps;
8384
};
8485

8586
/** Constructor */
@@ -118,6 +119,9 @@ class PLUGIN_API DataStream : public InfoObject,
118119
/** Returns true if this DataStream has a device associated with it.*/
119120
bool hasDevice() const;
120121

122+
/** Returns true if this DataStream generates timestamps. */
123+
bool generatesTimestamps() const;
124+
121125
/** Gets all of the continuous channels for this stream.*/
122126
Array<ContinuousChannel*> getContinuousChannels() const;
123127

@@ -137,6 +141,7 @@ class PLUGIN_API DataStream : public InfoObject,
137141
Array<SpikeChannel*> spikeChannels;
138142

139143
float m_sample_rate;
144+
bool m_generates_timestamps;
140145

141146
uint16 streamId;
142147
};

0 commit comments

Comments
 (0)