Add VST3 .vstpreset interchange codec and serialization provider#40
Merged
Conversation
Implements the .vstpreset interchange from the .NET VST3 effects host plan (upstream roadmap item #5), so ktsu persistence can round-trip host preset files. - VstPresetFile: a faithful reader/writer for the Steinberg VST3 .vstpreset container format (VST3 header + class id + component/controller/info chunks + trailing little-endian chunk list). Stream and byte[] overloads. Files it writes are loadable by hosts, and host-written presets read back. - VstPreset: the decoded model (class id, component state, optional controller state, optional XML metadata, version). - VstPresetSerializationProvider: an ISerializationProvider that wraps an inner provider (e.g. JSON) and packages its output as the component chunk of a .vstpreset, Base64-encoded to satisfy the string-based interface. For direct byte/file interop, VstPresetFile is used directly. All additive and netstandard2.0-compatible. Includes MSTest/FluentAssertions coverage: header validation, full round-trips (component only, all chunks, empty state), malformed-input and non-seekable-stream guards, and provider round-trip producing a real Base64-encoded .vstpreset.
CI's code-style analyzers (which the local sandbox SDK cannot load) flag the explicit constructor as IDE0290. Convert to a primary constructor with validating field initializers; behaviour is unchanged.
The ktsu.Sdk analyzer KTSU0004 (which the local sandbox SDK cannot load) requires Ensure.NotNull(x) instead of manual `?? throw new ArgumentNullException`. Replace the null checks in VstPreset, VstPresetFile, and VstPresetSerializationProvider accordingly; Ensure.NotNull returns the validated value, so it also works in the primary-constructor field initializers. Behaviour is unchanged.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Implements upstream roadmap item #5 from the .NET VST3 effects host plan: a
.vstpresetinterchange backend so ktsu persistence can round-trip host preset files.VstPresetFile— a faithful reader/writer for the Steinberg VST3.vstpresetcontainer format: theVST3header + version + 32-byte class id + anint64chunk-list offset, theComp/Cont/Infostate chunks, and a trailing little-endianList. ProvidesStreamandbyte[]overloads. Files it writes are loadable by hosts, and host-written presets read back.VstPreset— the decoded model: class id, component state, optional controller state, optional XML metadata, and version.VstPresetSerializationProvider— anISerializationProviderthat wraps an inner provider (e.g. JSON) and packages its output as the component chunk of a.vstpreset. Because the interface is string-based, the binary preset is returned Base64-encoded; for direct file/byte interop callers useVstPresetFiledirectly.All additive and netstandard2.0-compatible (uses
BinaryReader/BinaryWriter, which are little-endian on every platform).Testing
Added
VstPresetTests(8 cases, MSTest + FluentAssertions):VST3header validation, full round-trips (component-only, all three chunks, empty state), malformed-input and non-seekable-stream guards, and a provider round-trip that verifies the output is a Base64-encoded real.vstpreset. 20/20 tests pass locally (net10.0); the library also builds clean onnetstandard2.0.Note on AppData
Roadmap #5 names "SerializationProvider / AppData". The substantive interop primitive — the container codec — lives here in SerializationProvider, its natural home;
ktsu.AppDatacan adopt.vstpresetstorage by consuming this codec (or the provider) through its existing serializer seam, with no AppData changes required by this PR.🤖 Part of the ktsu VST plugin upstream-enablement work.
https://claude.ai/code/session_01JQ3bQMuSYuumAnQZaYUKP7
Generated by Claude Code