HISE Docs

Sample

Functions for doing something with a single samples selected from a Sampler. You can get and filter the array of samples from the sampler with one of these functions:

const var Sampler1 = Synth.getChildSynth("Sampler1"); // Script reference to Sampler module

const var sampler_obj = Sampler1.asSampler(); // Sampler object

const var sample = sampler_obj.createSelection("foley").pop(); // single sample from regex array

Console.print(sample.get(sample.FileName));


Class methods

deleteSample

Deletes the sample from the Sampler (not just this reference!). Edit on GitHub

Sample.deleteSample()



duplicateSample

Duplicates the sample. Edit on GitHub

Sample.duplicateSample()



get

Returns the sample property.

Sample.get(int propertyIndex)


Attribute Name Description
FileName The file name
Root The root note
HiKey The highest mapped key
LoKey The lowest mapped key
LoVel The lowest mapped velocity
HiVel The highest mapped velocity
RRGroup The group index for round robin / random group start behaviour
Volume The gain in decibels.
Pan The stereo balance (-100 = left, 100 = right)
Normalized Enables / disables Autogain to 0dB for all samples.
Pitch The pitch factor in cents (+- 100). This is for fine tuning, for anything else, use RootNote.
SampleStart The start of the sample.
SampleEnd The end sample
SampleStartMod The amount of samples that the sample start can be modulated.
LoopStart The loop start in samples. This is independent from the sample start / end (so 0 is the SampleStart value and not the beginning of the file , but it checks the bounds.
LoopEnd The loop end in samples. This is independent from the sample start / end, but it checks the bounds.
LoopXFade The loop crossfade at the end of the loop (using a recalculated buffer)
LoopEnabled True if the sample should be looped.
ReleaseStart The release start value. A value of 0 disables the feature.
LowerVelocityXFade The length of the lower velocity crossfade (0 if there is no crossfade).
UpperVelocityXFade The length of the upper velocity crossfade (0 if there is no crossfade).
SampleState This property allows to set the state of samples between Normal(0) and Purged (1)
Reversed Whether the sample is reversed.

Example to print the SamplEnd of all samples:

const selection = Synth.getChildSynth("Sampler1").asSampler().createSelection(".")` //Array of `Sample` objects.
for (sample in selection){
  Console.print(sample.get(Sampler.SamplEnd));
}

Note that attribute names belong to the Sampler class, not Sample

trace() does not work on Sample objects. Use the Script Watch Table to peek inside.

getCustomProperties

Returns an object that can hold additional properties. Edit on GitHub

Sample.getCustomProperties()



getId

Returns the ID of the property (use this with the setFromJSONMethod). Edit on GitHub

Sample.getId(int id)



getRange

Returns the value range that the given property can have (eg. the loop end might not go beyond the sample end. Edit on GitHub

Sample.getRange(int propertyIndex)



loadIntoBufferArray

Loads the sample into a array of buffers for analysis. Edit on GitHub

Sample.loadIntoBufferArray()



refersToSameSample

Checks if the otherSample object refers to the same sample as this. Edit on GitHub

Sample.refersToSameSample(var otherSample)



replaceAudioFile

Writes the content of the audio data (array of buffers) into the audio file. This is undoable!. Edit on GitHub

Sample.replaceAudioFile(var audioData)



set

Sets the sample property. Edit on GitHub

Sample.set(int propertyIndex, var newValue)



setFromJSON

Sets the properties from a JSON object. Edit on GitHub

Sample.setFromJSON(var object)