How to get around max start offset is 65536?
-
@Christoph-Hart said in How to get around max start offset is 65536?:
Can you use the modulator?
That might work, I will test and report back, thanks.
-
@Christoph-Hart I don't think it will work in this situation. I'm porting over a Kontakt instrument -
In Kontakt this instrument uses the timemachine legato mode. So sample A plays, and then when you play sample B it starts playback from the current position of sample A.
If all the samples were the same length then I think the modulator would work, but in this case they are not so, for example, I don't know what 2000ms into sample A translates to as 0 - 1 of sample B.
Or perhaps there is a method I'm not seeing.
-
@d-healey Can you use getSampleLength() to calculate the 0-1 value?
Something like:var totalSamples = currentSample.getSampleLength(); var offsetSamples = (offsetMs * sampleRate) / 1000; var normalizedOffset = offsetSamples / totalSamples;
And then use the normalizedOffset value for your modulator?
-
@Dan-Korneff how are you getting current sample?
-
@d-healey I added a function to my fork to get sample length based on note/velocity in the map, I've found it very useful.
-
@d-healey fair point. Could a method help that just multiplies the start offset for the sampler in question? This way you would loose a bit of precision but can yank the offset range into the dimension you need.
So if you need to start the sample at
100.000
offset which is beyond 65k, then you'll use// Internally multiply the offsets by this amount Sampler.setOffsetMultiplier(2); // Later local realOffset = 100000; Message.setStartOffset(realOffset / 2); // 50k < 65k => all good
it won't be 100% sample accurate anymore, but below a multiplication factor of
8
this shouldn't have any real world consequences. -
@Christoph-Hart that might work, am I able to change it dynamically in on note on?
-
@d-healey yes but don鈥榯 rely on the calls being always in order, if multiple notes are played in one buffer then it will use the latest value for the multiplier for all notes within that buffer.
-
@Christoph-Hart Sounds promising, let's give it a try
-
@Simon said in How to get around max start offset is 65536?:
I added a function to my fork to get sample length based on note/velocity in the map, I've found it very useful.
There's actually a built in way to do this.
Although I'm not sure if it's usable for realtime... but maybe I could "cache" this info during init and retrieve it in the on note on callback perhaps... something for me to play with
const var Sampler1 = Synth.getSampler("Sampler1"); const list = Sampler1.createSelectionWithFilter(function() { return this.get(Sampler.Root) == 72 && this.get(Sampler.HiVel) > 20 && this.get(Sampler.RRGroup) == 1; }); Console.print(list[0].get(Sampler.SampleEnd));
-
let's give it a try
You're chances of this not interrupting your workflow will rise by 100% if you try to implement this yourself and hit me with a sweet pull request. My local branch is heads deep into the rewrite for the new group management system and the implementation should be pretty easy:
All you need to do is to add the API method to the Sampler class and create a function in the
ModulatorSampler::setStartOffsetMultiplier()
class that stores the multiplier (ideally as an integer).Then in the voice start code, you need to modify this line here:
HISE/hi_core/hi_sampler/sampler/ModulatorSampler.cpp at 961d7d903632982c4c315062271cf1318cee278b 路 christophhart/HISE
The open source framework for sample based instruments - HISE/hi_core/hi_sampler/sampler/ModulatorSampler.cpp at 961d7d903632982c4c315062271cf1318cee278b 路 christophhart/HISE
GitHub (github.com)
to include the multiplication with the factor.
-
@Christoph-Hart Thank you
-