[JUCE API] Load Preset

SangHoon You·2025년 4월 2일

JUCE API

목록 보기
3/17

The XML file needs to be imported and converted into parameters

case IdComboBoxPreset::Load:
                    {
                        DBG("Load");
                        mPresetManager.loadXmlPreset(file);
                        break;
                    }

void MyPresetManager::loadXmlPreset(const juce::File& inFileXml) noexcept
{
	std::unique_ptr<juce::XmlElement> xml = juce::XmlDocument::parse(inFileXml);
}

First, the selected inFile object from the file explorer needs to be converted into XML. In this case, the parse() function should be used.


juce::FIile inFile ?

juce::File doesn't actually contain the file itself. It just holds the file's path and name. So whether you're saving or loading something through the file explorer, you can still use it to handle the result data.



const juce::ValueTree inState = juce::ValueTree::fromXml(*xml);

This is process of converting from xml to valuetree(parameter). It is important to pass a pointer to a parameter.



    if(inState.getType() == mApvts.state.getType())
    {
        mApvts.replaceState(inState);
    }

At this, getType() return as an juce::Identifier. It indicates the ID of ValuTree. The replaceState() method in apvts updates the parameter.

profile
Audio Plugin Developer

0개의 댓글