• 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.

Sim sound on/off

DragonflightDesign

Resource contributor
Messages
1,371
Country
northernireland
Is there any way of easily detecting whether the simulator sound is on or off (key Q by default)? I thought there was at one time, but I can't find anything relevant in the simvars.
 
I don't recall anything that would indicate whether sound was on or off.
 
Is there any way of easily detecting whether the simulator sound is on or off (key Q by default)? I thought there was at one time, but I can't find anything relevant in the simvars.
Should be in SimConnect somewhere, since Dougs XMLSound gauge make this state available in an Lvar (FSSoundIsOn).

Rob
 
It's not quite what you think, Rob/Tom.
Code:
GAUGE_KEY_EVENT_HANDLER FSAPI SoundTrap ( ID32 event, UINT32 evdata, PVOID userdata )
{
switch( event )
    {
    case KEY_SOUND_TOGGLE:
        {
        SoundIsOn = 1 - SoundIsOn;
        FSSoundStatus.SetLVar( (double)SoundIsOn );
        }
    break;
    case KEY_SOUND_SET:
        {
        SoundIsOn = evdata;
        FSSoundStatus.SetLVar( (double)SoundIsOn );
        }
    break;
    case KEY_SOUND_ON:
        {
        SoundIsOn = 1;
        FSSoundStatus.SetLVar( (double)SoundIsOn );
        }
    break;
    case KEY_SOUND_OFF:
        {
        SoundIsOn = 0;
        FSSoundStatus.SetLVar( (double)SoundIsOn );
        }
    break;
    }
return 0;
};
It's reporting the key_events, not the actual state of the sim sound. If someone hits the 'Q' key, I want to silence my whole cockpit.
 
In fact... if I save a flight with sound off... and load that flight... then press the 'Q' key... that variable would then be set to 0 which would be incorrect.
 
It's not quite what you think, Rob/Tom.
Code:
GAUGE_KEY_EVENT_HANDLER FSAPI SoundTrap ( ID32 event, UINT32 evdata, PVOID userdata )
{
switch( event )
    {
    case KEY_SOUND_TOGGLE:
        {
        SoundIsOn = 1 - SoundIsOn;
        FSSoundStatus.SetLVar( (double)SoundIsOn );
        }
    break;
    case KEY_SOUND_SET:
        {
        SoundIsOn = evdata;
        FSSoundStatus.SetLVar( (double)SoundIsOn );
        }
    break;
    case KEY_SOUND_ON:
        {
        SoundIsOn = 1;
        FSSoundStatus.SetLVar( (double)SoundIsOn );
        }
    break;
    case KEY_SOUND_OFF:
        {
        SoundIsOn = 0;
        FSSoundStatus.SetLVar( (double)SoundIsOn );
        }
    break;
    }
return 0;
};
It's reporting the key_events, not the actual state of the sim sound. If someone hits the 'Q' key, I want to silence my whole cockpit.
Hmm.. interresting ....
Is the code above your code or from Dougs XMLSound gauge ??
Just asking, since your code uses an Lvar SoundIsOn, where Dougs XMLSound gauge uses an Lvar named FSSoundIsOn.

Which is ALWAYS in sync which the actual Sound status (on or off); so it must be possible to read/maintain the current state somehow.

Getting curious how Dougs XMLSound gauge determines the current Sound state, I did a few tests (that is: in FSX-Accell).
There are two places (I know of) that FSX writes the current state of the Sound:
1. In the FSX.cfg file, as in:
[SOUND]
SOUND=1 (sound is On)

Which is the current state written when you exit FSX.

2. In a saved .FLT file, as in :
[Options]
Sound=False (Sound is Off)

However, the latter value (as I have tested it) has NO effect at all: meaning that FSX is running, and Sound is currently ON, and you load a flight with Sound=False in the .FLT file, the flight still loads with the sound On.

So maybe Dougs XMLSound gauge reads the sound state defined in FSX.cfg and then maintains changes by trapping events ??
You have to ask Doug how he does that …..
I can only conclude (based on my tests), that the value of his Lvar FSSoundIsOn ALWAYS reflects the actual sound state On or Off.

Rob
 
Rob: that's extracted from Doug's code. I've been talking to him recently and he admits that he's lost interest in flight simulation. He was good enough to pass some of his source code across and of course, there's a lot more available on his website still. I did a skim-read of the xml sound gauge code but from what you're saying, I need to look at it in more detail.

kalong: I'll check that out.

Probably more in hope than anything else, I lobbed a feature request at LMCO for a 'sound is on/off' boolean.
 
Heh... he's right... it's available via the SubscribeToSystemEvent in SimConnect. Talk about buried. LOL
 
As usual, I'm now at the wrong end of the garden path and the shovel is in the shed...

OnReceiveOpen:
Code:
    hr = SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SOUND_STATE, "Sound");
OnReceiveEvent
Code:
    switch (pEvent->uEventID)
    {
        case CLIENT_6HZ:
        {
            // Sound state
            hr = SimConnect_RequestSystemState(hSimConnect, EVENT_SOUND_STATE, "Sound");
        }
    }
OnReceiveSystemState
Code:
    if (pData->dwRequestID)
    {
        switch (pData->dwRequestID)
        {
            case EVENT_SOUND_STATE:
                // What do I do here?
            break;
        }
    }
Any half-sensible replies? Any variation on 'write some code' will be politely ignored... :rotfl:
 
First... I thought the system event was not a timed response but rather is sent whenever the value has changed?
When you first subscribe, it should immediately return to you the current state of the sound toggle... a 1 is ON and a 0 is OFF. Each subsequent time you get this event it should show you the new value (which by logical conclusion will be the opposite of what it was before).

Not sure why you're doing request repeatedly...
 
Back
Top