- Sound input
This commit is contained in:
Frank 2024-05-25 01:56:23 +02:00
parent f1c03e1b86
commit 7bac0f32fc
3 changed files with 60 additions and 2 deletions

View File

@ -495,7 +495,7 @@ ATIS.Alphabet = {
-- @field #number TheChannel -10° (West).
-- @field #number Syria +5° (East).
-- @field #number MarianaIslands +2° (East).
-- @field #number SinaiMao +5° (East).
-- @field #number SinaiMap +5° (East).
ATIS.RunwayM2T = {
Caucasus = 0,
Nevada = 12,
@ -1088,6 +1088,55 @@ function ATIS:SetSoundfilesPath( path )
return self
end
--- Set the path to the csv file that contains information about the used sound files.
-- @param #ATIS self
-- @param #string csvfile Full path to the csv file on your local disk (not in the miz file).
-- @return #ATIS self
function ATIS:SetSoundfilesInfoFile( csvfile )
--- Local function to return the ATIS.Soundfile for a given file name
local function getSound(filename)
for key,_soundfile in pairs(ATIS.Sound) do
local soundfile=_soundfile --#ATIS.Soundfile
if filename==soundfile.filename then
return soundfile
end
end
return nil
end
local data=UTILS.ReadCSV(csvfile)
if data then
env.info("FF sound info")
local soundfiles={}
for i,soundinfo in pairs(data) do
local sound=soundinfo --#Soundinfo
local soundfile=getSound(sound.filename..".ogg") --#ATIS.Soundfile
if soundfile then
-- Set duration
soundfile.duration=soundinfo.duration
else
self:E(string.format("ERROR: Could not get info for sound file %s", sound.filename))
end
end
else
self:E("ERROR: Could not read sound csv file!")
end
return self
end
--- Set airborne unit (airplane or helicopter), used to transmit radio messages including subtitles.
-- Best is to place the unit on a parking spot of the airbase and set it to *uncontrolled* in the mission editor.
-- @param #ATIS self

View File

@ -249,6 +249,9 @@ do -- Sound File
-- @param #string Duration Duration in seconds. Default 3 seconds.
-- @return #SOUNDFILE self
function SOUNDFILE:SetDuration(Duration)
if Duration and type(Duration)=="string" then
Duration=tonumber(Duration)
end
self.duration=Duration or 3
return self
end

View File

@ -3966,6 +3966,11 @@ function UTILS.ReadCSV(filename)
local lines=UTILS.Split(data, "\n" )
-- Remove carriage returns from end of lines
for _,line in pairs(lines) do
line=string.gsub(line, "[\n\r]","")
end
local sep=";"
local columns=UTILS.Split(lines[1], sep)
@ -3977,11 +3982,12 @@ function UTILS.ReadCSV(filename)
local csvdata={}
for i, line in pairs(lines) do
line=string.gsub(line, "[\n\r]","")
local row={}
for j, value in pairs(UTILS.Split(line, sep)) do
local key=columns[j]
local key=string.gsub(columns[j], "[\n\r]","")
--env.info(string.format("i=%d, j=%d key=%s value=%s", i,j, key, value))