How to force createStateXml() to return the current settings?

I need to save/recall AudioDeviceManager settings regardless of changes (they are to be stored as meta information with recordings).

From an older post (Retrieving AudioDeviceManager's Xml State yields null) I learnt that createStateXml() is supposed to return nullptr if AudioDeviceManager settings have not been changed. Changing settings triggers AudioDeviceManager ::updateXML() which is (unfortunately in my case) private.

So how can I get the settings?

I tried AudioDeviceManager::AudioDeviceSetup currentAudioDeviceSetup = audioDeviceManager->getAudioDeviceSetup() but this does not include MIDI settings.

Maybe createStateXml() should be changed to createStateXml(bool forceReturnStateIfSettingsUnchanged=false)?

the AudioDeviceManager class is a ChangeBroadcaster, so somewhere else in your app (presumably whichever class owns that object), listen for changes and cache a copy of the settings when they change,

void MyAppClass::changeListenerCallback(ChangeBroadcaster* src) override 
   if (src == &audioManager)
      audioXml = audioManager.createStateXml();