diff --git a/Source/Processors/GenericProcessor/GenericProcessor.cpp b/Source/Processors/GenericProcessor/GenericProcessor.cpp index a7751d134ac144be71002786550e570767511267..ca570f0f31096dc8b762bfd9c6cfb0d53a71e323 100755 --- a/Source/Processors/GenericProcessor/GenericProcessor.cpp +++ b/Source/Processors/GenericProcessor/GenericProcessor.cpp @@ -29,7 +29,8 @@ GenericProcessor::GenericProcessor(const String& name_) : AccessClass(), sourceNode(0), destNode(0), isEnabled(true), wasConnected(false), nextAvailableChannel(0), saveOrder(-1), loadOrder(-1), currentChannel(-1), - editor(0), parametersAsXml(nullptr), sendSampleCount(true), name(name_), paramsWereLoaded(false) + editor(0), parametersAsXml(nullptr), sendSampleCount(true), name(name_), + paramsWereLoaded(false), needsToSendTimestampMessage(false) { settings.numInputs = settings.numOutputs = settings.sampleRate = 0; @@ -480,12 +481,17 @@ void GenericProcessor::setRecording(bool state) if (ed != 0) ed->startRecording(); startRecording(); + if (generatesTimestamps()) + { + needsToSendTimestampMessage = true; + } } else { if (ed != 0) ed->stopRecording(); stopRecording(); + needsToSendTimestampMessage = false; } } @@ -608,6 +614,23 @@ void GenericProcessor::setTimestamp(MidiBuffer& events, int64 timestamp) //since the processor generating the timestamp won't get the event, add it to the map timestamps[nodeId] = timestamp; + + if (needsToSendTimestampMessage) + { + String eventString = "Processor: " + String(getNodeId()) + " start time: " + String(timestamp); + + CharPointer_UTF8 data = eventString.toUTF8(); + + addEvent(events, + MESSAGE, + 0, + 0, + 0, + data.length() + 1, //It doesn't hurt to send the end-string null and can help avoid issues + (uint8*)data.getAddress()); + + needsToSendTimestampMessage = false; + } } int GenericProcessor::processEventBuffer(MidiBuffer& events) diff --git a/Source/Processors/GenericProcessor/GenericProcessor.h b/Source/Processors/GenericProcessor/GenericProcessor.h index c8fe794bd0563bd7a5eedbe2e327505e55f02d19..9da3ee59692635cd9b74bd295ad4614b991325ae 100755 --- a/Source/Processors/GenericProcessor/GenericProcessor.h +++ b/Source/Processors/GenericProcessor/GenericProcessor.h @@ -675,7 +675,7 @@ private: static const String unusedNameString; bool paramsWereLoaded; - + bool needsToSendTimestampMessage; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(GenericProcessor); diff --git a/Source/Processors/MessageCenter/MessageCenter.cpp b/Source/Processors/MessageCenter/MessageCenter.cpp index bd22f88d09471f9aad6dc253705c34fe1fcaad83..9c736f5c97d028c73b213cde28b6fe71fe8eccdb 100644 --- a/Source/Processors/MessageCenter/MessageCenter.cpp +++ b/Source/Processors/MessageCenter/MessageCenter.cpp @@ -109,9 +109,9 @@ int MessageCenter::getSourceNodeId() return sourceNodeId; } -int64 MessageCenter::getTimestamp() +int64 MessageCenter::getTimestamp(bool softwareTime) { - if (sourceNodeId > 0) + if (!softwareTime && sourceNodeId > 0) return timestampSource->getTimestamp(0); else return (Time::currentTimeMillis() - msTime); @@ -120,6 +120,22 @@ int64 MessageCenter::getTimestamp() void MessageCenter::process(AudioSampleBuffer& buffer, MidiBuffer& eventBuffer) { setTimestamp(eventBuffer,getTimestamp()); + if (needsToSendTimestampMessage) + { + String eventString = "Software time: " + String(getTimestamp(true)); + CharPointer_UTF8 data = eventString.toUTF8(); + + addEvent(eventBuffer, + MESSAGE, + 0, + 0, + 0, + data.length() + 1, //It doesn't hurt to send the end-string null and can help avoid issues + (uint8*)data.getAddress()); + + needsToSendTimestampMessage = false; + } + if (newEventAvailable) { int numBytes = 0; @@ -127,7 +143,6 @@ void MessageCenter::process(AudioSampleBuffer& buffer, MidiBuffer& eventBuffer) String eventString = messageCenterEditor->getLabelString(); CharPointer_UTF8 data = eventString.toUTF8(); - int realId = getNodeId(); addEvent(eventBuffer, MESSAGE, diff --git a/Source/Processors/MessageCenter/MessageCenter.h b/Source/Processors/MessageCenter/MessageCenter.h index 6e46899839c9a6ea5fb3a6d6b6d066031e6abedf..084f96b2a9248d80a7ca2d433a85e8204196c059 100644 --- a/Source/Processors/MessageCenter/MessageCenter.h +++ b/Source/Processors/MessageCenter/MessageCenter.h @@ -67,10 +67,12 @@ public: void startRecording() { isRecording = true; + needsToSendTimestampMessage = true; } void stopRecording() { isRecording = false; + needsToSendTimestampMessage = false; } void setSourceNodeId(int id); @@ -79,7 +81,7 @@ public: void addSourceProcessor(GenericProcessor* p); void removeSourceProcessor(GenericProcessor* p); - int64 getTimestamp(); + int64 getTimestamp(bool softwareTime = false); private: bool newEventAvailable; @@ -87,6 +89,7 @@ private: int sourceNodeId; GenericProcessor* timestampSource; int64 msTime; + bool needsToSendTimestampMessage; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MessageCenter);