@@ -362,15 +362,15 @@ void LfpDisplayCanvas::updateScreenBuffer()
362362 dbi %= displayBufferSize; // make sure we're not overshooting
363363 int nextPos = (dbi + 1 ) % displayBufferSize; // position next to displayBufferIndex in display buffer to copy from
364364
365- // if (channel == 0)
366- // std::cout << "Channel "
367- // << channel << " : "
368- // << sbi << " : "
369- // << index << " : "
370- // << dbi << " : "
371- // << valuesNeeded << " : "
372- // << ratio
373- // << std::endl;
365+ // if (channel == 0)
366+ // std::cout << "Channel "
367+ // << channel << " : "
368+ // << sbi << " : "
369+ // << index << " : "
370+ // << dbi << " : "
371+ // << valuesNeeded << " : "
372+ // << ratio
373+ // << std::endl;
374374
375375 if (valuesNeeded > 0 && valuesNeeded < 1000000 )
376376 {
@@ -387,21 +387,25 @@ void LfpDisplayCanvas::updateScreenBuffer()
387387 screenBufferMin->clear (channel, sbi, 1 );
388388 screenBufferMax->clear (channel, sbi, 1 );
389389
390- dbi %= displayBufferSize; // just to be sure
391-
392- // interpolate between two samples with invAlpha and alpha
393- screenBuffer->addFrom (channel, // destChannel
394- sbi, // destStartSample
395- displayBuffer->getReadPointer (channel, dbi), // source
396- 1 , // numSamples
397- invAlpha*gain); // gain
398-
399-
400- screenBuffer->addFrom (channel, // destChannel
401- sbi, // destStartSample
402- displayBuffer->getReadPointer (channel, nextPos), // source
403- 1 , // numSamples
404- alpha*gain); // gain
390+ dbi %= displayBufferSize; // just to be sure
391+
392+ // update continuous data channels
393+ if (channel != nChans)
394+ {
395+ // interpolate between two samples with invAlpha and alpha
396+ screenBuffer->addFrom (channel, // destChannel
397+ sbi, // destStartSample
398+ displayBuffer->getReadPointer (channel, dbi), // source
399+ 1 , // numSamples
400+ invAlpha*gain); // gain
401+
402+
403+ screenBuffer->addFrom (channel, // destChannel
404+ sbi, // destStartSample
405+ displayBuffer->getReadPointer (channel, nextPos), // source
406+ 1 , // numSamples
407+ alpha*gain); // gain
408+ }
405409
406410 // same thing again, but this time add the min,mean, and max of all samples in current pixel
407411 float sample_min = 10000000 ;
@@ -432,13 +436,19 @@ void LfpDisplayCanvas::updateScreenBuffer()
432436
433437 }
434438
439+ // update event channel
440+ if (channel == nChans)
441+ {
442+ screenBuffer->setSample (channel, sbi, sample_max);
443+ }
444+
435445 // similarly, for each pixel on the screen, we want a list of all values so we can draw a histogram later
436446 // for simplicity, we'll just do this as 2d array, samplesPerPixel[px][samples]
437447 // with an additional array sampleCountPerPixel[px] that holds the N samples per pixel
438448 if (channel < nChans) // we're looping over one 'extra' channel for events above, so make sure not to loop over that one here
439449 {
440450 int c = 0 ;
441- for (int j = dbi; j < nextpix & c < MAX_N_SAMP_PER_PIXEL; j++)
451+ for (int j = dbi; j < nextpix && c < MAX_N_SAMP_PER_PIXEL; j++)
442452 {
443453 float sample_current = displayBuffer->getSample (channel, j);
444454 samplesPerPixel[channel][sbi][c]=sample_current;
@@ -454,26 +464,26 @@ void LfpDisplayCanvas::updateScreenBuffer()
454464
455465 screenBufferMin->addSample (channel, sbi, sample_min*gain);
456466 screenBufferMax->addSample (channel, sbi, sample_max*gain);
457- }
458- sbi++;
467+ }
468+ sbi++;
459469 }
460470
461- subSampleOffset += ratio;
462-
463- while (subSampleOffset >= 1.0 )
464- {
465- if (++dbi > displayBufferSize)
466- dbi = 0 ;
467-
468- nextPos = (dbi + 1 ) % displayBufferSize;
469- subSampleOffset -= 1.0 ;
471+ subSampleOffset += ratio;
472+
473+ while (subSampleOffset >= 1.0 )
474+ {
475+ if (++dbi > displayBufferSize)
476+ dbi = 0 ;
477+
478+ nextPos = (dbi + 1 ) % displayBufferSize;
479+ subSampleOffset -= 1.0 ;
480+ }
481+
470482 }
471-
472- }
473-
474- // update values after we're done
475- screenBufferIndex.set (channel, sbi);
476- displayBufferIndex.set (channel, dbi);
483+
484+ // update values after we're done
485+ screenBufferIndex.set (channel, sbi);
486+ displayBufferIndex.set (channel, dbi);
477487 }
478488
479489 }
@@ -1931,11 +1941,20 @@ void LfpTimescale::paint(Graphics& g)
19311941 3 * getHeight ()/4 ,
19321942 2 .0f );
19331943 }
1944+
19341945
19351946 if (i != 0 && i % 2 == 0 )
19361947 g.drawText (labels[i-1 ],getWidth ()/steps*i+3 ,0 ,100 ,getHeight (),Justification::left, false );
1948+
19371949 }
1950+ }
19381951
1952+ void LfpTimescale::mouseUp (const MouseEvent &e)
1953+ {
1954+ if (e.mods .isLeftButtonDown ())
1955+ {
1956+ lfpDisplay->trackZoomInfo .isScrollingX = false ;
1957+ }
19391958}
19401959
19411960void LfpTimescale::resized ()
@@ -1999,14 +2018,6 @@ void LfpTimescale::mouseDrag(const juce::MouseEvent &e)
19992018 }
20002019}
20012020
2002- void LfpTimescale::mouseUp (const MouseEvent &e)
2003- {
2004- if (e.mods .isLeftButtonDown ())
2005- {
2006- lfpDisplay->trackZoomInfo .isScrollingX = false ;
2007- }
2008- }
2009-
20102021void LfpTimescale::setTimebase (float t)
20112022{
20122023 timebase = t;
@@ -3121,9 +3132,6 @@ void LfpChannelDisplay::pxPaint()
31213132 // draw event markers
31223133 int rawEventState = canvas->getYCoord (canvas->getNumChannels (), i);// get last channel+1 in buffer (represents events)
31233134
3124- // if (i == ifrom)
3125- // std::cout << rawEventState << std::endl;
3126-
31273135 for (int ev_ch = 0 ; ev_ch < 8 ; ev_ch++) // for all event channels
31283136 {
31293137 if (display->getEventDisplayState (ev_ch)) // check if plotting for this channel is enabled
@@ -3281,8 +3289,19 @@ void LfpChannelDisplay::pxPaint()
32813289 plotterInfo.samp = i;
32823290 plotterInfo.lineColour = lineColour;
32833291
3292+ // if (plotterInfo.samp == canvas->lastScreenBufferIndex[chan])
3293+ // {
3294+ // for (int j = jfrom_wholechannel; j <= jto_wholechannel; j++)
3295+ // {
3296+ // bdLfpChannelBitmap.setPixelColour(i,j,lineColour);
3297+ // }
3298+ // }
3299+
3300+ // if (getChannelNumber() == 0)
3301+ // std::cout << "plotting " << i << std::endl;
3302+
32843303 // TODO: (kelly) complete transition toward plotter class encapsulation
3285- display->getPlotterPtr ()->plot (bdLfpChannelBitmap, plotterInfo); // plotterInfo is prepared above
3304+ display->getPlotterPtr ()->plot (bdLfpChannelBitmap, plotterInfo); // plotterInfo is prepared above
32863305
32873306// int jfrom=from+getY();
32883307// int jto=to+getY();
@@ -3772,6 +3791,7 @@ bool LfpChannelDisplayInfo::isChannelNumberHidden()
37723791
37733792
37743793
3794+
37753795#pragma mark - EventDisplayInterface -
37763796// Event display Options --------------------------------------------------------------------
37773797
0 commit comments