Skip to content
Snippets Groups Projects
Commit a02ad22f authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

Launcher script: allows selection of different reproduction groups

- now also receives reproduction input type by client (e.g. binaural / ambisonics)
- based on that parameter, a specific group of modules is selected
parent 64fc1306
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,8 @@
"nLauncherPort": 41578,
"nVAServerPort": 12340,
"nDefaultSleep": 5,
"lsReproductionModules": ["TalkthroughHP", "CTC"],
"lsDefaultReproductionModules": ["TalkthroughHP", "CTC"],
"lsBinauralReproductionModules": ["TalkthroughHP", "CTC"],
"dVAServerDirectories" = {
"20160906.aixcave" : "D:/Demos/VA_20160906/Binaries",
......
......@@ -3,7 +3,9 @@
"nLauncherPort": 41578,
"nVAServerPort": 12340,
"nDefaultSleep": 3,
"lsReproductionModules": ["TalkthroughHP", "CTC"],
"lsDefaultReproductionModules": ["TalkthroughHP", "CTC"],
"lsBinauralReproductionModules": ["TalkthroughHP"],
"lsAmbisonicsReproductionModules": ["AmbisonicsBinauralMixdown"],
"dVAServerDirectories": {
"2018.a": "../v2018.a",
......
......@@ -14,6 +14,12 @@ class ErrorCodes(Enum):
ERROR_INCOMPLETE_VA_INI = 7
ERROR_UNDEFINED_LAUNCHER_STATE = 8
class ReproductionInput(Enum):
NOT_SPECIFIED = 0
BINAURAL = 1
AMBISONICS = 2
CUSTOM = 3
# Class representing the VA-Launcher config (.json) file
class LauncherConfig:
def __init__(conf, sConfigFile):
......@@ -30,14 +36,32 @@ class LauncherConfig:
conf.nLauncherPort = json_config["nLauncherPort"]
conf.nVAServerPort = json_config["nVAServerPort"]
conf.nDefaultSleep = json_config["nDefaultSleep"]
conf.lsReproductionModules = json_config["lsReproductionModules"]
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 )
try:
conf.lsBinauralReproductionModules = json_config["lsBinauralReproductionModules"]
except KeyError:
conf.lsBinauralReproductionModules = None
try:
conf.lsAmbisonicsReproductionModules = json_config["lsAmbisonicsReproductionModules"]
except KeyError:
conf.lsAmbisonicsReproductionModules = None
try:
conf.lsCustomReproductionModules = json_config["lsCustomReproductionModules"]
except KeyError:
conf.lsCustomReproductionModules = None
class VAComposedIniParser:
def __init__(self, lsReproductionModuleIDs):
self.lsReproductionModuleIDs = lsReproductionModuleIDs
def __init__(self, oLauncherConf : LauncherConfig):
self.lsDefaultReproductionModules = oLauncherConf.lsDefaultReproductionModules
self.lsBinauralReproductionModules = oLauncherConf.lsBinauralReproductionModules
self.lsAmbisonicsReproductionModules = oLauncherConf.lsAmbisonicsReproductionModules
self.lsCustomReproductionModules = oLauncherConf.lsCustomReproductionModules
self.eReproductionInput = ReproductionInput.NOT_SPECIFIED
self.sRendererIniPath = None
self.sConfFolder = "../conf/"
......@@ -89,7 +113,24 @@ class VAComposedIniParser:
print( "ERROR: " + str(e) )
sys.exit( ErrorCodes.ERROR_INCOMPLETE_VA_INI )
for sReproductionID in self.lsReproductionModuleIDs:
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")
elif self.eReproductionInput == ReproductionInput.AMBISONICS:
if self.lsAmbisonicsReproductionModules:
lsReproductionModuleIDs = self.lsAmbisonicsReproductionModules
else:
print("WARNING: Requested AMBISONICS reproduction modules are not specified, using default")
elif self.eReproductionInput == ReproductionInput.CUSTOM:
if self.lsCustomReproductionModules:
lsReproductionModuleIDs = self.lsCustomReproductionModules
else:
print("WARNING: Requested CUSTOM reproduction modules are not specified, using default")
for sReproductionID in lsReproductionModuleIDs:
sSection = "Reproduction:" + sReproductionID
if not reproductionIni.has_section(sSection):
print( "ERROR: Reproduction module with ID: '" + sReproductionID + "' not available in respective ini file '" + sFileToRead + "'")
......@@ -100,6 +141,7 @@ class VAComposedIniParser:
reproductionIni.write(inifile)
#Main class representing the VA Launcher app
class VirtualAcousticsLauncher:
def __init__(self):
print("init")
......@@ -144,7 +186,7 @@ class VirtualAcousticsLauncher:
print("Using config: " + sUsedConfigFile)
self.oConfig = LauncherConfig( sUsedConfigFile )
self.vaIniParser = VAComposedIniParser(self.oConfig.lsReproductionModules)
self.vaIniParser = VAComposedIniParser(self.oConfig)
#Open network socket used for the communication
def open_server_socket(self):
......@@ -232,13 +274,20 @@ class VirtualAcousticsLauncher:
if ":" not in sMessage: #VAServer ID, should be received last
self.sVAServerID = sMessage
else: #VARenderer.ini file, optional
elif sMessage.startswith("reproduction_input_type:"): #ReproductionInput type (Binaural / Ambisonics), optional
self.receive_reproduction_input(sMessage)
return self.receive_va_start_info()
elif sMessage.startswith("file:"): #VARenderer.ini file, optional
self.vaIniParser.sRendererIniPath = self.receive_file(sMessage)
return self.receive_va_start_info()
else:
lMessageParts = sMessage.split(":")
print("ERROR: Invalid message keyword '" + lMessageParts[0] + "' while receiving VA start info")
return False
print( "Received launch request for variant: " + self.sVAServerID )
print( "Received launch request for VAServer ID: " + self.sVAServerID )
except socket.error:
print( "Error while reading variant" )
print( "ERROR: Socket error while reading VAServer ID" )
self._reset_connection()
return False
else:
......@@ -255,6 +304,21 @@ class VirtualAcousticsLauncher:
return True
def receive_reproduction_input(self, sMessage):
try:
lsMessageParts = sMessage.split(":")
sReproductionInput = lsMessageParts[1].upper()
self.vaIniParser.eReproductionInput = ReproductionInput[sReproductionInput]
except IndexError:
print("ERROR: Message for receiving reproduction input type was empty")
self.oLauncherConnection.send( b'fail' )
except ValueError:
print("ERROR: Invalid ID (case-insensitive) for reproduction input: '" + sReproductionInput + "'")
self.oLauncherConnection.send( b'fail' )
else: #send acceptance
self.oLauncherConnection.send( b'ack' )
#Starts the VAServer from given directory
def start_va_server(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment