# Loading a preset directly into the VST

**URL:** <https://forum.juce.com/t/loading-a-preset-directly-into-the-vst/21662>\
**Category:** General JUCE discussion\
**Created:** [April 5, 2017, 12:50pm UTC](https://forum.juce.com/t/loading-a-preset-directly-into-the-vst/21662 "2017-04-05T12:50:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ricochet](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ricochet](https://forum.juce.com/u/ricochet)\
**Post date:** [April 5, 2017, 12:50pm UTC](https://forum.juce.com/t/loading-a-preset-directly-into-the-vst/21662/1 "2017-04-05T12:50:20Z")

</div>

I can extract and store single presets from a soundbank on my harddisk (as .fxp) using Juce.  
Also it’s possible to load such a preset from disk and apply it again to the VST at a certain preset slot using Juce.  
What doesn’t work: having the VST open (in my case Sylenth1) and directly load such a preset from disk (without using Juce).  
Either Juce generally doesn’t support storing presets in the format which the VST expects or i need to change my code when storing extracted presets from a sound bank:

```
    // instance is an AudioPluginInstance
    instance->setCurrentProgram(i);
    MemoryBlock mb1;
    VSTPluginFormat::saveToFXBFile(instance, mb1, false);
    File file1 (AppData::Paths::presetsPath + String(preset->itemId) + AppData::Presets::presetFileExtension);
    FileOutputStream out (file1);
    out.write(mb1.getData(), mb1.getSize());

```

Could someone please confirm or correct that? Thank you.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 5, 2017, 12:53pm UTC](https://forum.juce.com/t/loading-a-preset-directly-into-the-vst/21662/2 "2017-04-05T12:53:12Z")

</div>

> [@ricochet](#):
>
> File file1 (AppData::Paths::presetsPath + String(preset-\>itemId) + AppData::Presets::presetFileExtension);  
> FileOutputStream out (file1);  
> out.write(mb1.getData(), mb1.getSize());

This will just keep appending data to the end of the file rather than overwriting it, you know?

---

<div class="post-metadata">

**Author:** ![ricochet](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ricochet](https://forum.juce.com/u/ricochet)\
**Post date:** [April 5, 2017, 1:01pm UTC](https://forum.juce.com/t/loading-a-preset-directly-into-the-vst/21662/3 "2017-04-05T13:01:21Z")

</div>

No no it works fine: These 4 lines will generate a new File since preset-\>itemId is increased in a for loop.  
I just shortened it for brevity.

SOLVED

---

<div class="post-metadata">

**Author:** ![udisoft](https://avatars.discourse-cdn.com/v4/letter/u/ecccb3/32.png) [@udisoft](https://forum.juce.com/u/udisoft)\
**Post date:** [October 16, 2024, 6:43pm UTC](https://forum.juce.com/t/loading-a-preset-directly-into-the-vst/21662/4 "2024-10-16T18:43:29Z")

</div>

I am trying to follow the above and save a Serum preset using the code below.

void savePreset(juce::String presetSavePath)  
{  
juce::MemoryBlock mb;  
juce::VSTPluginFormat::saveToFXBFile(plugin.get(), mb, false);  
juce::File presetSaveFile(presetSavePath);  
juce::FileOutputStream out(presetSaveFile);  
out.write(mb.getData(), mb.getSize());  
}

The file gets saved, but when I load the preset in Serum, nothing happens. Thankful for any help from anyone who has tried a similar thing.
