SRS changes

This commit is contained in:
Applevangelist
2024-01-05 15:42:11 +01:00
parent f5d6d31b10
commit f2f7c88299
2 changed files with 32 additions and 19 deletions

View File

@@ -480,7 +480,7 @@ _MESSAGESRS = {}
-- MESSAGE:New("Test message!",15,"SPAWN"):ToSRS() -- MESSAGE:New("Test message!",15,"SPAWN"):ToSRS()
-- --
function MESSAGE.SetMSRS(PathToSRS,Port,PathToCredentials,Frequency,Modulation,Gender,Culture,Voice,Coalition,Volume,Label,Coordinate) 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.frequency = Frequency
_MESSAGESRS.modulation = Modulation or radio.modulation.AM _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.MSRS:SetGender(Gender)
_MESSAGESRS.Gender = Gender or "female" _MESSAGESRS.Gender = Gender or "female"
_MESSAGESRS.MSRS:SetGoogle(PathToCredentials) _MESSAGESRS.MSRS:SetProviderOptionsGoogle(PathToCredentials)
_MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE") _MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE")
_MESSAGESRS.label = 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) _MESSAGESRS.MSRS:SetCoordinate(coordinate)
end end
local category = string.gsub(self.MessageCategory,":","") 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 end
return self return self
end end

View File

@@ -516,8 +516,20 @@ end
-- @return #MSRS self -- @return #MSRS self
function MSRS:SetBackend(Backend) function MSRS:SetBackend(Backend)
self:F( {Backend=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 return self
end end
@@ -1184,8 +1196,8 @@ end
-- @param Core.Point#COORDINATE Coordinate Coordinate. -- @param Core.Point#COORDINATE Coordinate Coordinate.
-- @return #MSRS self -- @return #MSRS self
function MSRS:PlayTextExt(Text, Delay, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate) 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 if Delay and Delay>0 then
self:ScheduleOnce(Delay, MSRS.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate) self:ScheduleOnce(Delay, MSRS.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate)
else else
@@ -1205,6 +1217,7 @@ function MSRS:PlayTextExt(Text, Delay, Frequencies, Modulations, Gender, Culture
self:_ExecCommand(command) self:_ExecCommand(command)
elseif self.backend==MSRS.Backend.GRPC then elseif self.backend==MSRS.Backend.GRPC then
--BASE:I("MSRS.Backend.GRPC")
self:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate) self:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate)
@@ -1831,7 +1844,7 @@ end
-- @param #MSRSQUEUE self -- @param #MSRSQUEUE self
-- @return #MSRSQUEUE self The MSRSQUEUE object. -- @return #MSRSQUEUE self The MSRSQUEUE object.
function MSRSQUEUE:Clear() function MSRSQUEUE:Clear()
self:I(self.lid.."Clearing MSRSQUEUE") self:T((self.lid.."Clearing MSRSQUEUE")
self.queue={} self.queue={}
return self return self
end end
@@ -1842,7 +1855,6 @@ end
-- @param #MSRSQUEUE.Transmission transmission The transmission data table. -- @param #MSRSQUEUE.Transmission transmission The transmission data table.
-- @return #MSRSQUEUE self -- @return #MSRSQUEUE self
function MSRSQUEUE:AddTransmission(transmission) function MSRSQUEUE:AddTransmission(transmission)
-- Init. -- Init.
transmission.isplaying=false transmission.isplaying=false
transmission.Tstarted=nil transmission.Tstarted=nil
@@ -1921,20 +1933,20 @@ function MSRSQUEUE:NewTransmission(text, duration, msrs, tstart, interval, subgr
transmission.Tplay=tstart or timer.getAbsTime() transmission.Tplay=tstart or timer.getAbsTime()
transmission.subtitle=subtitle transmission.subtitle=subtitle
transmission.interval=interval or 0 transmission.interval=interval or 0
transmission.frequency=frequency transmission.frequency=frequency or msrs.frequencies
transmission.modulation=modulation transmission.modulation=modulation or msrs.modulations
transmission.subgroups=subgroups transmission.subgroups=subgroups
if transmission.subtitle then if transmission.subtitle then
transmission.subduration=subduration or transmission.duration transmission.subduration=subduration or transmission.duration
else else
transmission.subduration=0 --nil transmission.subduration=0 --nil
end end
transmission.gender = gender transmission.gender = gender or msrs.gender
transmission.culture = culture transmission.culture = culture or msrs.culture
transmission.voice = voice transmission.voice = voice or msrs.voice
transmission.volume = volume transmission.volume = volume or msrs.volume
transmission.label = label transmission.label = label or msrs.Label
transmission.coordinate = coordinate transmission.coordinate = coordinate or msrs.coordinate
-- Add transmission to queue. -- Add transmission to queue.
self:AddTransmission(transmission) self:AddTransmission(transmission)
@@ -1946,6 +1958,7 @@ end
-- @param #MSRSQUEUE self -- @param #MSRSQUEUE self
-- @param #MSRSQUEUE.Transmission transmission The transmission. -- @param #MSRSQUEUE.Transmission transmission The transmission.
function MSRSQUEUE:Broadcast(transmission) function MSRSQUEUE:Broadcast(transmission)
self:T((self.lid.."Broadcast")
if transmission.frequency then 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) transmission.msrs:PlayTextExt(transmission.text, nil, transmission.frequency, transmission.modulation, transmission.gender, transmission.culture, transmission.voice, transmission.volume, transmission.label, transmission.coordinate)
@@ -2115,7 +2128,7 @@ function MSRSQUEUE:_CheckRadioQueue(delay)
-- Found a new transmission. -- Found a new transmission.
if next~=nil and not playing then if next~=nil and not playing then
-- Debug info. -- 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. -- Call SRS.
self:Broadcast(next) self:Broadcast(next)