Jump to content
Sign in to follow this  
n4gix

Aircraft Loaded?

Recommended Posts

Is there a way to detect when an aircraft and all systems are loaded?

 

I need to keep some sounds from playing until after the aircraft is completely loaded.


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

For me using DSD xml sound I just used a (G:Var) to give me a few seconds of mute. But even then the DSD sound initializes first - hence just a couple of clicks, etc, but not nearly as bad as without the wait... In FSUIPC one could use 0x3364 & 0x3365 to send a mute command, timing is still the big thing though I reckon.

 

Roman


20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

Share this post


Link to post
Share on other sites

A timer initialized by the first instance of PANEL_SERVICE_PRE_DRAW might be one approach.

5 - 10 seconds would likely suffice.  For testing, you could put the value in a config file.  Those beta testers who confessed to having slower machines would be able to tell you what value was required.

 

Doug

Share this post


Link to post
Share on other sites

I'm not certain that a timer would solve the exact problem, which is that there have been many instances where a sound file is being called for before the sound module has been loaded, resulting in numerous "Sound Creation Error" messages, and of course the dreaded CTD that those cause...

 

I need a method to prevent the calls for a sound until after the sound module is completely loaded and ready to respond.

 

I am thinking that perhaps if I have the sound module set a "flag" after it has completely loaded and is ready to respond, and then condition all calls for sound to be inhibited unless this "flag" is true might solve the creation error issue, but I'd still rather not have any sound(s) play until the a/c has completely loaded...

 

...it just sounds silly to have avionics fans and so forth playing while the scenery is still being loaded. :Silly:


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Aren't the fans tied to the electrical main bus, i.e. no power, no fans, no sound?

Well yes they are, but since the a/c can be loaded with the battery power already active, that doesn't help much!

 

In fact, with the custom Aircraft Configuration Manager, every livery available may be pre-set with cargo, pax and fuel load, as well as choice of Gravel Kit/No Gravel Kit, and either SP-77 or SP-177 + FMS...

 

...and as a cherry on top, it may be set up to load:

  1. Cold and Dark (completely dark)
  2. Ready to Start (battery on, APU running)
  3. Ready to Fly (engines running, all switches flipped)

So you see, with all these options, I need to find a workable solution to this custom sound issue.


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

How about:

In PANEL_SERVICE_CONNECT_TO_WINDOW, or even module_init():

1.  Open SimConnect and subscribe to the sound event.

2.  Force the sound off.

 

Use the sound subscription to keep the sound off until you are satisfied that it should be turned on.  The only way I can think of to determine this would be to check for instances of PANEL_SERVICE_PRE_DRAW.  If you get instances of PRE_DRAW on a gauge in the VC while the scenery is still loading, I think you are going to be stuck with a timer. 

 

You could of course force open a 2D window on aircraft load. Once you get repeating instances of PRE_DRAW on it, you should be good to go, at which point you could close the window.  If the window background and the gauge itself were both RGB(0,0,0), the user would never even know it was open.

 

Doug

Share this post


Link to post
Share on other sites

Well yes they are, but since the a/c can be loaded with the battery power already active, that doesn't help much!

 

In fact, with the custom Aircraft Configuration Manager, every livery available may be pre-set with cargo, pax and fuel load, as well as choice of Gravel Kit/No Gravel Kit, and either SP-77 or SP-177 + FMS...

 

...and as a cherry on top, it may be set up to load:

  1. Cold and Dark (completely dark)
  2. Ready to Start (battery on, APU running)
  3. Ready to Fly (engines running, all switches flipped)

So you see, with all these options, I need to find a workable solution to this custom sound issue.

 

I see. Well, then just do what Doug suggested,


7950X3D + 6900 XT + 64 GB + Linux | 4800H + RTX2060 + 32 GB + Linux
My add-ons from my FS9/FSX days

Share this post


Link to post
Share on other sites

Well, I opted for the time being to simply set a flag in my sound module that will let me check the flag before issuing any calls for sound. At least this will prevent any calls being made before the sound module is fully loaded and ready to run, and stop "Sound Creation" errors from occurring...

 

I can work towards a more "elegant" solution as time allows...

    (A:ELECTRICAL MASTER BATTERY,bool)
    (L:XMLSND16,enum) 2 != and
    (L:AvailableNow,number) 55 == and
    if{ 2 (>L:XMLSND16,enum) }

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Bill,

 

If you have a C++ .gau/dll containing a function/group of functions that you need to be loaded first of anything, why don't you declare them in the module_init section? For example, sound instantiation could be done here, which will ensure that it will be running before any other gauge-callback/XML function.

I use this approach for event handlers, and works perfect -thanks to umberto's (virtualli) advise.

 

Tom

Share this post


Link to post
Share on other sites

Tom, that is not the problem, really. In any case I've at least eliminated the possibility of any call for sounds by implementing a flag L:var in the sound module...

 

...until that flag is set to 55, no calls for sound will be made. End of "Sound Creation Error(s)" :ph34r:

 

What I really truly need though is a flag that won't be set until the entire aircraft is loaded, displayed in the sim, ready for the pilot to fly... :Thinking:


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

What I really truly need though is a flag that won't be set until the entire aircraft is loaded, displayed in the sim, ready for the pilot to fly... :Thinking:

 

Have you considered waiting until the pilot actually does something?  Watch for a K:Event.  You may have to ignore a few that the sim will issue itself.  If you don't register the event handler until the second or third instance of PRE_DRAW or PRE_UPDATE, chances are pretty good that any event you catch will be one that the user generated.  You can then unregister the event handler once you are done with it.

Although I've never done anything with it, there is an "Update" method in the AircraftCallback class.  I believe you will get a new instance of the AircraftCallback class each time you load an aircraft.  You might be able to build the event handler into this class, thereby allowing the module itself to figure out when things were ready.

 

Doug

Share this post


Link to post
Share on other sites

Thanks, Doug. There must be a reliable way. It just sounds silly (pun intended) to hear the avionics fans and the 400Hz inverter whine while the aircraft and scenery are still being loaded...


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...