Controlling signal sounds based on which arm is up or down?

Controlling signal sounds based on which arm is up or down?

Postby albinopigeon » Thu Feb 17, 2022 9:23 pm

Hi all,

I've had success with adding sounds to my signals, but I've hit a snag when it comes to having sounds on a signal with multiple different arms - let's say a single post with one home arm and one shunt disc. They're both coded as ARM_HOME and both use AndiS scripts.

These have different animations and different sound sets which are synced together. They both work on their own, but when combining the two into one signal, it either plays one of the two sounds or both of them at the same time - depending on what tactic I try to sort them out! Now, normally this wouldn't be much of an issue but it's playing with my OCD...

This is my code below, as it stands. This only plays the home arm sound which is overwriting that of the shunt disc. The child objects on both are identically named.


function Initialise ()
DefaultInitialise() -- no need to give the route count here

gArmTable[1][ARM_HOME][SEM_CHILD_NAME] = "ARM_HOME1"
gArmTable[1][ARM_HOME][SEM_PROCEED_ANIM] = "Clear01"
gArmTable[1][ARM_HOME][SEM_BLOCKED_ANIM] = "Stop01"

gArmTable[2][ARM_HOME][SEM_CHILD_NAME] = "ARM_HOME2"
gArmTable[2][ARM_HOME][SEM_PROCEED_ANIM] = "Clear01"
gArmTable[2][ARM_HOME][SEM_BLOCKED_ANIM] = "Stop01"

end

function startOpening(dollIndex, armIndex)

Call ("ControlSound:SetParameter", "SignalProgress", 1)

end

function startClosing(dollIndex, armIndex)

Call ("ControlSound:SetParameter", "SignalProgress", 0)

end

Aside from re-animating the shunt discs so they match to the sounds, is there anything I can do (scripting wise) to play one sound when, say, ARM_HOME1 is up and play another sound when ARM_HOME2 is up?

Thanks!
Image

Asset maker, wagon builder, route builder among others.
albinopigeon
Fit for Firing Duties
 
Posts: 34
Joined: Wed Dec 08, 2021 4:19 pm
Has thanked: 2 times
Been thanked: 1 time

Re: Controlling signal sounds based on which arm is up or down?

Postby AndiS » Thu Feb 17, 2022 10:57 pm

That is what the parameters are for.

You will have two sound children anyway or else you will never be able to say what to play. Here I assume you named them ControlSound1 and ControlSound2.

Now in function startOpening you say:

if dollIndex == 1 then
Call ("ControlSound1:SetParameter", "SignalProgress", 1)
else
Call ("ControlSound2:SetParameter", "SignalProgress", 1)
end

Same for closing, of course.

If you need a separate sound for the distant arm, it would do something like
if armIndex == ARM_DISTANT then

An of course, combinations work like this (among other options to spell it out):
if dollIndex == 1 and armIndex == ARM_DISTANT then
AndiS
Top Link Driver!
 
Posts: 736
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 268 times
Been thanked: 308 times

Re: Controlling signal sounds based on which arm is up or down?

Postby albinopigeon » Fri Feb 18, 2022 12:07 am

Worked an absolute treat. You, sir, are a godsend!
Image

Asset maker, wagon builder, route builder among others.
albinopigeon
Fit for Firing Duties
 
Posts: 34
Joined: Wed Dec 08, 2021 4:19 pm
Has thanked: 2 times
Been thanked: 1 time

Re: Controlling signal sounds based on which arm is up or down?

Postby AndiS » Fri Feb 18, 2022 9:56 am

You too. You are about the first person to use this feature. At least I am not aware of anyone worrying about the semaphore sound. And certainly not the difference between disk sound and arm sound.

I had to introduce these functions to switch on and off spectacle lenses that use the Tex shader to emit light while they sit in front of the lamp. And I just guessed that one day someone will surprise me with a use case for them. That was in 2015 and people rather surprised me with moving parts that need extra animations that are not provided for in the scripts. Good things come to those who wait, they say, and seven years sounds a bit biblical, which closes the poetic circle, or whatever.
AndiS
Top Link Driver!
 
Posts: 736
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 268 times
Been thanked: 308 times

Re: Controlling signal sounds based on which arm is up or down?

Postby albinopigeon » Fri Feb 18, 2022 7:04 pm

I thought I would include a screenshot of the fruits of my labour: the Up starter signal gantry at Seaton Junction, effectively two ex-LSWR lower quadrant co-acting signals sandwiched together.

Image
Image

Asset maker, wagon builder, route builder among others.
albinopigeon
Fit for Firing Duties
 
Posts: 34
Joined: Wed Dec 08, 2021 4:19 pm
Has thanked: 2 times
Been thanked: 1 time


Return to Route Creation

Who is online

Users browsing this forum: No registered users and 3 guests