Skip to content

Commit 57f273e

Browse files
committed
Fix issues with Message Center not communicating with Record Nodes
1 parent c431173 commit 57f273e

5 files changed

Lines changed: 57 additions & 14 deletions

File tree

Source/Processors/MessageCenter/MessageCenter.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,35 @@ GenericProcessor("Message Center"), newEventAvailable(false), isRecording(false)
3636
0, // number of outputs
3737
44100.0, // sampleRate
3838
128); // blockSize
39+
40+
eventChannel = nullptr;
41+
3942
}
4043

4144
MessageCenter::~MessageCenter()
4245
{
4346

4447
}
4548

46-
void MessageCenter::addSpecialProcessorChannels(Array<EventChannel*>& channels)
49+
void MessageCenter::addSpecialProcessorChannels()
4750
{
48-
clearSettings();
49-
EventChannel* chan = new EventChannel(EventChannel::TEXT, 1, MAX_MSG_LENGTH, CoreServices::getGlobalSampleRate(), this, 0);
50-
chan->setName("GUI Messages");
51-
chan->setDescription("Messages from the GUI Message Center");
52-
channels.add(chan);
53-
eventChannelArray.add(new EventChannel(*chan));
54-
updateChannelIndexes();
51+
52+
if (eventChannel == nullptr)
53+
{
54+
clearSettings();
55+
56+
eventChannel = new EventChannel(EventChannel::TEXT,
57+
1,
58+
MAX_MSG_LENGTH,
59+
CoreServices::getGlobalSampleRate(),
60+
this, 0);
61+
62+
eventChannel->setName("GUI Messages");
63+
eventChannel->setDescription("Messages from the GUI Message Center");
64+
eventChannelArray.add(new EventChannel(*eventChannel));
65+
66+
updateChannelIndexes();
67+
}
5568
}
5669

5770
AudioProcessorEditor* MessageCenter::createEditor()
@@ -119,6 +132,8 @@ void MessageCenter::process(AudioSampleBuffer& buffer)
119132
TextEventPtr event = TextEvent::createTextEvent(getEventChannel(0), CoreServices::getGlobalTimestamp(), eventString);
120133
addEvent(getEventChannel(0), event, 0);
121134

135+
std::cout << "Message Center added event." << std::endl;
136+
122137
newEventAvailable = false;
123138
}
124139

Source/Processors/MessageCenter/MessageCenter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ class MessageCenter : public GenericProcessor
7777
needsToSendTimestampMessage = false;
7878
}
7979

80-
void addSpecialProcessorChannels(Array<EventChannel*>& channel);
80+
void addSpecialProcessorChannels();
8181
private:
8282

8383
bool newEventAvailable;
8484
bool isRecording;
8585
bool needsToSendTimestampMessage;
8686

87+
ScopedPointer<EventChannel> eventChannel;
88+
8789
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MessageCenter);
8890

8991
};

Source/Processors/ProcessorGraph/ProcessorGraph.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
346346
//TODO: This is will be removed when probe based audio node added.
347347
connectProcessorToAudioNode(source);
348348

349+
//if (source->isRecordNode())
350+
// connectProcessorToMessageCenter(source);
351+
349352
// find the next dest that's not a merger or splitter
350353
GenericProcessor* prev = source;
351354

@@ -448,8 +451,8 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
448451
}
449452
}
450453

451-
Array<EventChannel*> extraChannels;
452-
getMessageCenter()->addSpecialProcessorChannels(extraChannels);
454+
//OwnedArray<EventChannel> extraChannels;
455+
getMessageCenter()->addSpecialProcessorChannels();
453456

454457
getAudioNode()->updatePlaybackBuffer();
455458

@@ -555,6 +558,19 @@ void ProcessorGraph::connectProcessorToAudioNode(GenericProcessor* source)
555558

556559
}
557560

561+
562+
void ProcessorGraph::connectProcessorToMessageCenter(GenericProcessor* source)
563+
{
564+
565+
// connect event channel
566+
addConnection(getMessageCenter()->getNodeId(), // sourceNodeID
567+
midiChannelIndex, // sourceNodeChannelIndex
568+
source->getNodeId(), // destNodeID
569+
midiChannelIndex); // destNodeChannelIndex
570+
571+
}
572+
573+
558574
GenericProcessor* ProcessorGraph::createProcessorFromDescription(Array<var>& description)
559575
{
560576
GenericProcessor* processor = nullptr;

Source/Processors/ProcessorGraph/ProcessorGraph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class ProcessorGraph : public AudioProcessorGraph
119119
void connectProcessors(GenericProcessor* source, GenericProcessor* dest,
120120
bool connectContinuous, bool connectEvents);
121121
void connectProcessorToAudioNode(GenericProcessor* source);
122+
void connectProcessorToMessageCenter(GenericProcessor* source);
122123

123124
int64 m_startSoftTimestamp{ 0 };
124125
const GenericProcessor* m_timestampSource{ nullptr };

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ RecordNode::~RecordNode()
7474
void RecordNode::connectToMessageCenter()
7575
{
7676

77-
const EventChannel* orig = AccessClass::getMessageCenter()->messageCenter->getEventChannel(0);
77+
const EventChannel* orig = AccessClass::getMessageCenter()->messageCenter->getMessageChannel();
7878
eventChannelArray.add(new EventChannel(*orig));
7979

8080
isConnectedToMessageCenter = true;
8181

82+
std::cout << "Record node " << getNodeId() << " connected to Message Center" << std::endl;
83+
8284
}
8385

8486
void RecordNode::addInputChannel(const GenericProcessor* sourceNode, int chan)
@@ -280,6 +282,7 @@ void RecordNode::updateChannelStates(int srcIndex, int subProcIdx, std::vector<b
280282

281283
void RecordNode::updateSubprocessorMap()
282284
{
285+
283286

284287
std::map<int, std::vector<int>> inputs;
285288

@@ -411,6 +414,8 @@ void RecordNode::updateSettings()
411414
bool RecordNode::enable()
412415
{
413416

417+
connectToMessageCenter();
418+
414419
if (hasRecorded)
415420
{
416421
hasRecorded = false;
@@ -497,8 +502,7 @@ void RecordNode::startRecording()
497502

498503
hasRecorded = true;
499504

500-
if (!isConnectedToMessageCenter)
501-
connectToMessageCenter();
505+
502506

503507
/* Set write properties */
504508
setFirstBlock = false;
@@ -575,7 +579,10 @@ void RecordNode::handleEvent(const EventChannel* eventInfo, const MidiMessage& e
575579
if (Event::getSourceID(event) > 900)
576580
{
577581
if (!msgCenterMessages.contains(Event::getTimestamp(event)))
582+
{
578583
msgCenterMessages.add(Event::getTimestamp(event));
584+
std::cout << "Received event." << std::endl;
585+
}
579586
else
580587
return;
581588
}
@@ -584,6 +591,8 @@ void RecordNode::handleEvent(const EventChannel* eventInfo, const MidiMessage& e
584591

585592
if (recordEvents)
586593
{
594+
595+
587596
int64 timestamp = Event::getTimestamp(event);
588597
uint64 eventChan = event.getChannel();
589598
int eventIndex;

0 commit comments

Comments
 (0)