/ HALion Developer Resource / HALion Script / Reference /

savePreset

savePreset(filename, layer, plugin, attr)

(Since HALion 7.0)

Description

Function to save a layer as VST preset to disk.

Available in: Controller.

Arguments

ArgumentDescriptionValue Type
filenameThe absolute path and name of the VST preset.string
layerSpecifies the Layer element which is to be saved.Layer
pluginDetermines the plug-in for the VST preset. You can choose H7 (HALion 7) or HS (HALion Sonic).string, optional
attrSet this to program to save a program VST preset. If this is not set, a layer VST preset will be saved. Alternatively, you can provide a table with MediaBay attributes and values.string, optional

MediaBay Attributes

AttributeValueValue Type
MediaAuthor"Author"string
MediaComment"Comment"string
MediaLibraryManufacturerName"ManufacturerName"string
MediaLibraryName"LibraryName"string
MediaRating3integer
MusicalArticulations"Articulation1|Articulation2|..."string
MusicalCategory"Category"string
MusicalInstrument"Category|Subcategory"string
MusicalMoods"Mood1|Mood2|..."string
MusicalProperties"Property1|Property2|..."string
MusicalStyle"Style"string
MusicalSubStyle"Style|Substyle"string
VST3UnitTypePath"program" or "program/layer"string

❕ See MediaBay Guideline for more information about the attributes and how to use them.

Example

posStart, posEnd = string.find(getUserSubPresetPath(), "Steinberg/")
fileLocation = string.sub(getUserSubPresetPath(), 1, posEnd)

defineParameter("FileName", nil, "test.vstpreset")
defineParameter("SavePreset", nil, false, function() if SavePreset then onSavePresetChanged() end end)

setScriptExecTimeOut(20000)

attr = {MediaRating = 3, MusicalProperties = "Soft|Bright|Rich", VST3UnitTypePath = "program",}

function onSavePresetChanged()
	FileName = fileLocation..FileName
	local layer = this.parent:getLayer()
	local saved = savePreset(FileName, layer, "HS", attr)
	print(saved)
	SavePreset = false
end