From f2f7c8829968ab5b9e3e4a0a67fbc1f453bf81e5 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 5 Jan 2024 15:42:11 +0100 Subject: [PATCH] SRS changes --- Moose Development/Moose/Core/Message.lua | 6 ++-- Moose Development/Moose/Sound/SRS.lua | 45 +++++++++++++++--------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Moose Development/Moose/Core/Message.lua b/Moose Development/Moose/Core/Message.lua index 46c896f0d..ce95f03c8 100644 --- a/Moose Development/Moose/Core/Message.lua +++ b/Moose Development/Moose/Core/Message.lua @@ -480,7 +480,7 @@ _MESSAGESRS = {} -- MESSAGE:New("Test message!",15,"SPAWN"):ToSRS() -- function MESSAGE.SetMSRS(PathToSRS,Port,PathToCredentials,Frequency,Modulation,Gender,Culture,Voice,Coalition,Volume,Label,Coordinate) - _MESSAGESRS.MSRS = MSRS:New(PathToSRS,Frequency or 243,Modulation or radio.modulation.AM,Volume) + _MESSAGESRS.MSRS = MSRS:New(PathToSRS,Frequency or 243,Modulation or radio.modulation.AM) _MESSAGESRS.frequency = Frequency _MESSAGESRS.modulation = Modulation or radio.modulation.AM @@ -497,7 +497,7 @@ function MESSAGE.SetMSRS(PathToSRS,Port,PathToCredentials,Frequency,Modulation,G _MESSAGESRS.MSRS:SetGender(Gender) _MESSAGESRS.Gender = Gender or "female" - _MESSAGESRS.MSRS:SetGoogle(PathToCredentials) + _MESSAGESRS.MSRS:SetProviderOptionsGoogle(PathToCredentials) _MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE") _MESSAGESRS.label = Label or "MESSAGE" @@ -543,7 +543,7 @@ function MESSAGE:ToSRS(frequency,modulation,gender,culture,voice,coalition,volum _MESSAGESRS.MSRS:SetCoordinate(coordinate) end local category = string.gsub(self.MessageCategory,":","") - _MESSAGESRS.SRSQ:NewTransmission(self.MessageText,nil,_MESSAGESRS.MSRS,nil,nil,nil,nil,nil,frequency or _MESSAGESRS.frequency,modulation or _MESSAGESRS.modulation, gender or _MESSAGESRS.Gender,culture or _MESSAGESRS.Culture,nil,volume or _MESSAGESRS.volume,category,coordinate or _MESSAGESRS.coordinate) + _MESSAGESRS.SRSQ:NewTransmission(self.MessageText,nil,_MESSAGESRS.MSRS,0.5,1,nil,nil,nil,frequency or _MESSAGESRS.frequency,modulation or _MESSAGESRS.modulation, gender or _MESSAGESRS.Gender,culture or _MESSAGESRS.Culture,nil,volume or _MESSAGESRS.volume,category,coordinate or _MESSAGESRS.coordinate) end return self end diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index 559d23c56..b470264eb 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -516,8 +516,20 @@ end -- @return #MSRS self function MSRS:SetBackend(Backend) self:F( {Backend=Backend} ) - self.backend=Backend or MSRS.Backend.SRSEXE - + Backend = Backend or MSRS.Backend.SRSEXE -- avoid nil + local function Checker(back) + local ok = false + for _,_backend in pairs(MSRS.Backend) do + if tostring(back) == _backend then ok = true end + end + return ok + end + + if Checker(Backend) then + self.backend=Backend + else + MESSAGE:New("ERROR: Backend "..tostring(Backend).." is not supported!",30,"MSRS",true):ToLog():ToAll() + end return self end @@ -1184,8 +1196,8 @@ end -- @param Core.Point#COORDINATE Coordinate Coordinate. -- @return #MSRS self function MSRS:PlayTextExt(Text, Delay, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate) - self:F( {Text, Delay, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate} ) - + self:T(( {Text, Delay, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate} ) + self:T((self.lid.."Backend "..self.backend) if Delay and Delay>0 then self:ScheduleOnce(Delay, MSRS.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate) else @@ -1205,6 +1217,7 @@ function MSRS:PlayTextExt(Text, Delay, Frequencies, Modulations, Gender, Culture self:_ExecCommand(command) elseif self.backend==MSRS.Backend.GRPC then + --BASE:I("MSRS.Backend.GRPC") self:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate) @@ -1831,7 +1844,7 @@ end -- @param #MSRSQUEUE self -- @return #MSRSQUEUE self The MSRSQUEUE object. function MSRSQUEUE:Clear() - self:I(self.lid.."Clearing MSRSQUEUE") + self:T((self.lid.."Clearing MSRSQUEUE") self.queue={} return self end @@ -1842,7 +1855,6 @@ end -- @param #MSRSQUEUE.Transmission transmission The transmission data table. -- @return #MSRSQUEUE self function MSRSQUEUE:AddTransmission(transmission) - -- Init. transmission.isplaying=false transmission.Tstarted=nil @@ -1921,20 +1933,20 @@ function MSRSQUEUE:NewTransmission(text, duration, msrs, tstart, interval, subgr transmission.Tplay=tstart or timer.getAbsTime() transmission.subtitle=subtitle transmission.interval=interval or 0 - transmission.frequency=frequency - transmission.modulation=modulation + transmission.frequency=frequency or msrs.frequencies + transmission.modulation=modulation or msrs.modulations transmission.subgroups=subgroups if transmission.subtitle then transmission.subduration=subduration or transmission.duration else transmission.subduration=0 --nil end - transmission.gender = gender - transmission.culture = culture - transmission.voice = voice - transmission.volume = volume - transmission.label = label - transmission.coordinate = coordinate + transmission.gender = gender or msrs.gender + transmission.culture = culture or msrs.culture + transmission.voice = voice or msrs.voice + transmission.volume = volume or msrs.volume + transmission.label = label or msrs.Label + transmission.coordinate = coordinate or msrs.coordinate -- Add transmission to queue. self:AddTransmission(transmission) @@ -1946,7 +1958,8 @@ end -- @param #MSRSQUEUE self -- @param #MSRSQUEUE.Transmission transmission The transmission. function MSRSQUEUE:Broadcast(transmission) - + self:T((self.lid.."Broadcast") + if transmission.frequency then transmission.msrs:PlayTextExt(transmission.text, nil, transmission.frequency, transmission.modulation, transmission.gender, transmission.culture, transmission.voice, transmission.volume, transmission.label, transmission.coordinate) else @@ -2115,7 +2128,7 @@ function MSRSQUEUE:_CheckRadioQueue(delay) -- Found a new transmission. if next~=nil and not playing then -- Debug info. - self:T(self.lid..string.format("Broadcasting text=\"%s\" at T=%.3f", next.text, time)) + self:T((self.lid..string.format("Broadcasting text=\"%s\" at T=%.3f", next.text, time)) -- Call SRS. self:Broadcast(next)