From 660e778832c819b5dc780be88b47db025d8fdb7a Mon Sep 17 00:00:00 2001
From: kmichaelfox <kmichaelfox.contact@gmail.com>
Date: Sat, 2 Sep 2017 13:33:47 -0700
Subject: [PATCH] insert event testing code

---
 .../LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp  |  3 +-
 Source/Processors/FileReader/FileReader.cpp   | 32 ++++++++++++++++++-
 Source/Processors/FileReader/FileReader.h     |  2 ++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp
index 134968b60..f02b5662e 100644
--- a/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp
+++ b/Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp
@@ -2615,7 +2615,6 @@ void LfpDisplay::rebuildDrawableChannelsList()
         }
         else // skip some channels
         {
-            std::cout << "displaySkipAmt = " << displaySkipAmt << std::endl;
             if (i % (displaySkipAmt) == 0) // add these channels
             {
                 channels[i]->setHidden(false);
@@ -2951,7 +2950,7 @@ void LfpChannelDisplay::pxPaint()
                 {
                     if (rawEventState & (1 << ev_ch))    // events are  representet by a bit code, so we have to extract the individual bits with a mask
                     {
-                        //std::cout << "Drawing event." << std::endl;
+//                        std::cout << "Drawing event." << std::endl;
                         Colour currentcolor=display->channelColours[ev_ch*2];
                         
                         for (int k=jfrom_wholechannel; k<=jto_wholechannel; k++) // draw line
diff --git a/Source/Processors/FileReader/FileReader.cpp b/Source/Processors/FileReader/FileReader.cpp
index 63d79c852..2238908d2 100644
--- a/Source/Processors/FileReader/FileReader.cpp
+++ b/Source/Processors/FileReader/FileReader.cpp
@@ -229,7 +229,6 @@ void FileReader::updateSettings()
      }
 }
 
-
 void FileReader::process (AudioSampleBuffer& buffer)
 {
     const int samplesNeededPerBuffer = int (float (buffer.getNumSamples()) * (getDefaultSampleRate() / 44100.0f));
@@ -282,10 +281,41 @@ void FileReader::process (AudioSampleBuffer& buffer)
     timestamp += samplesNeededPerBuffer;
     setTimestampAndSamples(timestamp, samplesNeededPerBuffer);
     
+    // TODO: (kelly) clean this up, testing event display
+    {
+        static bool flag = false;
+//        if (counter == 0)
+        if (counter % 3 == 0)
+        {
+            flag = !flag;
+//            TextEventPtr textEvent = TextEvent::createTextEvent(getEventChannel(0), timestamp, "Test Event");
+            //            TextEvent::createTextEvent
+//            addEvent(0, textEvent, 0);
+            uint8 value = 1;
+            std::cout << "\n\nSending event with value " << (int)value << std::endl;
+            TTLEventPtr ttlEvent = TTLEvent::createTTLEvent(getEventChannel(0), timestamp, &value, sizeof(uint8), 0);
+            addEvent(0, ttlEvent, 0);
+            
+            value = 0;
+            std::cout << "Sending event with value " << (int) value << std::endl;
+            TTLEventPtr ttlEvent2 = TTLEvent::createTTLEvent(getEventChannel(0), timestamp + 10, &value, sizeof(uint8), 0);
+            addEvent(0, ttlEvent2, 100);
+        }
+        counter++;
+    }
+    // END_TODO
+    
     bufferCacheWindow += 1;
     bufferCacheWindow %= BUFFER_WINDOW_CACHE_SIZE;
 }
 
+void FileReader::getDefaultEventInfo(Array<DefaultEventInfo> &events, int subproc) const
+{
+    events.clear();
+    
+    events.add(DefaultEventInfo(EventChannel::TTL, 1, sizeof(uint8), 44100));
+}
+
 
 void FileReader::setParameter (int parameterIndex, float newValue)
 {
diff --git a/Source/Processors/FileReader/FileReader.h b/Source/Processors/FileReader/FileReader.h
index 91ee3fe77..ae7386fd1 100644
--- a/Source/Processors/FileReader/FileReader.h
+++ b/Source/Processors/FileReader/FileReader.h
@@ -68,6 +68,8 @@ public:
 
     bool isFileSupported          (const String& filename) const;
     bool isFileExtensionSupported (const String& ext) const;
+    
+    virtual void getDefaultEventInfo(Array<DefaultEventInfo>& events, int subproc) const override;
 
 
 private:
-- 
GitLab