Solved Failing at HISE 101
-
I'm missing something fundamental here.
I globally allocated an array in my Interface Script Processor (i.e., deferred), but cannot access it in another Script Processor. However, if I globally allocate a "simpler" variable type in one Processor, I can access it.
Here, a "simple" constant is accessible.
I
But the array is not. (However, the exact same statement, in the other Processor, can access it.)
Bonus: I thought to use a reg type for the assignment, but that gave me this error:
Any thoughts? Cheers.
-
@clevername27 Use local, not var in the midi callbacks. Avoid global variables if you can. I'll take a proper look when I'm back at my computer.
-
@d-healey As always, thank you.
-
Works as expected here - but you should use a midi list instead of an array for this purpose.
HiseSnippet 5038.3oc68jsbiijbj8LZCSZuN7F934x8Sp2klhDfPhTiOV0TRsTL5ZIo5YZOQGc.ATjDcCBPC.piYh9Kx+Z9A+GXmUU39hf.PRTpkdPRn.prxqJqLyJQA7sVXMYr7mL0TlOGaUoR0u6BCcIrootQkp0Fc2bbkp+MaL7NMqo8mJpnU438qT8uciSEMsvFHVSu8t4hllX4JUq9cuizP0ZeeE5O+u+GuUTUTSB60TkJuWWQBehxLEKuVu3O+iJppGJJiGoLy2S24OerjtVecU8E.97cazpxbQouHNAelH4wd0FUp96NPVwR2XnknE1Ddl2pKe2vo52nwd92qXpbkJlbQ6JCA.wZtR+oJpxtzpIP4euOJ+6XT9+vFmpHq31tGG3uidCjWO7yCp9pzPo1q.J8Jenz2yPo+vFCkLTla4cGB97WuwwZf.YrHvp8iJrmsxq9GqtQec3IzrZNS7K3CMfKb6wla2pUCD7q27C0qOQU+JQUzjOcMVUWRw5Nz+F5W93OLdgljkhtFRW6LcK74Za9l5+V8ZdO1ubJfMffo4DrE4INawrqvFa9lOB822sdu8iuILVesNJLXGOlA2P2if6F5ppD.FysI5LFo0wM0nXSCz0hpKvtOHvTCJo9cYSRIwXk9dPcsi0TrNeN195C0UkIR.x+GUtVwVV.+2kGuunkHHpqZ2F7bywFVJDzo593qg4JLAesM1Ga9EK84vrkLpU72a2pmdZ63zNp9+rAJA4qxXzlJl6iGqngk2zSZ+l2TuVM.iM0UwMmann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SnQVasCjx1vYwsojJPoax1HiX6TS.fv7uM+k08WYE+fobRabLfr7dKet2dqUJWZeM4kegekUz9HSmNkJtxYNSdqPiU6X5Wv6a+G8LxccqDMHecAicK9IVEXlMt+JixLM32ukow1QpBhdamwhfvORl45zf+gUxYYujUIW6HkEaKT0ij.9I7.b7SFDqfHSSpfVBrG+gqmkXWJMPMsDHcLgKokvISIlJZIlzIDnhD7ahiKpaAb74wu.+8JcGC7sKDEw4.9UGNtl9iRxdI+J.2OQh089YfRKNMtZT2xWXi6Aegsd8dRtt1iPwD6eveBrtF2Z55Zbq2qqwsVttFWortl+kBBrvVLFPumWdiOKVC4ewZX1lSw+XZMj+of0P90Tqg7q2VC4WKsFx+bvZHmSAHWK4WHE6m3EyfoMYhiwoeLdcTbF46WCf74elrKFtNY8yGRcuX5qUIvuVeL64CkdBlYiuVuRkwJp3JUeE4OZhyf+8eZC1I75U5hFx.bmoq07ylUfP1s.3CO5FUpfmcEVVFKOTCeKDrM1rRkJ++Uqo7PA
-
@d-healey That you for looking further into this, and taking the time to write this code. But I'm not sure what to do with the information that it works for someone else, but doesn't work for me. (I was using a MIDI list - it's an array.) I tried to import the snippet you provided, but I get an error message. I don't understand where to go from here. There's another section of my plugin where a simple comparison operation doesn't work. I have no explanation for what might be going on, and there's nothing I can think of which might be wrong with my code. I'll try downloading a later build, and see if that does anything. I do appreciate your efforts.
-
@clevername27 said in Failing at HISE 101:
I tried to import the snippet you provided, but I get an error message.
Probably need to move to the latest develop branch for the snippet to load.
@clevername27 said in Failing at HISE 101:
I don't understand where to go from here.
Simplify. Make a new project. In the interface script add your global variable, in the on note callback set the velocity.
Add a second script, in it's note on callback read the velocity from the global variable.
-
@d-healey I'm confused (though appreciative) when you say not to use reg variables in the MIDI callback. The documentation reads:
-
@clevername27 When it says use reg instead of var for variables which are access in the MIDI callback - that's for variables you have declared in on init. For variables you declare in the on note callback you *can use reg, but as far as I'm aware there is no advantage over using local and since you only have 32 reg variables per namespace you should only use them when needed.
-
@clevername27 said in Failing at HISE 101:
I globally allocated an array in my Interface Script Processor
You should be doing this in a non-deferred script because you have no guarantee that this one's midi callbacks will trigger when the UI is closed or that they will trigger before the other scripts that are not deferred and are reading the values.
-
@d-healey There may be no advantage, but why am I getting an error message that I can't use them at all?
-
@d-healey I don't understand - are you saying I can't use global variables in MIDI callbacks?
-
@clevername27 said in Failing at HISE 101:
@d-healey There may be no advantage, but why am I getting an error message that I can't use them at all?
Ah looks like you can't use them there after all - I never tried. Use local and all will be well.
@clevername27 said in Failing at HISE 101:
are you saying I can't use global variables in MIDI callbacks?
Nope. I'm saying you can't depend on a value set in a deferred script's MIDI callback to be available in a non-deferred scripts MIDI callback when you want it to be.
You should use two non-deferred scripts. Separate the concerns, the UI script should only be used for UI stuff, anything not directly related to the UI should be in one or more separate MIDI processors and the UI script should connect to them as needed.
-
@d-healey Thank you - I may still be missing something. I did try with two non-deferred scripts.
-
@clevername27 said in Failing at HISE 101:
@d-healey Thank you - I may still be missing something. I did try with two non-deferred scripts.
We're talking about two separate things. Using two non-deferred scripts is good practice, but won't solve the issue you're having. There is something else wrong with your code but no way of knowing without seeing the whole project. So try the simple version I suggested and see if that works (it does for me) and then figure out from that what is different in your implementation in your main project.
-
@d-healey Thank you - I did try a simple test - I simply cannot access the global array from one script processor in another. I'll try downloading another build. Thank you again for your continued assistance.
-
@clevername27 said in Failing at HISE 101:
I'll try downloading another build.
Let me know how it goes in the latest develop branch, you should be able to load my snippet there.
-
@d-healey Thanks, man.
-
@d-healey Thank you again, Dave. I built with a newer dev branch, and it works. My immense gratitude.
-
-
-