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

Make Lfp Viewer able to detect source channel from event metadata

parent de811b89
No related branches found
No related tags found
No related merge requests found
...@@ -67,7 +67,7 @@ void LfpDisplayNode::updateSettings() ...@@ -67,7 +67,7 @@ void LfpDisplayNode::updateSettings()
for (int i = 0; i < eventChannelArray.size(); ++i) for (int i = 0; i < eventChannelArray.size(); ++i)
{ {
uint32 sourceID = getProcessorFullId(eventChannelArray[i]->getSourceNodeID(), eventChannelArray[i]->getSubProcessorIdx()); uint32 sourceID = getChannelSourceID(eventChannelArray[i]);
if (! eventSourceNodes.contains (sourceID )) if (! eventSourceNodes.contains (sourceID ))
{ {
eventSourceNodes.add (sourceID); eventSourceNodes.add (sourceID);
...@@ -93,6 +93,17 @@ void LfpDisplayNode::updateSettings() ...@@ -93,6 +93,17 @@ void LfpDisplayNode::updateSettings()
displayBufferIndex.insertMultiple (0, 0, getNumInputs() + numEventChannels); displayBufferIndex.insertMultiple (0, 0, getNumInputs() + numEventChannels);
} }
uint32 LfpDisplayNode::getChannelSourceID(const EventChannel* event) const
{
int metaDataIndex = event->findMetaData(MetaDataDescriptor::UINT16, 3, "source.channel.identifier.full");
if (metaDataIndex < 0)
{
return getProcessorFullId(event->getSourceNodeID(), event->getSubProcessorIdx());
}
uint16 values[3];
event->getMetaDataValue(metaDataIndex)->getValue(static_cast<uint16*>(values));
return getProcessorFullId(values[1], values[2]);
}
bool LfpDisplayNode::resizeBuffer() bool LfpDisplayNode::resizeBuffer()
{ {
...@@ -162,8 +173,8 @@ void LfpDisplayNode::handleEvent(const EventChannel* eventInfo, const MidiMessag ...@@ -162,8 +173,8 @@ void LfpDisplayNode::handleEvent(const EventChannel* eventInfo, const MidiMessag
const int eventId = ttl->getState() ? 1 : 0; const int eventId = ttl->getState() ? 1 : 0;
const int eventChannel = ttl->getChannel(); const int eventChannel = ttl->getChannel();
const int eventTime = samplePosition; const int eventTime = samplePosition;
const uint32 eventSourceNodeId = getProcessorFullId(ttl->getSourceID(), ttl->getSubProcessorIdx()); const uint32 eventSourceNodeId = getChannelSourceID(eventInfo);
const int nSamples = getNumSourceSamples (eventSourceNodeId); const int nSamples = getNumSourceSamples(eventSourceNodeId);
int samplesToFill = nSamples - eventTime; int samplesToFill = nSamples - eventTime;
if (samplesToFill < 0) samplesToFill = 0; if (samplesToFill < 0) samplesToFill = 0;
......
...@@ -89,6 +89,8 @@ private: ...@@ -89,6 +89,8 @@ private:
CriticalSection displayMutex; CriticalSection displayMutex;
uint32 getChannelSourceID(const EventChannel* event) const;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LfpDisplayNode); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LfpDisplayNode);
}; };
......
...@@ -167,13 +167,14 @@ void PhaseDetector::updateSettings() ...@@ -167,13 +167,14 @@ void PhaseDetector::updateSettings()
uint16 sourceInfo[3]; uint16 sourceInfo[3];
sourceInfo[0] = in->getSourceIndex(); sourceInfo[0] = in->getSourceIndex();
sourceInfo[1] = in->getSourceNodeID(); sourceInfo[1] = in->getSourceNodeID();
sourceInfo[3] = in->getSubProcessorIdx(); sourceInfo[2] = in->getSubProcessorIdx();
mv.setValue(static_cast<const uint16*>(sourceInfo)); mv.setValue(static_cast<const uint16*>(sourceInfo));
ev->addMetaData(md, mv); ev->addMetaData(md, mv);
} }
eventChannelArray.add(ev); eventChannelArray.add(ev);
moduleEventChannels.add(ev); moduleEventChannels.add(ev);
} }
lastNumInputs = getNumInputs();
} }
...@@ -219,9 +220,9 @@ void PhaseDetector::process (AudioSampleBuffer& buffer) ...@@ -219,9 +220,9 @@ void PhaseDetector::process (AudioSampleBuffer& buffer)
checkForEvents (); checkForEvents ();
// loop through the modules // loop through the modules
for (int i = 0; i < modules.size(); ++i) for (int m = 0; m < modules.size(); ++m)
{ {
DetectorModule& module = modules.getReference (i); DetectorModule& module = modules.getReference (m);
// check to see if it's active and has a channel // check to see if it's active and has a channel
if (module.isActive && module.outputChan >= 0 if (module.isActive && module.outputChan >= 0
...@@ -239,8 +240,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer) ...@@ -239,8 +240,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer)
if (module.type == PEAK) if (module.type == PEAK)
{ {
uint8 ttlData = 1 << module.outputChan; uint8 ttlData = 1 << module.outputChan;
TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[i], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan); TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[m], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan);
addEvent(moduleEventChannels[i], event, i); addEvent(moduleEventChannels[m], event, i);
module.samplesSinceTrigger = 0; module.samplesSinceTrigger = 0;
module.wasTriggered = true; module.wasTriggered = true;
} }
...@@ -254,8 +255,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer) ...@@ -254,8 +255,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer)
if (module.type == FALLING_ZERO) if (module.type == FALLING_ZERO)
{ {
uint8 ttlData = 1 << module.outputChan; uint8 ttlData = 1 << module.outputChan;
TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[i], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan); TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[m], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan);
addEvent(moduleEventChannels[i], event, i); addEvent(moduleEventChannels[m], event, i);
module.samplesSinceTrigger = 0; module.samplesSinceTrigger = 0;
module.wasTriggered = true; module.wasTriggered = true;
} }
...@@ -267,8 +268,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer) ...@@ -267,8 +268,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer)
if (module.type == TROUGH) if (module.type == TROUGH)
{ {
uint8 ttlData = 1 << module.outputChan; uint8 ttlData = 1 << module.outputChan;
TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[i], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan); TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[m], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan);
addEvent(moduleEventChannels[i], event, i); addEvent(moduleEventChannels[m], event, i);
module.samplesSinceTrigger = 0; module.samplesSinceTrigger = 0;
module.wasTriggered = true; module.wasTriggered = true;
} }
...@@ -282,8 +283,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer) ...@@ -282,8 +283,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer)
if (module.type == RISING_ZERO) if (module.type == RISING_ZERO)
{ {
uint8 ttlData = 1 << module.outputChan; uint8 ttlData = 1 << module.outputChan;
TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[i], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan); TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[m], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan);
addEvent(moduleEventChannels[i], event, i); addEvent(moduleEventChannels[m], event, i);
module.samplesSinceTrigger = 0; module.samplesSinceTrigger = 0;
module.wasTriggered = true; module.wasTriggered = true;
} }
...@@ -298,8 +299,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer) ...@@ -298,8 +299,8 @@ void PhaseDetector::process (AudioSampleBuffer& buffer)
if (module.samplesSinceTrigger > 1000) if (module.samplesSinceTrigger > 1000)
{ {
uint8 ttlData = 0; uint8 ttlData = 0;
TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[i], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan); TTLEventPtr event = TTLEvent::createTTLEvent(moduleEventChannels[m], getTimestamp(module.inputChan) + i, &ttlData, sizeof(uint8), module.outputChan);
addEvent(moduleEventChannels[i], event, i); addEvent(moduleEventChannels[m], event, i);
module.wasTriggered = false; module.wasTriggered = false;
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment