Ok, this is a bit tricky. I have a wusikprst file, which is actually what I use to read and use as a setChunk for a VST. So, all I need to do is read it to memory and send to a setChunk. But I don’t want to over-do any code. From what I see the setStateInformation() would do the job, as long as I convert the read information into a FXP/FXB format, right? Here’s the code I’m trying to use on Windows, it crashes every time. :oops:
Here’s the working code. It will read a WusikPRST file, which is actually a Chunk Data saved to a Binary file, and output a MemoryBlock ready to be sent to the setInformationSate. 8)
[code] struct fxProgramSet_convert
{
long chunkMagic; // 'CcnK’
long byteSize; // of this chunk, excl. magic + byteSize
long fxMagic; // ‘FxCh’, ‘FPCh’, or 'FBCh’
long version;
long fxID; // fx unique id
long fxVersion;
long numPrograms;
char name[28];
long chunkSize;
};
Here’s another useful code, for those who need to convert something to a FXB/FXP format. I had to use this for when I load an old Wusik Station project. So it would detect it wasn’t in the Juce FXB/FXP format and convert if required.
[code]void convertDataToFXB (MemoryBlock& dest, const void* data, int sizeInBytes)
{
// First Check if its not a FXP already //
if (sizeInBytes > 28)
{
fxProgramSet_convert* set = (fxProgramSet_convert*) data;
if (set->chunkMagic == vst_swap (‘CcnK’))
{
dest.append((const void*)data,sizeInBytes);
return; // Its already a FXP //
}
}
[code]struct fxChunkSet_convert
{
long chunkMagic; // 'CcnK’
long byteSize; // of this chunk, excl. magic + byteSize
long fxMagic; // ‘FxCh’, ‘FPCh’, or 'FBCh’
long version;
long fxID; // fx unique id
long fxVersion;
long numPrograms;
char future[128];
long chunkSize;
};
void convertDataToFXB (MemoryBlock& dest, const void* data, int sizeInBytes);[/code]
Plus the headers from the previous code I posted above.
Now, here’s how I use this:
void FilterComponent::setStateInformation (const void* data, int sizeInBytes)
{
if (VstInstance != 0)
{
MemoryBlock dest;
convertDataToFXB(dest,data,sizeInBytes);
VstInstance->setStateInformation (dest.getData(),dest.getSize());
}
}