Iteratively updating sample properties
-
@Orvillain Do other constants work?
-
They don't no.
Am I to assume then that this syntax is correct for the actual setting of the property?
sample.set(Sampler.HiKey, 36);
-
This post is deleted! -
@Orvillain said in Iteratively updating sample properties:
They don't no.
Am I to assume then that this syntax is correct for the actual setting of the property?
sample.set(Sampler.HiKey, 36);
Yes that's what I'm doing here - but I haven't tried changing the key number. Does changing the Pitch work for you?
-
@d-healey said in Iteratively updating sample properties:
@Orvillain said in Iteratively updating sample properties:
They don't no.
Am I to assume then that this syntax is correct for the actual setting of the property?
sample.set(Sampler.HiKey, 36);
Yes that's what I'm doing here - but I haven't tried changing the key number. Does changing the Pitch work for you?
Sorry, had to pop away. But here's what I've got:
for(sample in this_sampler.createSelection(".*")) { sample.set(Sampler.Pitch, 24); //sample.set(Sampler.LoKey, 60 + parseInt(pad_id)); //sample.set(Sampler.HiKey, 60 + parseInt(pad_id)); //sample.set(Sampler.Root, 60 + parseInt(pad_id)); }
But there is something interesting going on. Let me see if I can breakdown what is happening.
First... I load my plugin from init. All my samplers are empty.
I drag a sample to one of my pads, and it loads:
But when I select the sample in the editor, you can see that Pitch is still at 0ct.
I drag another sample onto the same pad (and thus same sampler) and I get this:
Notice my sample is not selected in the editor, but the pitch box does say 24ct, as I was expecting.
But... select the sample, and....
It resets back to 0ct.
So... it seems to me something isn't being applied correctly.
Again, here is my whole code:
Content.makeFrontInterface(600, 600); const var samplers = []; inline function load_sample(file_obj) { local pad_id = this.get("id").split("_")[2]; local this_sampler = samplers[pad_id]; this_sampler.clearSampleMap(); local abs_path = FileSystem.fromAbsolutePath(file_obj.fileName); local parsed = [this_sampler.parseSampleFile(abs_path)]; this_sampler.loadSampleMapFromJSON(parsed); // I think this is supposed to work. But it doesn't. for(sample in this_sampler.createSelection(".*")) { sample.set(Sampler.Pitch, 24); //sample.set(Sampler.LoKey, 60 + parseInt(pad_id)); //sample.set(Sampler.HiKey, 60 + parseInt(pad_id)); //sample.set(Sampler.Root, 60 + parseInt(pad_id)); } } for (i = 0; i <16; i++) { var current_pad_panel = Content.getComponent("pad_panel_" + i); var current_sampler = Synth.getSampler("Sampler" + i); samplers[i] = current_sampler; current_pad_panel.setFileDropCallback("Drop Only", "*.wav", load_sample); }
Syntax and standards aside, can you spot anything that would cause this kind of issue?
Here is the HISE snippet:
HiseSnippet 2708.3oc6c1ubabaD.+nkNWKFmLIo9O5ezNCFNcZnhcYHonHkpSmP8gUjRLsUEcbSGqTMP2AJhpiGt4NbRlMiadU5iPeD7iReDxaP6h6NxCjRTQhlzwLb4XKc36cWfE3GANaruuvhEDH7Mxrzy55wLxbWylccks2pMk6Zr21P7l1rVzPGowlc8nAALaiLYV3KUImYoEMh97iewlTGpqEKMJCimK3VrGy6vkowte8ul63rC0l8LdGsbWo9dVB2sDNhPPTVvrngG05T5IrmPUY6VlFYt8ir4RgeSIUxBLxr3lB6tMaKN2MN+OmGvO1goBTxnITQwQuivwVIwpXM1pM2wd+dpbfgQl6sepAXgXCv8Lavs48iO0P7gQIPRKgt8HysFT7VX.wqjt3UTS7tDQJilHsXrH8QlMs74dxzTTxy6Ytmqj42hBlccQINuF2528qL2R.4vUVnC8T1N9Pf9kHe0hEe.A9wxOLaVvzGHImQ8IAzNdNL+.xel7huCRg65vcYjVgtVRtvk3Hn1GEmo7s3NriDG+OVN62mcIGgE0g3AoxsgBKayCJbBSlOG2N2xEB7b3vyGka4WTFp1jbqxTRk4CkoWa+h3ZQkO8bTvxgQ8aFEnA0K+x8qG5wAG4Qksg5XGPlZ1MPx5TnkunyFGGHbBkr8gT6KuETOnFWkVCdTev3oT5AZwnniaQUEmuWCs7EjMkcounAV5NeUym9j7wUqpYxtzm8YIJHInsHzwlbLKxZBMKUFYJHdBtqLNuALYSQnqZjgGyW1cGg+FNNwsP.4bvGhPcbDmS5vHRAwpM08D3o1LhuPHItBIzoI7UYJp5RJH2kPUJqjaE5j1cWPkmMCkDtMCJQWxdehMwgeZTcKo9PGITTa9Yb6PvZkTaQkZ.qvUJ04qnFuQterwFFH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SCdS6evB0lr671ZH7FBugvayIvaqivaH7FBugvaH71z8cdaMM3s0Rg2VaxtyaqivaH7FBu8KS3se8E9O52hH8FRugzaH8FRuMceo2VWida8T5s0mHzauW++W5EueGP7MDeatAeCunFP7MDeCw2P7so6q8Vsho3avy8v2pUbBiug2xBH9FhuM2fugWyBH9Fhug3aH91z8EeqVIM7sRo3aklv3a38r.hug3ayM3a3Es.hug3aH9FhuMce02pUVCeqbJ9V4IL9FdSKf3aH91bC9FdUKf3aH9Fhug3aS228sZZW0B0RupEpsxDFeCuqEP7MDeatAeCurEP7MDeCw2P7so769l1ksPszKagZUlv3a3ss.hug3ayM3a30s.hug3aH9FhuMke22zttEpkdcKTa0qBe6sQWWGpku3HfJS5Kh5.uSTLf33FYcVxrgJLojwYTmvAH+5.q9djk0fU0EJX4wsfqLtErx3VvUG2BVcbKXswsfq8SWPEbzFgfOT7JFFFM1+QwdkYdTeuxEL9+TCVWXI
-
@Orvillain Ah I think I understand the problem now. I missed that this is meant to happen after you load a sample via drag/drop.
This is what is happening:
Load sample
Do the set sample stuff
Sometime later the sampler finishes loading the sample.You see HISE doesn't wait for the sample to load before the bit of code that you've written to change the sample properties. That code just fires right after you've told it to load the sample, but the sample is still loading at that point. You need to wait until the sample is loaded before trying to change its properties.
This is done using a panel and the loading callback: https://docs.hise.audio/scripting/scripting-api/scriptpanel/index.html#setloadingcallback
-
Ahhhhhhhh. Yes, that makes sense. I will read the API and try to implement this callback. My "pads" are panels already.
-
@Orvillain said in Iteratively updating sample properties:
My "pads" are panels already.
Btw, you can probably use a single panel for all your pads.
-
@d-healey said in Iteratively updating sample properties:
@Orvillain said in Iteratively updating sample properties:
My "pads" are panels already.
Btw, you can probably use a single panel for all your pads.
Thanks for the help on the setloadingcallback - I've got that working.
I guess my unfamiliarity with HISE is why I went with individual panels, but if you care to expand on how I might use a single panel, I'm all ears.
As it stands, I now have this:
Content.makeFrontInterface(600, 600); const var samplers = []; inline function load_sample(file_obj) { local pad_id = this.get("id").split("_")[2]; local this_sampler = samplers[pad_id]; this_sampler.clearSampleMap(); local abs_path = FileSystem.fromAbsolutePath(file_obj.fileName); local parsed = [this_sampler.parseSampleFile(abs_path)]; this_sampler.loadSampleMapFromJSON(parsed); } inline function set_sample_trigger_zones(isPreloading) { local pad_id = this.get("id").split("_")[2]; local this_sampler = samplers[pad_id]; if(!isPreloading) for(sample in this_sampler.createSelection(".*")) { sample.set(Sampler.LoKey, 60 + parseInt(pad_id)); sample.set(Sampler.HiKey, 60 + parseInt(pad_id)); sample.set(Sampler.Root, 60 + parseInt(pad_id)); } } inline function trigger_pad(event) { if (event.clicked) { local pad_id = this.get("id").split("_")[2]; local this_sampler = samplers[pad_id]; Synth.playNoteFromUI(1, 60 + parseInt(pad_id), 100); } } for (i = 0; i <16; i++) { var current_pad_panel = Content.getComponent("pad_panel_" + i); var current_sampler = Synth.getSampler("Sampler" + i); samplers[i] = current_sampler; current_pad_panel.setFileDropCallback("Drop Only", "*.wav", load_sample); current_pad_panel.setLoadingCallback(set_sample_trigger_zones); current_pad_panel.setMouseCallback(trigger_pad); }
And this basically gives me what I want. However, I suspect right now that my properties are being set 16 times, because the callback is triggered 16 times when I drop a wav file onto a panel.
-
@Orvillain said in Iteratively updating sample properties:
I guess my unfamiliarity with HISE is why I went with individual panels, but if you care to expand on how I might use a single panel, I'm all ears.
This should get you started
HiseSnippet 1334.3ocsW0uaaaCDmJMJnxaEaEXO.rAXExqtt1ooeflUz13jrErlVu3jrADTTvHQaQDYRCJ5XaLDf8O6OyKvdH1y1dC5tSTxRN1neXf4+H17te2w6adosVEvSRTZhi2QSFvINesamIRSTqHlPR1eGjv.ljGeTjP1ir8jArjDdHww4F+DhvwaUR5m+8EayhYx.dAIB4DkHf+ZQegofZ6W9Kh338Xg7iD8KgdyWtefR1REqFBVyMbaPFvBNm0i+FFBaEWhyZ6FJLJcGCyvS.LaqBmzIRMRZwehHQbVLGOzjzATjkLoUjHNrctmlPHNq1tvuug0u+N2CDghozK7+uMkA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