@@ -99,7 +99,7 @@ void LfpDisplayNode::updateSettings()
9999 }
100100
101101 int numChans = getNumSubprocessorChannels ();
102- int srate = getSubprocessorSampleRate ();
102+ int srate = getSubprocessorSampleRate (subprocessorToDraw );
103103
104104 std::cout << " Re-setting num inputs on LfpDisplayNode to " << numChans << std::endl;
105105 if (numChans > 0 )
@@ -136,15 +136,7 @@ void LfpDisplayNode::updateSettings()
136136
137137uint32 LfpDisplayNode::getEventSourceId (const EventChannel* event)
138138{
139-
140- if (event->getTimestampOrigin () == EventChannel::timestampsDerivedFromChannel)
141- {
142- return getProcessorFullId (event->getTimestampOriginProcessor (), event->getTimestampOriginSubProcessor ());
143- }
144- else
145- {
146- return getChannelSourceId (event);
147- }
139+ return getProcessorFullId (event->getTimestampOriginProcessor (), event->getTimestampOriginSubProcessor ());
148140}
149141
150142uint32 LfpDisplayNode::getChannelSourceId (const InfoObjectCommon* chan)
@@ -184,18 +176,19 @@ int LfpDisplayNode::getNumSubprocessorChannels()
184176 return 0 ;
185177}
186178
187- float LfpDisplayNode::getSubprocessorSampleRate ()
179+ float LfpDisplayNode::getSubprocessorSampleRate (uint32 subprocId )
188180{
189- if (subprocessorToDraw != 0 )
181+ auto entry = subprocessorSampleRate.find (subprocId);
182+ if (entry != subprocessorSampleRate.end ())
190183 {
191- return subprocessorSampleRate[subprocessorToDraw] ;
184+ return entry-> second ;
192185 }
193186 return 0 .0f ;
194187}
195188
196189bool LfpDisplayNode::resizeBuffer ()
197190{
198- int nSamples = (int )getSubprocessorSampleRate () * bufferLength;
191+ int nSamples = (int )getSubprocessorSampleRate (subprocessorToDraw ) * bufferLength;
199192 int nInputs = getNumSubprocessorChannels ();
200193
201194 std::cout << " Resizing buffer. Samples: " << nSamples << " , Inputs: " << nInputs << std::endl;
@@ -269,12 +262,15 @@ void LfpDisplayNode::handleEvent(const EventChannel* eventInfo, const MidiMessag
269262 const int eventId = ttl->getState () ? 1 : 0 ;
270263 const int eventChannel = ttl->getChannel ();
271264 const int eventTime = samplePosition;
265+
266+ // find sample rate of event channel
272267 uint32 eventSourceNodeId = getEventSourceId (eventInfo);
273-
274- // treat events with no source as occurring on the subprocessor being drawn.
275- if (eventSourceNodeId == 0 )
268+ float eventSampleRate = getSubprocessorSampleRate (eventSourceNodeId);
269+
270+ if (eventSampleRate == 0 )
276271 {
277- eventSourceNodeId = subprocessorToDraw;
272+ // shouldn't happen for any real event channel at this point
273+ return ;
278274 }
279275
280276 // std::cout << "Received event on channel " << eventChannel << std::endl;
0 commit comments