From 29d2fcebf032c647f36e540b68afba9414fc9eb0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20Sch=C3=A4fer?=
 <philipp.schaefer@akustik.rwth-aachen.de>
Date: Mon, 6 Mar 2023 14:03:10 +0100
Subject: [PATCH] VALauncher: removing default reproduction module setting

---
 ...VirtualAcousticStarterConfig.ITC16100.json |  1 -
 .../VirtualAcousticStarterConfig.json         |  1 -
 LaunchScript/VirtualAcousticsStarterServer.py | 22 ++++++++++---------
 README.md                                     |  5 ++---
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/LaunchScript/VirtualAcousticStarterConfig.ITC16100.json b/LaunchScript/VirtualAcousticStarterConfig.ITC16100.json
index 1792c22..4eabe72 100644
--- a/LaunchScript/VirtualAcousticStarterConfig.ITC16100.json
+++ b/LaunchScript/VirtualAcousticStarterConfig.ITC16100.json
@@ -3,7 +3,6 @@
 	"nLauncherPort": 41578,
 	"nVAServerPort": 12340,
 	"nWaitForVAServerStart": 5,
-	"lsDefaultReproductionModules": ["TalkthroughHP", "CTC"],
 	"lsBinauralReproductionModules": ["TalkthroughHP", "CTC"],
 
 	"dVAServerDirectories" = {
diff --git a/LaunchScript/VirtualAcousticStarterConfig.json b/LaunchScript/VirtualAcousticStarterConfig.json
index d1b818f..9b3010a 100644
--- a/LaunchScript/VirtualAcousticStarterConfig.json
+++ b/LaunchScript/VirtualAcousticStarterConfig.json
@@ -3,7 +3,6 @@
 	"nLauncherPort": 41578,
 	"nVAServerPort": 12340,
 	"nWaitForVAServerStart": 3,
-	"lsDefaultReproductionModules": ["TalkthroughHP", "CTC"],
 	"lsBinauralReproductionModules": ["TalkthroughHP"],
 	"lsAmbisonicsReproductionModules": ["AmbisonicsBinauralMixdown"],
 
diff --git a/LaunchScript/VirtualAcousticsStarterServer.py b/LaunchScript/VirtualAcousticsStarterServer.py
index 3de2a4f..7dce6e3 100644
--- a/LaunchScript/VirtualAcousticsStarterServer.py
+++ b/LaunchScript/VirtualAcousticsStarterServer.py
@@ -36,7 +36,6 @@ class LauncherConfig:
       conf.nLauncherPort = json_config["nLauncherPort"]
       conf.nVAServerPort = json_config["nVAServerPort"]
       conf.nWaitForVAServerStart = json_config["nWaitForVAServerStart"]
-      conf.lsDefaultReproductionModules = json_config["lsDefaultReproductionModules"]
     except KeyError as e:
       print( "ERROR reading the json config. Missing " + str(e.args[0]) )
       sys.exit( ErrorCodes.ERROR_INCOMPLETE_CONFIG )
@@ -57,7 +56,6 @@ class LauncherConfig:
 
 class VAComposedIniParser:
   def __init__(self, oLauncherConf : LauncherConfig):
-    self.lsDefaultReproductionModules = oLauncherConf.lsDefaultReproductionModules
     self.lsBinauralReproductionModules = oLauncherConf.lsBinauralReproductionModules
     self.lsAmbisonicsReproductionModules = oLauncherConf.lsAmbisonicsReproductionModules
     self.lsCustomReproductionModules = oLauncherConf.lsCustomReproductionModules
@@ -76,7 +74,7 @@ class VAComposedIniParser:
   def prepare_inis(self):
     print("Parsing VA ini-files")
     self.link_renderer_ini()
-    self.prepare_reproduction_ini()
+    return self.prepare_reproduction_ini()
 
   def link_renderer_ini(self):
     if not self.sRendererIniPath:
@@ -113,22 +111,24 @@ class VAComposedIniParser:
       print( "ERROR: " + str(e) )
       sys.exit( ErrorCodes.ERROR_INCOMPLETE_VA_INI )
     
-    lsReproductionModuleIDs = self.lsDefaultReproductionModules
     if self.eReproductionInput == ReproductionInput.BINAURAL:
       if self.lsBinauralReproductionModules:
         lsReproductionModuleIDs = self.lsBinauralReproductionModules
       else:
-        print("WARNING: Requested BINAURAL reproduction modules are not specified, using default")
+        print("ERROR: Requested BINAURAL reproduction modules are not specified")
+        return False
     elif self.eReproductionInput == ReproductionInput.AMBISONICS:
       if self.lsAmbisonicsReproductionModules:
         lsReproductionModuleIDs = self.lsAmbisonicsReproductionModules
       else:
-        print("WARNING: Requested AMBISONICS reproduction modules are not specified, using default")
+        print("ERROR: Requested AMBISONICS reproduction modules are not specified")
+        return False
     elif self.eReproductionInput == ReproductionInput.CUSTOM:
       if self.lsCustomReproductionModules:
         lsReproductionModuleIDs = self.lsCustomReproductionModules
       else:
-        print("WARNING: Requested CUSTOM reproduction modules are not specified, using default")
+        print("ERROR: Requested CUSTOM reproduction modules are not specified")
+        return False
 
     for sReproductionID in lsReproductionModuleIDs:
       sSection = "Reproduction:" + sReproductionID
@@ -139,6 +139,8 @@ class VAComposedIniParser:
     
     with open( sFileToWrite, 'w' ) as inifile:
       reproductionIni.write(inifile)
+    
+    return True
 
 
 #Main class representing the VA Launcher app
@@ -262,7 +264,9 @@ class VirtualAcousticsLauncher:
       self.oVAProcess = None
 
     self.receive_va_start_info()
-    self.vaIniParser.prepare_inis()
+    if not self.vaIniParser.prepare_inis():
+      print( "Resetting launcher connection" )
+      self._reset_connection()
 
 
   #Checks for a message containing the ID of the VAServer instance to be started and returns the respective VAServer directory
@@ -332,8 +336,6 @@ class VirtualAcousticsLauncher:
           print( "ERROR: Invalid config for " + self.sVAServerID + " -- file " + sVAExecutableFile + " does not exist" )
           self.oLauncherConnection.send( b'n' ) #answer 'binary file cannot be found or invalid'
           return
-      elif self.sVAServerDir == None:
-        self.sVAServerDir = os.path.dirname( sVAExecutableFile ) #TODO-PSC: VAServer should always be started from its main directory, not the "bin" folder
     except KeyError:
       sVAExecutableFile = None
       print( "ERROR: config for " + self.sVAServerID + " has no valid \"file\" entry" )
diff --git a/README.md b/README.md
index 4992507..ef14fcd 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,6 @@ The VAServerLauncher can be configured by adjusting the settings in `./LaunchScr
 | nLauncherPort | Port used for communication with launcher | 41578 |
 | nVAServerPort | Port used for communication with VAServer | 12340 |
 | nWaitForVAServerStart | Time to wait for VAServer to start [seconds] | 3 |
-| lsDefaultReproductionModules | [Reproduction modules](#audio-reproduction) used if [Reproduction input signal type](#unreal-project-configuration) is not specified by client (Unreal) | ["TalkthroughHP", "CTC"] |
 | lsBinauralReproductionModules | [Reproduction modules](#audio-reproduction) used for [binaural](#unreal-project-configuration) input signals | ["TalkthroughHP"] |
 | lsAmbisonicsReproductionModules | [Reproduction modules](#audio-reproduction) used for [ambisonics](#unreal-project-configuration) input signals | ["AmbisonicsBinauralMixdown"] |
 | lsCustomReproductionModules | [Reproduction modules](#audio-reproduction) used for [custom](#unreal-project-configuration) purposes (e.g. multiple renderers with different signal types) | e.g. ["TalkthroughHP", "AmbisonicsBinauralMixdown"] |
@@ -70,7 +69,7 @@ You can add additional modules, if you want. However, you should *not* rename th
 In any case, especially for the loudspeaker-based modules, you will have to update the `Outputs` setting according to what you defined in the `VASetup.Launcher.ini`.
 
 ### Audio rendering
-The [rendering settings](https://www.virtualacoustics.org/VA/documentation/rendering/) specify, how audio is rendered based on the virtual sources and the receiver in your scene. Typically, this should live in your Unreal project (see [Unreal project configuration](#unreal-project-configuration)). However, the file `VARendering.Default.ini` is provided in case the Unreal project does not provide such a file.
+The [rendering settings](https://www.virtualacoustics.org/VA/documentation/rendering/) specify, how audio is rendered based on the virtual sources and the receiver in your scene. Typically, this should live in your Unreal project (see [Unreal project configuration](#unreal-project-configuration)). However, the file `VARenderer.Default.ini` is provided in case the Unreal project does not provide such a file.
 
 
 ## Unreal project configuration
@@ -82,4 +81,4 @@ When working with the [Unreal VA plugin](https://git-ce.rwth-aachen.de/vr-vis/VR
 | VAServerLauncher Port | Port used for communication with launcher | 41578 |
 | VAServer Version ID | ID used to specify which VAServer version should be started. This must match a value in the dictionary `dVAServerDirectories` in the [Launcher config](#launcher-configuration). | "2022.a" |
 | VARenderer.ini file | Filename of the ini file including the audio rendering settings for this project. If specified, the file will be sent to the VAServerLauncher on startup. | "" |
-| Reproduction input signal type | Depending on this setting a different set of reproduction modules (see [Launcher config](#launcher-configuration)) is used by the VAServerLauncher, the group [Default / Binaural / Ambisonics / Custom] | Binaural |
\ No newline at end of file
+| Reproduction input signal type | Depending on this setting a different set of reproduction modules (see [Launcher config](#launcher-configuration)) is used by the VAServerLauncher, the group [Binaural / Ambisonics / Custom] | Binaural |
\ No newline at end of file
-- 
GitLab