Skip to content

Commit fb6a6fe

Browse files
committed
Connect to MessageCenter from RecordNode and ignore any duplicate messages
1 parent 24a3f4a commit fb6a6fe

6 files changed

Lines changed: 46 additions & 6 deletions

File tree

Source/Processors/MessageCenter/MessageCenter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ AudioProcessorEditor* MessageCenter::createEditor()
6363

6464
}
6565

66+
const EventChannel* MessageCenter::getMessageChannel()
67+
{
68+
return getEventChannel(0);
69+
}
70+
6671
void MessageCenter::setParameter(int parameterIndex, float newValue)
6772
{
6873
if (isRecording)

Source/Processors/MessageCenter/MessageCenter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class MessageCenter : public GenericProcessor
6161
/** A pointer to the Message Center editor. */
6262
ScopedPointer<MessageCenterEditor> messageCenterEditor;
6363

64+
const EventChannel* getMessageChannel();
65+
6466
bool enable() override;
6567
bool disable() override;
6668

Source/Processors/MessageCenter/MessageCenterEditor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class MessageCenterEditor : public AudioProcessorEditor,
6464

6565
String getLabelString();
6666

67+
MessageCenter* messageCenter;
68+
6769
private:
6870

6971
void buttonClicked(Button* button);
@@ -85,8 +87,6 @@ class MessageCenterEditor : public AudioProcessorEditor,
8587
/** A JUCE button used to send messages. */
8688
ScopedPointer<Button> sendMessageButton;
8789

88-
MessageCenter* messageCenter;
89-
9090
Colour incomingBackground;
9191
Colour outgoingBackground;
9292

Source/Processors/ProcessorGraph/ProcessorGraph.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,16 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
447447
connectProcessors(conn.source, dest, conn.connectContinuous, conn.connectEvents);
448448
}
449449
}
450+
451+
Array<EventChannel*> extraChannels;
452+
getMessageCenter()->addSpecialProcessorChannels(extraChannels);
450453

451454
getAudioNode()->updatePlaybackBuffer();
452455

453-
Array<EventChannel*> extraChannels;
454-
getMessageCenter()->addSpecialProcessorChannels(extraChannels);
455-
456+
/*
456457
for (auto& recordNode : getRecordNodes())
457458
recordNode->addSpecialProcessorChannels(extraChannels);
459+
*/
458460

459461
} // end method
460462

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "../../UI/EditorViewport.h"
44
#include "../../UI/ControlPanel.h"
5+
#include "../../Processors/MessageCenter/MessageCenterEditor.h"
56
#include "BinaryFormat/BinaryRecording.h"
67
#include "OpenEphysFormat/OriginalRecording.h"
78

@@ -40,7 +41,8 @@ RecordNode::RecordNode()
4041
hasRecorded(false),
4142
settingsNeeded(false),
4243
receivedSoftwareTime(false),
43-
numSubprocessors(0)
44+
numSubprocessors(0),
45+
isConnectedToMessageCenter(false)
4446
{
4547
setProcessorType(PROCESSOR_TYPE_RECORD_NODE);
4648

@@ -69,6 +71,16 @@ RecordNode::~RecordNode()
6971
{
7072
}
7173

74+
void RecordNode::connectToMessageCenter()
75+
{
76+
77+
const EventChannel* orig = AccessClass::getMessageCenter()->messageCenter->getEventChannel(0);
78+
eventChannelArray.add(new EventChannel(*orig));
79+
80+
isConnectedToMessageCenter = true;
81+
82+
}
83+
7284
void RecordNode::addInputChannel(const GenericProcessor* sourceNode, int chan)
7385
{
7486
// not getting called
@@ -341,6 +353,8 @@ void RecordNode::updateSubprocessorMap()
341353
eventMap.clear();
342354
syncChannelMap.clear();
343355
syncOrderMap.clear();
356+
357+
LOGD("Record Node: ", getNodeId(), " has ", eventChannelArray.size(), " channels");
344358
for (int ch = 0; ch < eventChannelArray.size(); ch++)
345359
{
346360

@@ -483,6 +497,9 @@ void RecordNode::startRecording()
483497

484498
hasRecorded = true;
485499

500+
if (!isConnectedToMessageCenter)
501+
connectToMessageCenter();
502+
486503
/* Set write properties */
487504
setFirstBlock = false;
488505

@@ -557,6 +574,15 @@ void RecordNode::setRecordSpikes(bool recordSpikes)
557574
void RecordNode::handleEvent(const EventChannel* eventInfo, const MidiMessage& event, int samplePosition)
558575
{
559576

577+
//Ignore any duplicate messages from MessageCenter
578+
if (Event::getSourceID(event) > 900)
579+
{
580+
if (!msgCenterMessages.contains(Event::getTimestamp(event)))
581+
msgCenterMessages.add(Event::getTimestamp(event));
582+
else
583+
return;
584+
}
585+
560586
eventMonitor->receivedEvents++;
561587

562588
if (recordEvents)

Source/Processors/RecordNode/RecordNode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class RecordNode : public GenericProcessor, public FilenameComponentListener
4949
RecordNode();
5050
~RecordNode();
5151

52+
void connectToMessageCenter();
53+
5254
void updateRecordChannelIndexes();
5355

5456
AudioProcessorEditor* createEditor() override;
@@ -167,6 +169,9 @@ class RecordNode : public GenericProcessor, public FilenameComponentListener
167169

168170
private:
169171

172+
bool isConnectedToMessageCenter;
173+
Array<int64> msgCenterMessages;
174+
170175
bool useSynchronizer;
171176

172177
bool receivedSoftwareTime;

0 commit comments

Comments
 (0)