From 0c424f4c6619421320bfc8142d1d6e38702bb9eb Mon Sep 17 00:00:00 2001
From: ferrari <maxence.ferrari@gmail.com>
Date: Thu, 5 May 2022 10:20:11 +0200
Subject: [PATCH] Skip addition data sample

---
 src/recorder.cpp | 7 ++++---
 src/recorder.h   | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/recorder.cpp b/src/recorder.cpp
index fc49272..bae6592 100644
--- a/src/recorder.cpp
+++ b/src/recorder.cpp
@@ -175,19 +175,20 @@ void JasonRecorder::get_samples(std::vector<std::uint8_t> &samples, bool planar,
             if (buffer[0] != FRAME_START); // invalid message
             else if ((((std::uint16_t) buffer[1] << 8 )|(buffer[2])) == DATA_ID) {
                 // find the beginning and length of the samples in the buffer
-                size_t num_samples = (received - 6) /this->depth;
+                size_t start = this->addtional_data_size + 6;
+                size_t num_samples = (received - start) /this->depth;
                 num_samples = (num_samples / num_channels) * num_channels * this->depth;
                 // copy data to provided vector
                 if (planar || (num_channels == 1)) {
                     // copy out directly
                     samples.resize(0);
                     samples.reserve(num_samples);
-                    samples.insert(samples.end(), &buffer[6], &buffer[6] + num_samples);
+                    samples.insert(samples.end(), &buffer[start], &buffer[start] + num_samples);
                 }
                 else {
                     // convert from blocked channels to interleaved channels
                     samples.resize(num_samples);
-                    JasonRecorder::interleave_channels(&buffer[6],
+                    JasonRecorder::interleave_channels(&buffer[start],
                                                        samples.data(), num_samples,
                                                        this->num_channels, this->depth);
                 }
diff --git a/src/recorder.h b/src/recorder.h
index b29f3d1..a1654aa 100644
--- a/src/recorder.h
+++ b/src/recorder.h
@@ -65,6 +65,7 @@ private:
     size_t receive_message(uint8_t *buffer, size_t max_wait = 0);
 
     // device state, as far as known
+    size_t addtional_data_size = 1024;
     std::uint8_t num_channels = 0;
     std::uint8_t depth = 0;
     std::uint8_t num_filter = 0;
-- 
GitLab