Preset Select + Mute script (to avoid clicks)

  • Hi guys,

    So I tried to tinker with a script from @Natan which would mute my ShapeFX modules when changing presets (and thereby avoiding the clicks they produce when changing). I've showed it to @d-healey and he's described it as "crazy code" (a favourite term of his I think?!). Of course he's absolutely correct, but it was working so I left it. And now it's not working 😆

    It uses a timer function to mute the modules, but I'm out of my depth with timer functions and don't know where it needs improving. Apparently the timer will just run endlessly. If any of you geniuses would like to offer any help, I would be super appreciative! Code below (the code does work with my next / previous preset buttons weirdly):

    //////////////////////////////////  PRESETS  ///////////////////////////
    var on = true;
    const var PRESETNAME = Content.getComponent("PRESETNAME");
    inline function onPRESETKNOBControl(component, value)
    	if (Engine.getCurrentUserPresetName() == "")
    	    Content.getComponent("PRESETNAME").set("text", "CHOOSE PRESET");
    	    Content.getComponent("PRESETNAME").set("text", Engine.getCurrentUserPresetName());

    And the OnTimer function:

    function onTimer()
    		on = value;
    		on = true;

  • @DanH said in Preset Select + Mute script (to avoid clicks):

    he's described it as "crazy code"

    I stand by this definition...

    You have a variable called on which is set to true and then in the timer callback you set it to value, what is value?

    In the timer you check if on is true and if it is you start the timer, but the timer is already started!

    Then if on isn't true you stop the timer and set on to true which will restart the timer. So your timer is never stopped.

    Check this snippet to confirm (set on to true in on init and hit compile, the timer will run forever)

    HiseSnippet 738.3ocsU01SaCCD1tzLs1sNMj1OfH9TqDqJcCXSpZZL5KnnsVpH.ZeCYRbnVjXG43vVEh+T6W19GrcNtPBaADpR3ujd2yctO97ycdlT3SSSERDtwQKRnH7Ks7VvUyGLmv3H2gH7qrlPRUTosw0dKRHooz.DFu19ZG3F0Q4qe+48HQDtOsvEBchf4S+FKloJ7Na2uxhhFSBnGwhKE8V655K3CDQhLfOqY4fRH9WPNmNknCqlEB+rQALkP5oHJZJBWeOQvBu4hevMweBKkcVDUazC4Aajw8XQTflwZunAyYQAyt4bmhfcYVQUXMSU3MVSXAra8WTMdcNfcQFkqG3ZOD85UldNOd5gKQu5F5stkmujknJPzb6EVtb3hJj.WAkokIVTsegsFHfH3ptwjKnikfwsYzdGGmMs21woS+VMujHsEb6OYqjYTvtUybQQ2TEQpzWZx185zOLi6qXPbB9Tghd.ucmlW0rQyqaZ+uPggUhooiTDEA6WUvl+objVMsgEKztslWFh0w37JyG8JmyY7.ZHiSC5W.TE8MnWa9PiRoUucgD.phsRjrjd8KuOvIJUDQ6lHYbU6MNxcxnCsc8rO73oScmt+FPzUVBZyyhOiJ2z9RRDbxtoX.232URYc+RpxJdey8bo.EbWNScPBkeeBMzRwA7qicGRTDs1aoOHtDpTwzT.OjdIzTaThMrFRSu.JFPa8+ISglEQPVDQc2NH8Xik.PM3NRUsbjmxTKJOV4Ios5wR20slwT9yqlu0pfuPU6oluKGR0xZTXH0WUP15Vi+9S+DIzghLEie9DhRx9InImlE6Ayr8o.S3bnUB7gqoUTFaGsstx3Q4A4F+AVKA6oswKA6cCHJl3KEm5a5NziAedtGfS77WCZ.OKA118P4cLPdVNccPwvz4S880kh2Bbu5bd2Jjy6Wgb1ZExY6UHmcVgb9vJjyGevbzOL9kLkH1zl.NlMJeLBFOhS.UVthD8W.pv3ic

    Edit: I just realised I missed out a key part of the logic in my snippet. on will be set to undefined in the timer (assuming value in your script is undefined as it appears to be), so the timer will stop after a few cycles. I've updated the snippet now.

  • Can you post a minimal snippet that demonstrates the shapeFX = click issue?

  • @d-healey I'll have to post a project as you'll need presets...

  • @DanH No presets needed. I can make my own 🙂 just the simplest example that demonstrates the issue. Preferably with a sinewave generator rather than a sampler.

  • @d-healey Ok! Snippet below:

    HiseSnippet 2126.3oc6ZzzaabbcnjVWSZKm3fDzdbAQOPgnnPR8ISgAW8AoDgkHI3Jaohz7wpcGJN0K2gX2gzV1U.8RA5egbK.8dOVfdK+.5gTzyEH.8PQu4+AsuYlc4NKEEEKAriUQW.a348l279bdeLzM8o13f.pOJU5iunGFk59ZlW3w5raGKhGp1dnTOTy7fsaVo5o50LMeRE8UQ6bQOqf.rCJUp42musToW.I9dc4crbs7rwwfPnmRI13CIc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uy90kUb1ec61evT4rQn+uyNQ8zGDVOsEFrxmEVwWBRWBKYZlVTZWkY291u4a9Wk2CbNw9FiUW8eT9DL6PfZ2PX5+w8+qk2y+BUXnk9U+yxmnLgq3rp5iwuDqDB.P+yku0Zku6ve1JgIc+nJHQlccNjqcPfu6ub3Re2dXWqD08NIwqBf9kFiYTgZPiP9rlTWK+QqZN+ahRUStzNWkt8zJBuaRvjeaRfEgD2dD32WCF56c.w8sbxfIaRfJN2d7f+TMXV7h5hd10+wuo82FNx2F7nqksO8qrk+TF7br2U.AzaOw+CCRqcDes9vePGMs7qjm+bojux1lOXxm.1mwSSwYflUmAZVaFnY8YflMlAZ1bFnYqIRC+Ya3sY1UF+C.ZVQ7aljJk7kqDWEP+GXvDLvI

    I think that perhaps what is going on is that when I change preset HISE updates all the modules with their new settings, but gets to the UI knobs and buttons etc slightly later, thereby allowing the clicks through because the script hasn't got to the point where it mutes the ShapeFX etc.

  • So to recreate the issue all I need to do is save a few presets with different shapeFX settings and switch between them?

  • Yes, but make some super whacky shapes and crank the gain up - you should at least see the meters move when you change presets even if you don't hear the clicks. There's a lot going on in my project that's hard to replicate in a simple snippet to get exactly the same behaviour...

    Thanks for helping!

  • I'm not hearing or seeing an issue, the meters jump, but only up to the waveform generator, it doesn't pass through the the main container or HISE output because HISE auto mutes the instrument when you switch presets. I disabled all the scripting before I tried this btw because I didn't want it getting in the way.

  • @d-healey I think this is happening on the exported plugin, not in Hise.

  • @orange It happens in Hise too

  • @d-healey Ha, I thought that snippet might not do the sameas my project!

    I think perhaps my script needs to be a lot more efficient in order to speed it up. Quite often when changing presets the panel and knob changes lag behing eachother when changing state. I need to get better at Arrays for sure.

    Thanks for looking at it!

  • @DanH How many components do you have in your interface?

  • @ustk 60+ including tables, analysers etc etc..

  • @DanH That's not a particularly large amount of components so probably not the cause, but it's easy to test - make a backup and delete components one at a time and see if the problem goes away. I would suspect your script is causing the issue since I couldn't recreate it with the script disabled.

  • @DanH You got some controls but nothing that should add lag to the interface... I got lag in the past with 700+ components. If something is not going as expected it's definitely about the code (or when a slider sets 10 modules at the same time for instance...)

  • @ustk I've no doubt the code can be better - it's the first one I've ever made! There's a lot of repetition. I was hoping to group some things into arrays but not having much luck - Can you put components into arrays?

    For example I have a button which switches on/off several panels and modules. At the moment the callback is one long list of about 15 lines, for eg:

    analyser1.setBypassed(1- value);
    etc x 15

    Can I get the list of components / modules into two different arrays and do for example:

    allanalysers = [analyser1,2,3 etc];

    and then in the callback:

    allanalysers[i].setBypassed(1- value);


  • @ustk checked this out recently but will go through it again!!

  • @DanH Make sure your code follows these guidelines and it will go a long way to cleaning things up -

Log in to reply