How do I play a sample/loop with from a different starting point

How do I play a sample/loop with a Halion 6 script from a different starting point(in ms/microseconds )? (playnote function)
in example with ksp(kontakt script): play_note(,,,)
where stands for playing sample from start from offset in microseconds


This is not possible in HALion. At least not the same way as in Kontakt. But there are couple of options.

You could map the same sample multiple times but with different sample start point. Then you can trigger the sample or layer with playNote.

Another option is to use sample start range. Assign it as modulation destination in modulation matrix and set the source to something you can change from the script. Maybe midi cc or note expression.

Having said that I hope this feature will make it to HALion 7, whenever it comes out.

Can you explain in more details on your second option?

Select the sample zone in program tree. Go to Sample tab and set up the Sample Start Range. Let’s say set it to 1 second. Select the Zone or Sound tab and go to modulation matrix. Select Sample>Sample Start as destination and set the amount to 100%. I would pick note expression as modulation source. Let’s say I choose Note Expression custom1. Then from the script I just change the note expression right after playing the note. The value for note expression is in range of 0 to 1 (float). You can use this value to choose anything between no offset and full range of sample start range. Dont forget to set the duration argument to true.

function onNote(e)
    local id = playNote(e.note, e.velocity)
    changeNoteExpression(id, 4, 1, false, true)

It doesn’t work for me

should i change something else?
i tried to start in the middle of the sample and nothing

In your screenshot you have the modulation amount set to 1. Set it to 100.

Then the script example above should play the sample from wherever you have set the sample start range.

THANKS four your help @misohoza, when you say is 1. set to 100 you talk about the “Modulation depth” settings where the bypass modulation icon? i set to 100 and still not working :frowning: ? do you mange to do that?


Did you set up the sample start range in the sample editor?

Couple of examples how you could change the sample start

Sample Offset Modwheel.vstpreset (8.8 KB)
Sample Offset Knob NE.vstpreset (8.8 KB)
Sample Offset Knob Custom Mod Source.vstpreset (8.8 KB)

Yeah it works :innocent: you are the best.
However it is so hack, and hard to calculate specific point to start from. i.e if I store the last time note played, then received immediately new note. And I want to continue play the sample from the last time end… I need to transform the time from milk seconds to percentage…hard to do math :weary:
I hope that offset will be in halion7