Saving device settings xml


Hello again, I need some short advice on saving device settings.
I’m saving XML and it looks like this in a text editor:

DEVICESETUP deviceType="DirectSound" audioOutputDeviceName="Primary Sound Driver"
             audioInputDeviceName="Primary Sound Capture Driver" audioDeviceRate="88200"

But when I load it back in, it only sets the device name and type. Sample rate and buffer size all get reset to default. Any idea what’s going on? I’ve follow the code into juce and does grab them from the xml with these lines

setup.bufferSize = xml.getIntAttribute (“audioDeviceBufferSize”, setup.bufferSize);
setup.sampleRate = xml.getDoubleAttribute (“audioDeviceRate”, setup.sampleRate);

But then it ignores them. What am I doing wrong? I’m guessing I’m setting them in the wrong place where should the settings be initialised?


Never mind I appear to need to create a new AudioDeviceManager because the one in MainContentComponent() called ‘deviceManager’ doesn’t allow a re-initialise. I find this all slightly confusing, but I guess it’ll make sense at some point. :slight_smile:


I would find that confusing as well. I don’t think recreating the DeviceManager is needed.

What is your setup? Is the MainContentComponent inheriting AudioAppComponent? (I assume, because that one has the public deviceManager).

When you call the AudioAppComponent::setAudioChannels(int numInputChannels, int numOutputChannels, const XmlElement *const storedSettings=nullptr),
this is the right time to supply the xml settings, because this will call AudioIODevice::open(…). When the device is opened, changes to the samplerate will have no effect without closing the device and reopening (afaik).

On the other hand, the audio device can be changed from outside. Some apps could react when you change the samplerate with changing it back, and similar annoyances. For that purpose you have the changeMessages from the DeviceManager to react to.



Excellent thanks. Yes I have a deviceManager in AudioAppComponent. I’ve switched it back in and magically it appears to work now(!!!) I swear the file was being changed but the setting weren’t loading in. I’ll leave it now. I’m not using setAudioChannels I’m using straight deviceManager.initialise. I didn’t know the other existed. I’ll use the one in the AudioAppComponent now like you suggest.
Thanks again,
Dave H.