• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Sound and Macro question

  • Thread starter Deleted member 1281
  • Start date
D

Deleted member 1281

Guest
My task is to have a controller articulate a plane's atc _id.
Using Doug's sound setup, I can pass a literal value to a macro that plays a sound, like so:

Code:
<Macro Name="playsound">1 (>L:mysounds_@, number></Macro>
...
@play(helloworld)   //plays mysounds_helloworld.wav
@play(1)                 //plays mysounds_1.wav  ("one")
@play(Z)                 //plays mysounds_Z.wav ("zulu")

This, as you know, works just fine. Now what I want to get is to make the macro capture a value from an Lvar, like so

Code:
1 (>L:myvar, number)
@play((L:myvar, number))   // to play play mysounds_1.wav; but doesn't work

I could of course make it conditional like ...

Code:
(L:myvar, number) 1 == if{ @play(1) }
(L:myvar, number) 2 == if{ @play(2) }
...
(L:myvar, number) 65 == if{ @play(A) }
...
(L:myvar, number) 90 == if{ @play(Z) }

... but at what a horrible waste of space and time. Any ideas for a more efficient solution?
 
Last edited by a moderator:

taguilo

Resource contributor
Messages
1,585
Country
argentina
This example is a bit tricky but helps to reduce source code.

Code:
<Macro Name="Play">l0 @1 == if{ 1 (>L:mysounds_@2, number) }</Macro>
...
(L:myvar, number) sp0
@Play(1,sound1) @Play(2,sound2) @Play(3,sound3) @Play(65,A) @Play(90,Z) ....etc

Tom
 
D

Deleted member 1281

Guest
Thanks Tom, but I'm not sure I get it. Maybe too complicated for me...

Say atc_id is N1024A
Say I want my controller to pronounce the last digit, ie "A" or "Alpha".
I isolate the last digit and put 65 to L:myvar (because ord(A) is 65).
So far so good. But from there how do I get my code to execute "@play(65,sound65)" ?
The first parameter is variable, but sound65 is not. How to get the 65 (or any other value!) into the "soundXX" of the macro call?
 
Last edited by a moderator:

taguilo

Resource contributor
Messages
1,585
Country
argentina
Ah ok, you need to play SOUND65, and you use ascii codes for alphabet chars, then even simpler:

Code:
Macro Name="Play">l0 @1 == if{ 1 (>L:SOUND@1, number) }</Macro>
(L:myvar, number) sp0
@Play(65)

Code is internally translated to

Code:
(L:myvar, number) sp0
l0 65 == if{ 1 (>L:SOUND65, number) }

You'll have to repeat @Play() macro for every alphabetic character related to a sound.
ie

Code:
@Play(65)     <!-- Alpha -->
@Play(66)     <!--  Bravo --> 
@Play(67)     <!--  Charlie) -->
@Play(68)     <!--  Delta) -->
etc


Tom

.
 
D

Deleted member 1281

Guest
Well, apart from the sp0/l0 bit this is basically what I had in my initial post. The crux is the condition "l0 xx == if{ 1 (>L:SOUNDxx, number) }" because it has to be tested for the whole range 48..57 and 65 ..90, i.e. the ten digits and the 24 letters. Can be done, maybe must be done, but it's precisely what I wanted to avoid ...
 
Messages
1,564
Country
thailand
I don't know enough about application of Doug's sound gauge to be helpful, I fear, but is this simply an issue about dynamically (on the fly) creating a variable name that has an arbitrary number - like the ascii code of a string character - appended to the var name?

If so, then XMLVARS can be used to create such a var name:

'Sound' Ord(A) scat (>C:XMLVARS:StoreVarName, string), where Ord(A) is your script that isolates the desired string character and returns its ascii number. In your example, it would create the XMLVAR name 'Sound65'

Does this help? Hope so.

Bob
 
D

Deleted member 1281

Guest
Thanks Bob, looks promising.

I don't know enough about application of Doug's sound gauge to be helpful, I fear, but is this simply an issue about dynamically (on the fly) creating a variable name that has an arbitrary number - like the ascii code of a string character - appended to the var name?

Exactly.

If so, then XMLVARS can be used to create such a var name:

'Sound' Ord(A) scat (>C:XMLVARS:StoreVarName, string), where Ord(A) is your script that isolates the desired string character and returns its ascii number. In your example, it would create the XMLVAR name 'Sound65'

OK. Since L:myvar already has the ord number, I guess one would write this as

Code:
'Sound' (L:myvar, number) chr scat (>C:XMLVARS:StoreVarName, string)

But, on reflection, as a matter of fact, Doug's gauge already creates the variables named sounds48 thru sounds90, via an .ini file, ready to be used. Anyway I'll see what gives. Haven't used XMLVARS so far. Must read up...
 

ddawson

Resource contributor
Messages
862
Country
canada
I guess what you really need is a text to speech module...
 
Messages
1,564
Country
thailand
OK. Since L:myvar already has the ord number, I guess one would write this as

Code:
'Sound' (L:myvar, number) chr scat (>C:XMLVARS:StoreVarName, string)


Pretty close. If you've already applied the ord operator, drop the chr:

Code:
'Sound' (L:myvar, number) scat (>C:XMLVARS:StoreVarName, string)


I understand this application of XMLVARS might not end up being helpful with Doug's sound gauge, but otherwise, the importance and usefulness of dynamic variable names and dynamic variable name arrays is hard to overstate. There are several tools in Tom Aguilo's XMLTOOLS that I use regularly; XMLVARS is at the top of my list.

Bob
 
Last edited:
D

Deleted member 1281

Guest
I know it's the bees knees, I actually have it installed. My users haven't though. Maybe it's time to change that.

I guess what you really need is a text to speech module...

Do I? Yours does me fine. Here, listen in, the GCA's controller's voice is Alice from fromtexttospeech.com:

https://vocaroo.com/i/s0I2n6o1eVIK
 
Last edited by a moderator:

taguilo

Resource contributor
Messages
1,585
Country
argentina
Well, apart from the sp0/l0 bit this is basically what I had in my initial post. The crux is the condition "l0 xx == if{ 1 (>L:SOUNDxx, number) }" because it has to be tested for the whole range 48..57 and 65 ..90, i.e. the ten digits and the 24 letters. Can be done, maybe must be done, but it's precisely what I wanted to avoid ...

Despite Bob's good intentions to provide something to test, there is no other simple way to do that than the example I provided.

Unfortunately LVar names must be written literaly for the parser to recognize them. You cannot use variable values appended to part of an LVar's partial name to conform a complete name.
Anyway, if you need to repeat , for example @Play(n) 100 times, I see no big problem to that. Just copy/paste/update each macro call in a different line to improve readability. Cost in FPS will be nil, not visually observable.

Tom
 
D

Deleted member 1281

Guest
Right, looks like it has to be done the roundabout way.

Thanks all for your thoughts!

--Manfred
 
Top