Table of Contents

Class Vst3Preset

Namespace
NAudio.Vst3
Assembly
NAudio.Vst3.dll

Reads and writes Steinberg .vstpreset files — the standard on-disk container for a VST 3 plug-in's saved state. A preset bundles the component (DSP) state blob and, optionally, the controller (UI / parameter) state blob, tagged with the plug-in's class identifier so a host can refuse to load a preset that belongs to a different plug-in.

public static class Vst3Preset
Inheritance
Vst3Preset
Inherited Members

Remarks

This type handles only the binary container. To save or load the state of a live plug-in use SavePreset(string) / LoadPreset(string), which capture and apply the component / controller blobs for you.

File layout (all integers little-endian, offsets relative to the start of the preset):

Header (48 bytes):  "VST3" | int32 version | char[32] classID | int64 chunkListOffset
Chunk data:         <component bytes><controller bytes><meta-info bytes>
Chunk list:         "List" | int32 entryCount | { char[4] id, int64 offset, int64 size } * n

The class ID stored in the header is the COM / GUID string form Steinberg uses on Windows (COM_COMPATIBLE): the 16-byte TUID rendered as a 32-character hex string with the first three GUID fields byte-swapped. The ClassId returned by Read(Stream) is converted back to the raw-TUID hex used elsewhere in the library (e.g. ClassId), so the two are directly comparable.

Fields

ComponentChunkId

Chunk id for the component (processor / DSP) state blob.

public const string ComponentChunkId = "Comp"

Field Value

string

ControllerChunkId

Chunk id for the controller (edit-controller / parameter) state blob.

public const string ControllerChunkId = "Cont"

Field Value

string

MetaInfoChunkId

Chunk id for the optional XML meta-info chunk.

public const string MetaInfoChunkId = "Info"

Field Value

string

Methods

Read(Stream)

Reads and parses a .vstpreset from stream (which must be seekable).

public static Vst3PresetContents Read(Stream stream)

Parameters

stream Stream

Returns

Vst3PresetContents

Exceptions

InvalidDataException

The stream is not a well-formed .vstpreset.

Read(string)

Reads and parses a .vstpreset from the given file.

public static Vst3PresetContents Read(string filePath)

Parameters

filePath string

Returns

Vst3PresetContents

ReadClassId(Stream)

Reads just the class id from a .vstpreset stream, without loading the state blobs. Returned in raw-TUID hex so it can be compared directly with ClassId.

public static string ReadClassId(Stream stream)

Parameters

stream Stream

Returns

string

ReadClassId(string)

Reads just the class id from a .vstpreset file, without loading the state blobs.

public static string ReadClassId(string filePath)

Parameters

filePath string

Returns

string

Write(Stream, string, ReadOnlySpan<byte>, ReadOnlySpan<byte>, string?)

Writes a .vstpreset to stream (which must be seekable). The component blob is always written; the controller blob is written only when controllerState is non-empty, and the meta-info chunk only when metaInfoXml is non-null.

public static void Write(Stream stream, string classId, ReadOnlySpan<byte> componentState, ReadOnlySpan<byte> controllerState, string? metaInfoXml = null)

Parameters

stream Stream

Destination stream; written from its current position and must be seekable.

classId string

The plug-in's class id as 32 hex characters in raw-TUID order (i.e. the value of ClassId / ClassInfo). It is converted to the GUID string form on the wire.

componentState ReadOnlySpan<byte>

The component (DSP) state blob.

controllerState ReadOnlySpan<byte>

The controller state blob, or empty to omit the chunk.

metaInfoXml string

Optional meta-info XML, or null to omit the chunk.