Skip to content

Commit 7cc5e22

Browse files
committed
Reconnect message center to record nodes
1 parent c9cb133 commit 7cc5e22

4 files changed

Lines changed: 58 additions & 37 deletions

File tree

Resources/Python/record_control_example_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ def run_client():
7777

7878

7979
if __name__ == '__main__':
80-
run_client()
80+
run_client()

Source/Processors/ProcessorGraph/ProcessorGraph.cpp

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ void ProcessorGraph::clearConnections()
266266

267267
}
268268

269-
/*
270-
addConnection(MESSAGE_CENTER_ID, midiChannelIndex,
271-
RECORD_NODE_ID, midiChannelIndex);
272-
*/
269+
for (auto& recordNode : getRecordNodes())
270+
addConnection(MESSAGE_CENTER_ID, midiChannelIndex,
271+
recordNode->getNodeId(), midiChannelIndex);
272+
273273
}
274274

275275

@@ -278,10 +278,6 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
278278

279279
clearConnections(); // clear processor graph
280280

281-
std::cout << "Updating connections:" << std::endl;
282-
std::cout << std::endl;
283-
std::cout << std::endl;
284-
285281
Array<GenericProcessor*> splitters;
286282

287283
// keep track of which splitter is currently being explored, in case there's another
@@ -453,10 +449,13 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
453449
}
454450

455451
getAudioNode()->updatePlaybackBuffer();
456-
//Update RecordNode internal channel mappings
452+
457453
Array<EventChannel*> extraChannels;
458454
getMessageCenter()->addSpecialProcessorChannels(extraChannels);
459-
//getRecordNode()->addSpecialProcessorChannels(extraChannels);
455+
456+
for (auto& recordNode : getRecordNodes())
457+
recordNode->addSpecialProcessorChannels(extraChannels);
458+
460459
} // end method
461460

462461
void ProcessorGraph::connectProcessors(GenericProcessor* source, GenericProcessor* dest,
@@ -492,12 +491,6 @@ void ProcessorGraph::connectProcessors(GenericProcessor* source, GenericProcesso
492491
midiChannelIndex); // destNodeChannelIndex
493492
}
494493

495-
// 3. connect record nodes
496-
if (dest->isRecordNode())
497-
{
498-
((RecordNode*)dest)->registerProcessor(source);
499-
}
500-
501494
}
502495

503496
void ProcessorGraph::connectProcessorToAudioNode(GenericProcessor* source)
@@ -748,15 +741,6 @@ bool ProcessorGraph::disableProcessors()
748741

749742
void ProcessorGraph::setRecordState(bool isRecording)
750743
{
751-
// actually start recording
752-
if (isRecording)
753-
{
754-
//getRecordNode()->setParameter(1,10.0f);
755-
}
756-
else
757-
{
758-
//getRecordNode()->setParameter(0,10.0f);
759-
}
760744

761745
for (int i = 0; i < getNumNodes(); i++)
762746
{
@@ -769,7 +753,6 @@ void ProcessorGraph::setRecordState(bool isRecording)
769753
}
770754
}
771755

772-
773756
}
774757

775758

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,45 @@ RecordNode::~RecordNode()
6666
{
6767
}
6868

69+
void RecordNode::addInputChannel(const GenericProcessor* sourceNode, int chan)
70+
{
71+
72+
if (chan != AccessClass::getProcessorGraph()->midiChannelIndex)
73+
{
74+
int channelIndex = getNextChannel(false);
75+
76+
const DataChannel* orig = sourceNode->getDataChannel(chan);
77+
DataChannel* newChannel = new DataChannel(*orig);
78+
newChannel->setRecordState(orig->getRecordState());
79+
dataChannelArray.add(newChannel);
80+
recordEngine->addDataChannel(channelIndex, dataChannelArray[channelIndex]);
81+
82+
}
83+
else
84+
{
85+
86+
for (int n = 0; n < sourceNode->getTotalEventChannels(); n++)
87+
{
88+
const EventChannel* orig = sourceNode->getEventChannel(n);
89+
//only add to the record node the events originating from this processor, to avoid duplicates
90+
if (orig->getSourceNodeID() == sourceNode->getNodeId())
91+
eventChannelArray.add(new EventChannel(*orig));
92+
93+
}
94+
95+
}
96+
97+
}
98+
99+
void RecordNode::addSpecialProcessorChannels(Array<EventChannel*>& channels)
100+
{
101+
102+
eventChannelArray.addArray(channels);
103+
settings.numInputs = dataChannelArray.size();
104+
setPlayConfigDetails(getNumInputs(), getNumOutputs(), 44100.0, 1024);
105+
106+
}
107+
69108
void RecordNode::setEngine(int index)
70109
{
71110
availableEngines = getAvailableRecordEngines();
@@ -373,7 +412,7 @@ void RecordNode::startRecording()
373412

374413
int recordedProcessorIdx = -1;
375414

376-
LOGD("Record Node ", getNodeId(), ": Total channels: ", totChans);
415+
//LOGD("Record Node ", getNodeId(), ": Total channels: ", totChans, " Total event channels: ", getTotalEventChannels());
377416

378417
for (int ch = 0; ch < totChans; ++ch)
379418
{
@@ -506,15 +545,15 @@ void RecordNode::handleEvent(const EventChannel* eventInfo, const MidiMessage& e
506545
int64 timestamp = Event::getTimestamp(event);
507546
uint64 eventChan = event.getChannel();
508547
int eventIndex;
509-
if (eventInfo && samplePosition > 0)
510-
{
548+
if (eventInfo)
511549
eventIndex = getEventChannelIndex(Event::getSourceIndex(event), Event::getSourceID(event), Event::getSubProcessorIdx(event));
512-
synchronizer->addEvent(Event::getSourceID(event), Event::getSubProcessorIdx(event), eventIndex, timestamp);
513-
}
514550
else
515551
eventIndex = -1;
516552

517-
if (isRecording && eventIndex >= 0)
553+
if (samplePosition)
554+
synchronizer->addEvent(Event::getSourceID(event), Event::getSubProcessorIdx(event), eventIndex, timestamp);
555+
556+
if (isRecording)
518557
eventQueue->addEvent(event, timestamp, eventIndex);
519558

520559
}
@@ -626,13 +665,10 @@ bool RecordNode::isFirstChannelInRecordedSubprocessor(int ch)
626665
return std::find(startRecChannels.begin(), startRecChannels.end(), ch) != startRecChannels.end();
627666
}
628667

629-
//TODO: Need to validate these methods
630-
631668
void RecordNode::registerProcessor(const GenericProcessor* sourceNode)
632669
{
633670
settings.numInputs += sourceNode->getNumOutputs();
634671
setPlayConfigDetails(getNumInputs(), getNumOutputs(), 44100.0, 128);
635-
636672
recordEngine->registerProcessor(sourceNode);
637673
}
638674

Source/Processors/RecordNode/RecordNode.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class RecordNode : public GenericProcessor, public FilenameComponentListener
5252
AudioProcessorEditor* createEditor() override;
5353
bool hasEditor() const override { return true; }
5454

55-
55+
void addSpecialProcessorChannels(Array<EventChannel*>& channels);
56+
5657
void updateSubprocessorMap();
5758
void setMasterSubprocessor(int srcIdx, int subProcIdx);
5859
bool isMasterSubprocessor(int srcIdx, int subProcIdx);
@@ -120,6 +121,7 @@ class RecordNode : public GenericProcessor, public FilenameComponentListener
120121
bool isSyncReady;
121122

122123
//TODO: Need to validate these new methods
124+
void addInputChannel(const GenericProcessor* sourceNode, int chan);
123125

124126
/** Must be called by a spike recording source on the "enable" method
125127
*/

0 commit comments

Comments
 (0)