Recall previous parameter value
-
Hi all,
I am a new Hise user for a few weeks.
here's my first (beginner) questionI made a panel responding to mouse dragging for setting a parameter (Q in the EQ)
my interface requires a panel, not a knob (which would have been easier...)everything is working great, except that I don't understand how to recall the last setting.
currently, each time you set the parameter, it begins again from 1 (which is the middle/default value)I know it should be easy and has something to do with storing the last value for reference, but I just don't understand how to handle it...
Any help much appreciated!
Thanks a lot, guys!reg Q = 1; // initialise Q to middle position reg Qlabel = ""; // var for Q label display Panel2.setMouseCallback(function(event){ // Q setting if (event.dragY && event.altDown){ // If mouse in a 200 Y frame if (event.dragY >= -100 && envent.dragY <= 100){ // ----------Ratio-------------- ----------Log scale for the 200 frame-------------- Q = ((8 - 0.1) / Math.log10(200)) * (Math.log10(200) - (Math.log10(event.dragY + 100))); }; // Limits if (event.dragY < -100 || Q > 8){ Q = 8; }; if (event.dragY > 100 || Q < 0.1){ Q = 0.1; }; // Set EQ ParametriqEQ1.setAttribute(2, Q); // Dispaly the rounded Q value Qlabel = Engine.doubleToString(Q, 1); Label1.set("text", Qlabel); } // On release, display no text if (event.mouseUp){ Label1.set("text", ""); } });
-
You need to enable the SaveInPreset button for the panel.
Why can't you use a knob for this btw?
-
Hi
Thanks!But it doesn't work... My code makes the value always beginning at one when dragging up or down...
I can't use a knob because the panel is also draggable in the whole project, and as far as I knoob (triple play word haha), a knob doesn't allow mouse callbacks and/or dragging...?
This is why I try to handle everything within the script
-
@ustk A knob only responds to mouse callbacks, dragging, and double click. You handle it in either the
on control
callback or by using the.setControlCallback()
of the knob and passing a custom inline function. -
Maybe my explanation wasn't accurate, I need to drag the panel accross the interface (not just allow dragging onto it)
I tried with a knob with no success. Of course the knob responds to mouse drag, but can't move accross the interface.
My panel will just be a dot of 4/6 pixel in the end, draggable in the interface and responding to keyboard event (at this moment it stops the panel dragging and change the Q)
so no possibility to embed a knob inside either.
Everything seems to work fine except the value is not memorizedSorry for my bad english
-
@ustk I think I understand now, so you are trying to make it seem like an interactive EQ display. I'm not 100% sure what the problem is, can you make a small demonstration project and post it as a HISE snippet so that I can test?
-
Yes it is exactly that, but as I am currently rewriting everything (my code is working be so badly done)
I previously tried with the allowDragging property, but it seems not possible to stop the dragging "on the fly" (I would have prefered as the inbuilt dragging is much smoother than my method)here's the snippet just for the Q thing
HiseSnippet 1696.3ocwX0sSabDEdVfMJ1sHkD0KZ6USckRsarAamPJpjeHXLoVEB1XRJHUojw6N1dTFOiytig3lvM8IoW2a6iPusuC8Unu.somY1c8tFL1PkR5hDZ2YNm4722b9w08jNTeeoGxJ09C6SQVercygBU2JcILAp1lHqaXqn9JrqGoSGlnCtZCzFC6S78otHKq4erlNqTKfLO+0C2fvIBGZ7RHzyjLG51rdLU7p0W+6Yb9VDW59rdIn9NqWyQJpH4xAfNMucQTehyKIcnOgnIaNaj0Up5xTRulJBnXHqE1P5NrYW4wh.5eFym0hS0eTB0DNnfk2Rxc0ZrdUTktLta8Ha2GAmR8XOw7AdhOwdGlKaz5wdjqY1.GyQR+g0bSS8JkT8JdwUOqDp2BAp20sa53w5qh2QqaejcMgh50l.gfjpU.sn49yqZWQBTHTK0i7R5VdvGi3H6cKVLOdkhEys1hoWLMDHf.+QDObchG39UdrWUsQI78wFHxRcnppsaScTYyDS.fOJk4r7KnbMiQxFXshrWeo.9PysdaCWw7rMo0z3IX6PI4Q6f6K8O.nN3rzD+XtrEgWW5yTLo3frZRCI7voP3g.ggGYCfrRqgG8r7xXl.HhvY9TXWkD2i45xo5yzvbHebsxALmIyZg7osn1ROfof8bY984jgZkOTQ7opcjC7oUHbdK.yms8.gi9LyROBr3buYwz5yJ3+vItYzExiYptXeS7MOtE0g.GBtFHAWwWovsYBWLAeLYnVcAwR.zGFjg73QmPeOYepmZHVJvptTba9PiTXswABeI8se7MuI9KB9zQ4w2DfzQJ0GDUJVTwdrnfVVSz+V3Xs8f7wzOgGCHHI8GNc5KUbV6qgWSgf3MCPtyP6wEv2dkKqIfKTdF7r5LLixq.fe8KmrVR31HPWCLn1JH.s3D.HGpQH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WvXe455EJE4R+ze6mMKTNbgeg+G+yC0Kb6w+wJDt2Idgqst07ia5yewL8I342SNPeaB5wyioyj.FPSHejCEb7B3RnwNlSmSH36h5u0JQSpwtrsdG7DtYoHiVuYonM+fHidDGO4ycBJuoiiW0rBX2ByuHSJ6czeiKEUWS6OfohYO2wQisJ.3xIyQ4KMG29Rywctzbrxkli6do43atzbr5T3P+iQ8nAJYufLMvB0qZpwaYUUnKHXR5f9W.OfbP0A
-
I think something like this is close to what you need. It stores the previous Y value and uses it in the next calculation. I tidied the code a little too.
HiseSnippet 1677.3ocwX0saaaCElJIpn1aAncXWrsq37.5rWsSjca5BVvvbiiSWvRZrqSaStpkVh1lnzjNRzI0qnX.6IXWuK2qPew1aP2gTRVRItNwCXcJ.Ah7bN57C+34G2xW5RCBj9HqbGMYDEY8o1clHTCZLfvDn81AY8Y1JZfB64S52mI5ia1Fs8jQjf.pGxxZ4Go4yJ2JHyye+SaS3DgKMYKD5YRlKce1PlJY2V0+EFmuKwidDaXJtue88bkhFRtbLXSKa6fFQbeEoO8wDMaKYirtQSOlR52QQ.CCYsx1RuIcFHOWDx+yXArtbpdQUTG3CEt8tRtm1h06hZLfw8ZE66AH3qzJIRrbXj3ysOf4wlteRD4VFB3DIRGOrVZdlW0+klmUJyakPy611cb8YiTITz11mXumPQ86QfifzlUHunk9iaZ2PBbHTqMj7J5t9vhoRT7ANNkwa33TZqUyuZd3f.N3Oi3iaQ7gvuxmcZy1Uw+H1.QVqOU0rWOpqpXgDF.7Q0BWVdAkqELV2fnMjCGIEvBszZxFoRjYeR24ISH4HM4S6iGICNF3N7aoY9QbYWBukLfoXRwwE0rFw3IygwS.Fi9jsA1ptEd5y5qiYBfIBmEPApJIdHyyiS0eSivQxw0FGHbgBaEIm1i5I8AgBo4wBFwISzFejg3QTj03j.k13b1JEk.p5.43.ZCBm2EtMTr2XgqVaEomAwhRuY07ZsD9ePW6DeU8blZ.NvbxWF2k5RfOBdOP2dhuUg6wDdXB9bxDsi.FD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KFZb4aXyo8Tnd.tqC6WSMklSczkGHAFKR5MlSTYmUROfXDAHcPlgRzCdHfrZSRO.4BL.ky0d.pqq4da6VLk6fYauKMC6EtW9es8FMN5p1gCakXrqXu6wejm8LWbllFi8Oi17zny3ri+kwld73g6x3v.l5T6VVfqsMfichhfujw9l55MpFGR+h286lMpkDiwlMtW1ekAg28S13V0sVNqqu70y0mQj+Ixw5aUP2T9LcFEvA5.4kboPfW.WFM9wR5bCgqczq0FQGpwursdO7DQrZrSqIVMl3GEcLj35KegaXYN843MM6.9sv7Sojy9.8Zb035a53ALNK6EttZrUE.LLaIpsvRbuEVh6uvRrwBKwCVXI99EVhMmiD5eEoGNVIGFloA1nUSSsdKqlBcgASRGz+fBzeCr
-
Marvellous it's exactly what I needed!
Tomorrow I'll tweak it a bit, because somewhere, the movement is shorter/less precise, but that shouldn't be hard to find I guessThanks!
-
Ok so I just checked, and now there's the same problem I had when trying to use the last value
when you're dragging in the upper part, the value is increasing. But when you go down, it's increasing as well instead of decreasing. Then when you pass the middle (dragging in the lower part) everything is back to normal.
this is due by the fact we're adding the last value to the Y offset, which is always positive in the top, and negative in the bottom part.
What we need I think (not sure though) is the information of the mouse going up or down. I worked on that these last days but couldn't figure out this behavior.
-
Check out all properties of the event callback by typing
event.
and press escape. You‘ll find event.clicked and event.mouseUp. -
Hi Christoph thank you for replying
I am already using these events and it's working fine, the problem I have is either the last value is not stored, or if stored the behaviour is strange