Skip to content
Snippets Groups Projects
Commit 9e356417 authored by Aaron Cuevas Lopez's avatar Aaron Cuevas Lopez
Browse files

Change software timestamp from ms to high resolution timer

parent 1ab5a351
Branches
Tags
No related merge requests found
......@@ -623,7 +623,7 @@ void GenericProcessor::setTimestamp(MidiBuffer& events, int64 timestamp)
if (needsToSendTimestampMessage)
{
String eventString = "Processor: " + String(getNodeId()) + " start time: " + String(timestamp);
String eventString = "Processor: " + String(getNodeId()) + " start time: " + String(timestamp) + "@" + String(getSampleRate()) + "Hz";
CharPointer_UTF8 data = eventString.toUTF8();
......
......@@ -29,7 +29,8 @@
//---------------------------------------------------------------------
MessageCenter::MessageCenter() :
GenericProcessor("Message Center"), newEventAvailable(false), isRecording(false), sourceNodeId(0), msTime(0), timestampSource(nullptr)
GenericProcessor("Message Center"), newEventAvailable(false), isRecording(false), sourceNodeId(0),
lastTime(0), softTimestamp(0), timestampSource(nullptr)
{
setPlayConfigDetails(0, // number of inputs
......@@ -73,7 +74,8 @@ void MessageCenter::setParameter(int parameterIndex, float newValue)
bool MessageCenter::enable()
{
messageCenterEditor->startAcquisition();
msTime = Time::currentTimeMillis();
lastTime = Time::getHighResolutionTicks();
softTimestamp = 0;
if (sourceNodeId)
{
AudioProcessorGraph::Node* node = AccessClass::getProcessorGraph()->getNodeForId(sourceNodeId);
......@@ -115,15 +117,16 @@ int64 MessageCenter::getTimestamp(bool softwareTime)
if (!softwareTime && sourceNodeId > 0)
return timestampSource->getTimestamp(0);
else
return (Time::currentTimeMillis() - msTime);
return (softTimestamp);
}
void MessageCenter::process(AudioSampleBuffer& buffer, MidiBuffer& eventBuffer)
{
softTimestamp = Time::getHighResolutionTicks() - lastTime;
setTimestamp(eventBuffer,getTimestamp());
if (needsToSendTimestampMessage)
{
String eventString = "Software time: " + String(getTimestamp(true));
String eventString = "Software time: " + String(getTimestamp(true)) + "@" + String(Time::getHighResolutionTicksPerSecond()) + "Hz";
CharPointer_UTF8 data = eventString.toUTF8();
addEvent(eventBuffer,
......
......@@ -88,7 +88,7 @@ private:
bool isRecording;
int sourceNodeId;
GenericProcessor* timestampSource;
int64 msTime;
int64 lastTime, softTimestamp;
bool needsToSendTimestampMessage;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MessageCenter);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment