From 004457e6a0aa31504bd05787041eef4121946fe2 Mon Sep 17 00:00:00 2001
From: Aaron Cuevas Lopez <aacuelo@teleco.upv.es>
Date: Mon, 9 Jan 2017 20:50:06 +0100
Subject: [PATCH] Update Arduino output plugin

---
 Source/Plugins/ArduinoOutput/ArduinoOutput.cpp | 14 +++++++-------
 Source/Plugins/ArduinoOutput/ArduinoOutput.h   |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Source/Plugins/ArduinoOutput/ArduinoOutput.cpp b/Source/Plugins/ArduinoOutput/ArduinoOutput.cpp
index 02d490686..88e0dbb22 100644
--- a/Source/Plugins/ArduinoOutput/ArduinoOutput.cpp
+++ b/Source/Plugins/ArduinoOutput/ArduinoOutput.cpp
@@ -97,15 +97,15 @@ void ArduinoOutput::setDevice (String devName)
 }
 
 
-void ArduinoOutput::handleEvent (int eventType, MidiMessage& event, int sampleNum)
+void ArduinoOutput::handleEvent (const EventChannel* eventInfo, const MidiMessage& event, int sampleNum)
 {
-    if (eventType == TTL)
+    if (Event::getEventType(event) == EventChannel::TTL)
     {
-        const uint8* dataptr = event.getRawData();
+		TTLEventPtr ttl = TTLEvent::deserializeFromMessage(event, eventInfo);
 
         //int eventNodeId = *(dataptr+1);
-        const int eventId         = *(dataptr + 2);
-        const int eventChannel    = *(dataptr + 3);
+        const int eventId         = ttl->getState() ? 1: 0;
+        const int eventChannel    = ttl->getChannel();
 
         // std::cout << "Received event from " << eventNodeId
         //           << " on channel " << eventChannel
@@ -197,7 +197,7 @@ bool ArduinoOutput::disable()
 }
 
 
-void ArduinoOutput::process (AudioSampleBuffer& buffer, MidiBuffer& events)
+void ArduinoOutput::process (AudioSampleBuffer& buffer)
 {
-    checkForEvents (events);
+    checkForEvents ();
 }
diff --git a/Source/Plugins/ArduinoOutput/ArduinoOutput.h b/Source/Plugins/ArduinoOutput/ArduinoOutput.h
index 822143f79..1b0b89feb 100644
--- a/Source/Plugins/ArduinoOutput/ArduinoOutput.h
+++ b/Source/Plugins/ArduinoOutput/ArduinoOutput.h
@@ -46,14 +46,14 @@ public:
     ~ArduinoOutput();
 
     /** Searches for events and triggers the Arduino output when appropriate. */
-    void process (AudioSampleBuffer& buffer, MidiBuffer& events) override;
+    void process (AudioSampleBuffer& buffer) override;
 
     /** Currently unused. Future uses may include changing the TTL trigger channel
     or the output channel of the Arduino. */
     void setParameter (int parameterIndex, float newValue) override;
 
     /** Convenient interface for responding to incoming events. */
-    void handleEvent (int eventType, MidiMessage& event, int sampleNum) override;
+    void handleEvent (const EventChannel* eventInfo, const MidiMessage& event, int sampleNum) override;
 
     /** Called immediately prior to the start of data acquisition. */
     bool enable() override;
-- 
GitLab