VST 3 SDK  VST 3.7
SDK for developing VST plug-in
PresetFile Class Reference

Handler for a VST 3 Preset File. More...

#include <vstpresetfile.h>

Classes

struct  Entry
 Internal structure used for chunk handling. More...
 

Public Member Functions

 PresetFile (IBStream *stream)
 Constructor of Preset file based on a stream. More...
 
virtual ~PresetFile ()
 
IBStreamgetStream ()
 Returns the associated stream. More...
 
const FUIDgetClassID () const
 Returns the associated classID (component ID: Processor part (not the controller!)). More...
 
void setClassID (const FUID &uid)
 Sets the associated classID (component ID: Processor part (not the controller!)). More...
 
const EntrygetEntry (ChunkType which) const
 Returns an entry for a given chunk type. More...
 
const EntrygetLastEntry () const
 Returns the last available entry. More...
 
int32 getEntryCount () const
 Returns the number of total entries in the current stream. More...
 
const Entryat (int32 index) const
 Returns the entry at a given position. More...
 
bool contains (ChunkType which) const
 Checks if a given chunk type exist in the stream. More...
 
bool readChunkList ()
 Reads and build the chunk list (including the header chunk). More...
 
bool writeHeader ()
 Writes into the stream the main header. More...
 
bool writeChunkList ()
 Writes into the stream the chunk list (should be at the end). More...
 
bool readMetaInfo (char *xmlBuffer, int32 &size)
 Reads the meta XML info and its size, the size could be retrieved by passing zero as xmlBuffer. More...
 
bool writeMetaInfo (const char *xmlBuffer, int32 size=-1, bool forceWriting=false)
 Writes the meta XML info, -1 means null-terminated, forceWriting to true will force to rewrite the XML Info when the chunk already exists. More...
 
bool prepareMetaInfoUpdate ()
 checks if meta info chunk is the last one and jump to correct position. More...
 
bool writeChunk (const void *data, int32 size, ChunkType which=kComponentState)
 Writes a given data of a given size as "which" chunk type. More...
 
bool seekToComponentState ()
 Seeks to the begin of the Component State. More...
 
bool storeComponentState (IComponent *component)
 Stores the component state (only one time). More...
 
bool storeComponentState (IBStream *componentStream)
 Stores the component state from stream (only one time). More...
 
bool restoreComponentState (IComponent *component)
 Restores the component state. More...
 
bool seekToControllerState ()
 Seeks to the begin of the Controller State. More...
 
bool storeControllerState (IEditController *editController)
 Stores the controller state (only one time). More...
 
bool storeControllerState (IBStream *editStream)
 Stores the controller state from stream (only one time). More...
 
bool restoreControllerState (IEditController *editController)
 Restores the controller state. More...
 
bool restoreComponentState (IEditController *editController)
 Restores the component state and apply it to the controller. More...
 
bool storeProgramData (IBStream *inStream, ProgramListID listID)
 Store program data or unit data from stream (including the header chunk). More...
 
bool storeProgramData (IProgramListData *programListData, ProgramListID programListID, int32 programIndex)
 Stores a IProgramListData with a given identifier and index (including the header chunk). More...
 
bool restoreProgramData (IProgramListData *programListData, ProgramListID *programListID=nullptr, int32 programIndex=0)
 Restores a IProgramListData with a given identifier and index. More...
 
bool storeProgramData (IUnitData *unitData, UnitID unitID)
 Stores a IUnitData with a given unitID (including the header chunk). More...
 
bool restoreProgramData (IUnitData *unitData, UnitID *unitID=nullptr)
 Restores a IUnitData with a given unitID (optional). More...
 
bool restoreProgramData (IUnitInfo *unitInfo, int32 unitProgramListID, int32 programIndex=-1)
 for keeping the controller part in sync concerning preset data stream, unitProgramListID could be ProgramListID or UnitID. More...
 
bool getUnitProgramListID (int32 &unitProgramListID)
 Gets the unitProgramListID saved in the kProgramData chunk (if available). More...
 

Static Public Member Functions

static bool savePreset (IBStream *stream, const FUID &classID, IComponent *component, IEditController *editController=nullptr, const char *xmlBuffer=nullptr, int32 xmlSize=-1)
 Shortcut helper to create preset from component/controller state. More...
 
static bool savePreset (IBStream *stream, const FUID &classID, IBStream *componentStream, IBStream *editStream=nullptr, const char *xmlBuffer=nullptr, int32 xmlSize=-1)
 
static bool loadPreset (IBStream *stream, const FUID &classID, IComponent *component, IEditController *editController=nullptr, std::vector< FUID > *otherClassIDArray=nullptr)
 Shortcut helper to load preset with component/controller state. More...
 

Protected Types

enum  { kMaxEntries = 128 }
 

Protected Member Functions

bool readID (ChunkID id)
 
bool writeID (const ChunkID id)
 
bool readEqualID (const ChunkID id)
 
bool readSize (TSize &size)
 
bool writeSize (TSize size)
 
bool readInt32 (int32 &value)
 
bool writeInt32 (int32 value)
 
bool seekTo (TSize offset)
 
bool beginChunk (Entry &e, ChunkType which)
 
bool endChunk (Entry &e)
 

Protected Attributes

IBStreamstream
 
FUID classID
 classID is the FUID of the component (processor) part More...
 
Entry entries [kMaxEntries]
 
int32 entryCount
 

Detailed Description

Handler for a VST 3 Preset File.

See also
Preset Format

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
kMaxEntries 

Constructor & Destructor Documentation

◆ PresetFile()

PresetFile ( IBStream stream)

Constructor of Preset file based on a stream.

◆ ~PresetFile()

~PresetFile ( )
virtual

Member Function Documentation

◆ getStream()

IBStream* getStream ( )
inline

Returns the associated stream.

◆ getClassID()

const FUID& getClassID ( ) const
inline

Returns the associated classID (component ID: Processor part (not the controller!)).

◆ setClassID()

void setClassID ( const FUID uid)
inline

Sets the associated classID (component ID: Processor part (not the controller!)).

◆ getEntry()

const PresetFile::Entry * getEntry ( ChunkType  which) const

Returns an entry for a given chunk type.

◆ getLastEntry()

const PresetFile::Entry * getLastEntry ( ) const

Returns the last available entry.

◆ getEntryCount()

int32 getEntryCount ( ) const
inline

Returns the number of total entries in the current stream.

◆ at()

const Entry& at ( int32  index) const
inline

Returns the entry at a given position.

◆ contains()

bool contains ( ChunkType  which) const
inline

Checks if a given chunk type exist in the stream.

◆ readChunkList()

bool readChunkList ( )

Reads and build the chunk list (including the header chunk).

◆ writeHeader()

bool writeHeader ( )

Writes into the stream the main header.

◆ writeChunkList()

bool writeChunkList ( )

Writes into the stream the chunk list (should be at the end).

◆ readMetaInfo()

bool readMetaInfo ( char xmlBuffer,
int32 size 
)

Reads the meta XML info and its size, the size could be retrieved by passing zero as xmlBuffer.

◆ writeMetaInfo()

bool writeMetaInfo ( const char xmlBuffer,
int32  size = -1,
bool  forceWriting = false 
)

Writes the meta XML info, -1 means null-terminated, forceWriting to true will force to rewrite the XML Info when the chunk already exists.

◆ prepareMetaInfoUpdate()

bool prepareMetaInfoUpdate ( )

checks if meta info chunk is the last one and jump to correct position.

◆ writeChunk()

bool writeChunk ( const void *  data,
int32  size,
ChunkType  which = kComponentState 
)

Writes a given data of a given size as "which" chunk type.

◆ seekToComponentState()

bool seekToComponentState ( )

Seeks to the begin of the Component State.

◆ storeComponentState() [1/2]

bool storeComponentState ( IComponent component)

Stores the component state (only one time).

◆ storeComponentState() [2/2]

bool storeComponentState ( IBStream componentStream)

Stores the component state from stream (only one time).

◆ restoreComponentState() [1/2]

bool restoreComponentState ( IComponent component)

Restores the component state.

◆ seekToControllerState()

bool seekToControllerState ( )

Seeks to the begin of the Controller State.

◆ storeControllerState() [1/2]

bool storeControllerState ( IEditController editController)

Stores the controller state (only one time).

◆ storeControllerState() [2/2]

bool storeControllerState ( IBStream editStream)

Stores the controller state from stream (only one time).

◆ restoreControllerState()

bool restoreControllerState ( IEditController editController)

Restores the controller state.

◆ restoreComponentState() [2/2]

bool restoreComponentState ( IEditController editController)

Restores the component state and apply it to the controller.

◆ storeProgramData() [1/3]

bool storeProgramData ( IBStream inStream,
ProgramListID  listID 
)

Store program data or unit data from stream (including the header chunk).

Parameters
inStream
listIDcould be ProgramListID or UnitID.

◆ storeProgramData() [2/3]

bool storeProgramData ( IProgramListData programListData,
ProgramListID  programListID,
int32  programIndex 
)

Stores a IProgramListData with a given identifier and index (including the header chunk).

◆ restoreProgramData() [1/3]

bool restoreProgramData ( IProgramListData programListData,
ProgramListID programListID = nullptr,
int32  programIndex = 0 
)

Restores a IProgramListData with a given identifier and index.

◆ storeProgramData() [3/3]

bool storeProgramData ( IUnitData unitData,
UnitID  unitID 
)

Stores a IUnitData with a given unitID (including the header chunk).

◆ restoreProgramData() [2/3]

bool restoreProgramData ( IUnitData unitData,
UnitID unitID = nullptr 
)

Restores a IUnitData with a given unitID (optional).

◆ restoreProgramData() [3/3]

bool restoreProgramData ( IUnitInfo unitInfo,
int32  unitProgramListID,
int32  programIndex = -1 
)

for keeping the controller part in sync concerning preset data stream, unitProgramListID could be ProgramListID or UnitID.

◆ getUnitProgramListID()

bool getUnitProgramListID ( int32 unitProgramListID)

Gets the unitProgramListID saved in the kProgramData chunk (if available).

◆ savePreset() [1/2]

bool savePreset ( IBStream stream,
const FUID classID,
IComponent component,
IEditController editController = nullptr,
const char xmlBuffer = nullptr,
int32  xmlSize = -1 
)
static

Shortcut helper to create preset from component/controller state.

classID is the FUID of the component (processor) part.

◆ savePreset() [2/2]

bool savePreset ( IBStream stream,
const FUID classID,
IBStream componentStream,
IBStream editStream = nullptr,
const char xmlBuffer = nullptr,
int32  xmlSize = -1 
)
static

◆ loadPreset()

bool loadPreset ( IBStream stream,
const FUID classID,
IComponent component,
IEditController editController = nullptr,
std::vector< FUID > *  otherClassIDArray = nullptr 
)
static

Shortcut helper to load preset with component/controller state.

classID is the FUID of the component (processor) part.

◆ readID()

bool readID ( ChunkID  id)
protected

◆ writeID()

bool writeID ( const ChunkID  id)
protected

◆ readEqualID()

bool readEqualID ( const ChunkID  id)
protected

◆ readSize()

bool readSize ( TSize size)
protected

◆ writeSize()

bool writeSize ( TSize  size)
protected

◆ readInt32()

bool readInt32 ( int32 value)
protected

◆ writeInt32()

bool writeInt32 ( int32  value)
protected

◆ seekTo()

bool seekTo ( TSize  offset)
protected

◆ beginChunk()

bool beginChunk ( Entry e,
ChunkType  which 
)
protected

◆ endChunk()

bool endChunk ( Entry e)
protected

Member Data Documentation

◆ stream

IBStream* stream
protected

◆ classID

FUID classID
protected

classID is the FUID of the component (processor) part

◆ entries

Entry entries[kMaxEntries]
protected

◆ entryCount

int32 entryCount
protected
Empty

Copyright ©2020 Steinberg Media Technologies GmbH. All Rights Reserved. This documentation is under this license.