Docs

Sampler

This object can be used to access sampler-specific properties, like loading samplemaps, changing sample properties, setting the current RR index, etc.

If you have a generic reference obtained by calling Synth.getChildSynth() , you can turn it into a Sampler reference with ChildSynth.asSampler() :

const var genericReference = Synth.getChildSynth("MySampler");

genericReference.asSampler().loadSampleMap("My SampleMap");

Be aware that most of the functions that change samples will be executed asynchronously - if you want to keep your UI updated, take a look at ScriptPanel.setLoadingCallback()

Class methods

clearSampleMap

Clears the current samplemap.

Sampler.clearSampleMap()



createListFromGUISelection

Returns a list of the sounds selected in the samplemap.

Sampler.createListFromGUISelection()



createListFromScriptSelection

Returns a list of the sounds selected by the selectSounds() method.

Sampler.createListFromScriptSelection()



createSelection

Returns an array with all samples that match this regex.

Sampler.createSelection(String regex)



createSelectionFromIndexes

Returns an array with all samples from the index data (can be either int or array of int, -1 selects all.).

Sampler.createSelectionFromIndexes(var indexData)



createSelectionWithFilter

Returns an array with all samples that match the filter function.

Sampler.createSelectionWithFilter(var filterFunction)



enableRoundRobin

Enables / Disables the automatic round robin group start logic (works only on samplers).

Sampler.enableRoundRobin(bool shouldUseRoundRobin)



getActiveRRGroup

Returns the currently (single) active RR group.

Sampler.getActiveRRGroup()



getAttribute

Gets the attribute with the given index (use the constants for clearer code).

Sampler.getAttribute(int index)



getAttributeId

Returns the ID of the attribute with the given index.

Sampler.getAttributeId(int index)



getCurrentSampleMapId

Returns the currently loaded sample map.

Sampler.getCurrentSampleMapId()



getMicPositionName

Returns the name of the channel with the given index (Multimic samples only.

Sampler.getMicPositionName(int channelIndex)



getNumActiveGroups

Returns the number of currently active groups.

Sampler.getNumActiveGroups()



getNumAttributes

Returns the number of attributes.

Sampler.getNumAttributes()



getNumMicPositions

Returns the number of mic positions.

Sampler.getNumMicPositions()



getNumSelectedSounds

Returns the amount of selected samples.

Sampler.getNumSelectedSounds()



getRRGroupsForMessage

Returns the amount of actual RR groups for the notenumber and velocity

Sampler.getRRGroupsForMessage(int noteNumber, int velocity)



getSampleMapList

Returns an array with all available sample maps.

Sampler.getSampleMapList()



getSoundProperty

Returns the property of the sound with the specified index.

Sampler.getSoundProperty(int propertyIndex, int soundIndex)



importSamples

Loads a few samples in the current samplemap and returns a list of references to these samples.

Sampler.importSamples(var fileNameList, bool skipExistingSamples)



isMicPositionPurged

Checks if the mic position is purged.

Sampler.isMicPositionPurged(int micIndex)



isNoteNumberMapped

Checks whether the note number is mapped to any samples.

Sampler.isNoteNumberMapped(int noteNumber)



loadSampleForAnalysis

Loads the content of the given sample into an array of VariantBuffers that can be used for analysis.

Sampler.loadSampleForAnalysis(int indexInSelection)



loadSampleMap

Loads a new samplemap into this sampler.

Sampler.loadSampleMap( String fileName)


This method will return immediately and load a new samplemap on a background thread.

If you want to be notified when the sample loading has finished, you will need to create a Panel and add a PreloadingCallback using setLoadingCallback()

loadSfzFile

Loads an SFZ file into the sampler.

Sampler.loadSfzFile(var sfzFile)


This function expects either a String with a full path to the SFZ file or a File object and will try to parse it and load the multisample set into the Sampler. This finally enables you to offer multisample import on your compiled plugin! Be aware that if you load a SFZ file, the sampler will not store this information automatically, so you need to add a UI component that stores that information and calls this function in its control callback. A suitable candidate for this would be a ScriptPanel with file-drop support using this API function

The SFZ importer is not fully standard compliant (at this point it's just the old HISE SFZ import that has been cleaned up a little bit). However the goal is to offer enough standard compliance so that all mapping information of a SFZ is being imported correctly and without crashing the plugin (obviously stuff like the envelope attack time will never be parsed). If you encounter an issue with a SFZ file, please post it in the forum, then I'll take a look.

purgeMicPosition

Purges all samples of the given mic (Multimic samples only).

Sampler.purgeMicPosition(String micName, bool shouldBePurged)



refreshInterface

Refreshes the interface. Call this after you changed the properties.

Sampler.refreshInterface()



refreshRRMap

Recalculates the RR Map. Call this at compile time if you want to use 'getRRGroupForMessage()'.

Sampler.refreshRRMap()



saveCurrentSampleMap

Saves (and loads) the current samplemap to the given path (which should be the same string as the ID).

Sampler.saveCurrentSampleMap(String relativePathWithoutXml)



selectSounds

Selects samples using the regex string as wildcard and the selectMode ("SELECT", "ADD", "SUBTRACT")

Sampler.selectSounds(String regex)



setActiveGroup

Enables the group with the given index (one-based). Works only with samplers and enableRoundRobin(false) .

Sampler.setActiveGroup(int activeGroupIndex)



setAttribute

Sets a attribute to the given value.

Sampler.setAttribute(int index, var newValue)



setMultiGroupIndex

Enables the group with the given index (one-based). Allows multiple groups to be active.

Sampler.setMultiGroupIndex(var groupIndex, bool enabled)


This function can be used to enabled multiple groups at once. By default, only one RR group is active at the same time - as long as the Group XF property is disabled, then it will play all groups.

You can define a custom RR behaviour using Sampler.setActiveGroup() , but this function still gives you one exclusively active group.

However there are a few legitimate edge cases where you need multiple, but not all groups enabled - the most common one might be if you want to implement round robin behaviour in combination with Group XF samples.

In order to do so, you can use this function to tell the sampler to allow multiple groups at the same time - you also need to call Sampler.enableRoundRobin(false) before using this function. The function accepts different types as groupIndex argument:

Be aware that as soon as you activate this feature by calling this method, the table index used for defining the crossfade gain will be capped to the number of active groups (groupIndex %= numActiveGroups ). The rationale behind this is that if you have 4 dynamic layers and 3 round robin repetitions, you still want only 4 tables to be active (instead of 12). However this means that as soon as you use this feature the amount of dynamic layers must be consistent across RR repetitions .

// A simple example for 2 dynamic layers with 2 RR repetitions.
Sampler.enableRoundRobin(false);

const var g1 = [1, 2, 3];
const var g2 = [4, 5, 6];

reg on = false;

function onNoteOn()
{
    // Calling this function tells the sample to just use
    // the first 3 tables for crossfading
    Sampler.setMultiGroupIndex(g1, on);
	Sampler.setMultiGroupIndex(g2, !on);
	
    on = !on;
}


setRRGroupVolume

Sets the volume of a particular group (use -1 for active group). Only works with disabled crossfade tables.

Sampler.setRRGroupVolume(int groupIndex, int gainInDecibels)



setSortByRRGroup

Enables a presorting of the sounds into RR groups. This might improve the performance at voice start if you have a lot of samples (> 20.000) in many RR groups.

Sampler.setSortByRRGroup(bool shouldSort)



setSoundProperty

Sets the property for the index within the selection.

Sampler.setSoundProperty(int soundIndex, int propertyIndex, var newValue)



setSoundPropertyForAllSamples

Sets the property for all samples of the sampler.

Sampler.setSoundPropertyForAllSamples(int propertyIndex, var newValue)



setSoundPropertyForSelection

Sets the property of the sampler sound for the selection.

Sampler.setSoundPropertyForSelection(int propertyIndex, var newValue)



setUseStaticMatrix

Disables dynamic resizing when a sample map is loaded.

Sampler.setUseStaticMatrix(bool shouldUseStaticMatrix)