Page tree
Skip to end of metadata
Go to start of metadata

The properties of the LoadProgress class can be used to monitor the progress when loading elements of VST presets.

On this page:

Classes

LoadProgress Class

Description

The functions loadPresetAsync, appendLayerAsync and insertLayerAsync return a LoadProgress object. The properties of the LoadProgress object are described by the following fields.

Available in: Controller.

Fields

.progressThe load progress in the range from 0 to 1.number
.root

The value of .root will be the Element object of the first element (root) of the loaded VST preset. Depending on whether you load a layer, program, or multi-program VST preset, this is either an Element object of the type Layer, Program,or Instance.

Layer, Program or Instance
.cancelSet this to true to cancel the loading of the preset.boolean
.errorMessage if an error occured.string
.infoUser definable field, for example, to manage several loading threads.string or table

Example

-- start with an empty program, remove all existing layers
layers = this.parent:findLayers()

if layers then
   for i, layer in ipairs(layers) do
       this.parent:removeLayer(layer)
   end
end

-- table with layer presets from Skylab
layerPresets = {
   { name = "Ambient Pad 01", path = "vstsound://724ACB205EFF46F885735D1B216C37AD/.AppData/Steinberg/Skylab/Sub Presets/Layer Presets/Ambient Pads/Ambient Pad 01.vstpreset" },
   { name = "Ambient Pad 02", path = "vstsound://724ACB205EFF46F885735D1B216C37AD/.AppData/Steinberg/Skylab/Sub Presets/Layer Presets/Ambient Pads/Ambient Pad 02.vstpreset" },
   { name = "Ambient Pad 03", path = "vstsound://724ACB205EFF46F885735D1B216C37AD/.AppData/Steinberg/Skylab/Sub Presets/Layer Presets/Ambient Pads/Ambient Pad 03.vstpreset" },
   { name = "Ambient Pad 04", path = "vstsound://724ACB205EFF46F885735D1B216C37AD/.AppData/Steinberg/Skylab/Sub Presets/Layer Presets/Ambient Pads/Ambient Pad 04.vstpreset" },
}
-- create table with the preset names
function getPresetNames()
   presetNames = {}
   for i, preset in ipairs(layerPresets) do
       presetNames[i] = preset.name
   end
end

getPresetNames()

-- remove the old layer after the new one was added
function removeOldLayer(progressInfo)
   local newPreset = progressInfo.root
   if oldPreset then
       this.parent:removeLayer(oldPreset)
       print(oldPreset.name.." removed.")
   end
   oldPreset = newPreset
end

-- append the preset in a separate thread
function appendNewLayer(progressInfo)
   if progressInfo.root then
       this.parent:appendLayerAsync(progressInfo.root, removeOldLayer)
       print("Appending "..progressInfo.root.name.."...")
   end
end

-- load the preset in a separate thread
function onSelectPresetChanged()
   progress = 0
   progressInf = loadPresetAsync(layerPresets[SelectPreset].path, appendNewLayer)
   print("Loading "..layerPresets[SelectPreset].name.."...")
end

-- define a parameter for selecting the preset to be loaded
defineParameter("SelectPreset", "Select Preset", 1, presetNames, onSelectPresetChanged)

-- monitor the progress with onIdle
progress = 1
function onIdle()
   if progress < 1 then
       progress = progressInf.progress
       print("Progress: "..(progressInf.progress * 100).."%")
   end
end

 

Jump to Top

  • No labels

3 Comments

  1. Matthias, ich hab hier einen entsprechenden Einleitungssatz wie für die anderen Topics eingefügt ... ist der richtig? Please check!

    1. Hallo Sabine,

      LoadProgress steht in der Class Hierarchy neben Element und nicht darunter. Die LoadProgress Class erbt deshalb nichts. Ich hab einen alternativen Einleitungssatz geschrieben. Bitte Korrektur lesen. Danke.