# VST Bank Support

**URL:** <https://forum.juce.com/t/vst-bank-support/1600>\
**Category:** Audio Plugins\
**Created:** [April 3, 2007, 8:06am UTC](https://forum.juce.com/t/vst-bank-support/1600 "2007-04-03T08:06:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyriacos](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kyriacos](https://forum.juce.com/u/kyriacos)\
**Post date:** [April 3, 2007, 8:06am UTC](https://forum.juce.com/t/vst-bank-support/1600/1 "2007-04-03T08:06:14Z")

</div>

Hi Jules, Jucers,  
The current framework does not support vst bank load and save.  
I have made some changes so this functionality is supported.  
Regards  
Koull (Kyriacos)

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
//file juce\_VstWrapper.cpp  
VstInt32 getChunk (void\*\* data, bool isPreset)  
{  
chunkMemory.setSize (0);  
//filter-\>getStateInformation (chunkMemory);  
//kk changed to support both presets and banks  
filter-\>getStateInformation (chunkMemory,isPreset);  
_data = (void_) chunkMemory;

```
    // because the chunk is only needed temporarily by the host (or at least you'd
    // hope so) we'll give it a while and then free it in the timer callback.
    chunkMemoryTime = JUCE_NAMESPACE::Time::getApproximateMillisecondCounter();

    return chunkMemory.getSize();
}

```

VstInt32 setChunk (void\* data, VstInt32 byteSize, bool isPreset)  
{  
chunkMemory.setSize (0);  
chunkMemoryTime = 0;

```
    if (byteSize > 0 && data != 0)
    	//filter->setStateInformation (data, byteSize);
	//kk changed to support both presets and banks
	filter->setStateInformation (data, byteSize, isPreset);

    return 0;
}

```

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
//file juce\_AudioFilterBase.h  
virtual void JUCE\_CALLTYPE getStateInformation (JUCE\_NAMESPACE::MemoryBlock& destData) = 0;  
//kk overload to support vst banks  
virtual void JUCE\_CALLTYPE getStateInformation (JUCE\_NAMESPACE::MemoryBlock& destData, bool isPreset) = 0;

```
/** This must restore the plugin's state from a block of data previously created
    using getStateInformation().

    See also the helper function getXmlFromBinary() for loading settings as XML.
*/
	virtual void JUCE_CALLTYPE setStateInformation (const void* data, int sizeInBytes) = 0;
//kk overload to support vst banks
virtual void JUCE_CALLTYPE setStateInformation (const void* data, int sizeInBytes, bool isPreset) = 0;

```

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
//file DemoJuceFilter.h  
void JUCE\_CALLTYPE getStateInformation (JUCE\_NAMESPACE::MemoryBlock& destData);  
void JUCE\_CALLTYPE setStateInformation (const void\* data, int sizeInBytes);

```
//kk vst bank support
void JUCE_CALLTYPE getStateInformation (JUCE_NAMESPACE::MemoryBlock& destData, bool isPreset);
void JUCE_CALLTYPE setStateInformation (const void* data, int sizeInBytes, bool isPreset);

```

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
//file DemoJuceFilter.cpp  
//kk example how to save/load banks and presets  
void DemoJuceFilter::getStateInformation (JUCE\_NAMESPACE::MemoryBlock& destData, bool isPreset)  
{  
if (isPreset)  
{  
getStateInformation(destData);  
}  
else //complete bank  
{  
XmlElement xmlState (T(“KK\_BANK”));

```
   xmlState.setAttribute (T("Version"), "1.1.0");

   String sMyParameter = "MyParameter";

   for (int i=0; i<this->getNumPrograms(); i++)
   {
	

		xmlState.setAttribute (sMyParameter + String(i), programs[i]->fMyParameter);

   }

   copyXmlToBinary (xmlState, destData);
}

```

}

void DemoJuceFilter::setStateInformation (const void\* data, int sizeInBytes, bool isPreset)  
{  
if (isPreset)  
{  
setStateInformation(data, sizeInBytes);  
}  
else  
{  
String sMyParameter = “MyParameter”;

```
	XmlElement* const xmlState = getXmlFromBinary (data, sizeInBytes);

	if (xmlState != 0)
	{
		// check that it's the right type of xml..
		if (xmlState->hasTagName (T("KK_BANK")))
		{
			for (int i=0; i<this->getNumPrograms(); i++)
			{
				programs[i]->fMyParameter = (float) xmlState->getDoubleAttribute (sMyParameter + String(i), fMyParameter);

			}

			sendChangeMessage (this);
		}
	}
	delete xmlState;
}

```

}

---

<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 3, 2007, 9:07am UTC](https://forum.juce.com/t/vst-bank-support/1600/2 "2007-04-03T09:07:56Z")

</div>

That’s interesting - I didn’t realise that’s how it worked. Not surprising, as of course the VST headers don’t actually say what “isPreset” is for.

I’ll merge something similar into my code, but will change “isPreset” to “onlyStoreCurrentProgramData”, so that it’s clear what’s actually happening!

---

<div class="post-metadata">

**Author:** ![mdsp](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@mdsp](https://forum.juce.com/u/mdsp)\
**Post date:** [April 3, 2007, 1:51pm UTC](https://forum.juce.com/t/vst-bank-support/1600/3 "2007-04-03T13:51:34Z")

</div>

great

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [April 3, 2007, 7:25pm UTC](https://forum.juce.com/t/vst-bank-support/1600/4 "2007-04-03T19:25:28Z")

</div>

yep gr8 ! that was i thing i had overseen a lot of times… the pity of using too much the AudioFilterBase, that let you forget about the underlying implementations 🙂

---

<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:** [May 12, 2017, 8:57pm UTC](https://forum.juce.com/t/vst-bank-support/1600/5 "2017-05-12T20:57:09Z")

</div>


