From cd0d6f602a557b5f60833052837ce6e3e43b52a1 Mon Sep 17 00:00:00 2001
From: Tim Uebelhoer <tim.uebelhoer@rwth-aachen.de>
Date: Sun, 12 Nov 2017 15:37:47 +0100
Subject: [PATCH] Fixed using wrong memory address for channels > 0.

---
 AdidatCLI/AdidatCLI/NativeWriter.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/AdidatCLI/AdidatCLI/NativeWriter.cpp b/AdidatCLI/AdidatCLI/NativeWriter.cpp
index e5843cb..4d8aee8 100644
--- a/AdidatCLI/AdidatCLI/NativeWriter.cpp
+++ b/AdidatCLI/AdidatCLI/NativeWriter.cpp
@@ -78,14 +78,16 @@ void NativeWriter::AddRecord(std::vector<std::vector<float>> data)
 		{
 			chunkSize = OPTIMAL_CHUNK_SIZE;
 		}
+		long samplesAddedInStep = 0;
 		for (size_t channel = 0; channel < data.size(); channel++)
 		{
 			// Write it
 			long writtenSamples = 0;
 			checkResult(ADI_AddChannelSamples(_writerHandle, static_cast<long>(channel), data[channel].data() + samplesAdded, chunkSize, &writtenSamples));
 			// Weird but once the chunk is written to the first channel, all other channels will retunr writtenSamples = 0 :(
-			samplesAdded += writtenSamples;
+			samplesAddedInStep += writtenSamples;
 		}
+		samplesAdded += samplesAddedInStep;
 	}
 
 	// Close the record
-- 
GitLab