From 71fbfdb0a1d7247a6ded81fca288bccae0b449f8 Mon Sep 17 00:00:00 2001
From: Lewin Probst <info@emirror.de>
Date: Thu, 8 Aug 2019 10:46:59 +0200
Subject: [PATCH] Added generation of colors for every sound source.

---
 lib/+artoa/+controller/generateSoundSourceColors.m | 14 ++++++++++++++
 lib/+artoa/+controller/loadSoundSourceFile.m       |  1 +
 2 files changed, 15 insertions(+)
 create mode 100644 lib/+artoa/+controller/generateSoundSourceColors.m

diff --git a/lib/+artoa/+controller/generateSoundSourceColors.m b/lib/+artoa/+controller/generateSoundSourceColors.m
new file mode 100644
index 0000000..aca7e3b
--- /dev/null
+++ b/lib/+artoa/+controller/generateSoundSourceColors.m
@@ -0,0 +1,14 @@
+function [] = generateSoundSourceColors()
+%GENERATESOUNDSOURCECOLORS Generates unique identifier value for a sound source.
+%   Generates a 1D vector with values between 0 and 1. This vector is used
+%   to identify sound sources by color in the timeOfArrival plot.
+
+global artoaWorkspace artoaDataInput;
+
+soundsourceNames = fieldnames(artoaDataInput.soundsources);
+
+artoaWorkspace.soundSourceColorId = ...
+    [1:length(soundsourceNames)] / length(soundsourceNames);
+
+end
+
diff --git a/lib/+artoa/+controller/loadSoundSourceFile.m b/lib/+artoa/+controller/loadSoundSourceFile.m
index f291317..c71ee04 100644
--- a/lib/+artoa/+controller/loadSoundSourceFile.m
+++ b/lib/+artoa/+controller/loadSoundSourceFile.m
@@ -19,6 +19,7 @@ end
 artoaDataInput.soundsources = artoa.load.soundsources(filepath);
 
 %% Update workspace
+artoa.controller.generateSoundSourceColors();
 %artoa.controller.copyRfbToWorkspace();
 
 %% Update menu buttons
-- 
GitLab