How to smooth a path + Ducking Display Script
-
I am interested in drawing a path of ducking from a limiter or compressor (for example). I am curious how I can smooth the path being drawn? I know I can add some smoothing within my scriptnode chain to get similar results, but in this particular case it comes with the drawback of loosing the information of the attacks. I was wondering if I could somehow use the
Path.toQuadratic
here in order to smooth the graphics being drawn but I can't figure out how to accomplish this. Any ideas?Content.makeFrontInterface(500, 300); const var pnl_DuckingDisplay2 = Content.getComponent("pnl_DuckingDisplay2"); const var knb_PostDuck2 = Content.getComponent("knb_PostDuck2"); const var BUFFER_DUCK = Synth.getDisplayBufferSource("Limiter"); const var BUF_DUCKING = BUFFER_DUCK.getDisplayBuffer(1); const var duckingTimer = Engine.createTimerObject(); namespace DuckingAnimation { inline function DuckPaintRoutine(g, panel) { local a = panel.getLocalBounds(0.0); local h = this.getHeight(); local p = BUF_DUCKING.createPath(a, [0, 1, 0, 0], 0.0); local duckScale = Math.max(knb_PostDuck2.getValue() / 101.0, 0.01); // Invert the path vertically and scale by duck p.scaleToFit(a[0], h , a[2], -h, false); // Fill g.fillAll(panel.get("bgColour")); g.setColour(Colours.white); g.drawPath(p, p.getBounds(1.0), {"Thickness": 2.0}); }; // Paint Routine pnl_DuckingDisplay2.setPaintRoutine(function(g) { DuckPaintRoutine(g, this); }); // Timer Callback duckingTimer.setTimerCallback(function() { pnl_DuckingDisplay2.repaint(); }); duckingTimer.startTimer(30); }
HiseSnippet 3519.3oc6azzbaabETRKkEschsiSSmo8.FM8.UqBC.HkHUS6XRIQFqHIKFQEk3ISGMffKIgEH.C.nDYx3oo25ul9av+.Z+OzicldoG5kdx8se.BrjfRTzxpwoByXYhce668122ukKq55Xf87bbkRj5nAcwRItGp1.a+1a0V2zVZmskRbWz18LNshYermzlC5p64gaHkHw7eFAfDKsfD84e8jM0szsMvgCIIcrioAdOyNl9giVs3tlVVUzafOxrSDnyUbGCG6sbrb5ALy7HEot5Fmp2B+LcBXygjdptWaoD+Zz5FarlRcrxZqUHW1B4xsdt0WSooR1l0Krdt5YymKaibq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XgKegjNH4e8jDOLns5pkoeiJIRDbKQ.mMo+6kKGOU
-
@HISEnberg
Path.roundCorners(var radius)
is your friend
Please notice that this doesn't round the actual path but returns a new oneso:
roundedPath = rawPath.roundCorners(10.0); g.drawPath(roundedPath, etc...)
-
@ustk Ahhh thank you I had tried that but failed to notice it requires a new path!
-
@ustk Have I missed something? I am just getting errors trying to use the roundCorners.
// Invert the path vertically and scale by duck p.scaleToFit(a[0], h , a[2], -h, false); local roundedPath = p.roundCorners(10.0); // Fill g.fillAll(panel.get("bgColour")); g.setColour(Colours.white); g.drawPath(roundedPath, p.getBounds(1.0), {"Thickness": 2.0});
-
@HISEnberg not as far as I can see
exceptp.getBounds(1.0)
that should useroundedPath
but this shouldn't lead to an error... -
@HISEnberg So it appear there's no need to create another path... I don't where I get that, I was sure it was the case when I implemented it, it's even written in the description...
But there's something that you can't round. There are too many points, so the rounding will happen at the pixel size. you need more space between the points so the curve can smooth out freely
-
@HISEnberg did this and got rounding:
pnl_DuckingDisplay2.setPaintRoutine(function(g) { var h = this.getHeight(); // path is restrained to a width of 60 so it is created with less points (rescaled later) var p = BUF_DUCKING.createPath([220,0,60,200], [0, 1, 0, 0], 0.0); // Invert the path vertically and scale by duck p.scaleToFit(0, h, this.getWidth(), -h, false); g.fillAll(this.get("bgColour")); g.setColour(0xFFFFAE00); g.drawPath(p, p.getBounds(1.0), {"Thickness": 0.5}); g.setColour(0xFF00ff00); p.roundCorners(100.0); // set to 100 so it rounds up to the next point, which is way closer. so 100 is just a limit we never reach here g.drawPath(p, p.getBounds(1.0), {"Thickness": 0.5}); });
-
I don't want to interrupt your Path manipulation party, but I think that should be solved on the DSP side.
I know I can add some smoothing within my scriptnode chain to get similar results, but in this particular case it comes with the drawback of loosing the information of the attacks.
If that's your only problem, use an envelope follower with a short attack time instead of a smoother (an envelope follower is basically the same but with two different times for upwards and downwards smoothing).
-
@Christoph-Hart thank you the envelope follower should be a better solution!
@ustk thanks for taking the time to script these!
Thank you guys these are both great suggestions!
Christoph I am actually seeing that the envelope follower is producing more noise in the signal than the peak node. Here is an example of one arpeggiated sine wave gating another sine wave:
HiseSnippet 2669.3oc6Zs0aaibElx1iSrxlqa5Ef1GHL1Gj65pna9VWTDIYIkn0V1ZEcb2EAEFiHGIwHpgLjT1VaPPQequ0m2GVf92nu0e.6BzG5Oi9v9On8LyPJRJQaKqboMKVBjHwybly4aNyYNWF4l1lpDGGSaoDIOZjEQJwGgTFQc6saOrNUpdEoD2BUYnZ+Z5mSbjJOxB63PzjRjXwmvXHwJKIwe9gGWFafopj.RRRGapqR1Wefta.0lE2S2vnFVibj9fPbWnXcUS5tlFlCAvrHJijEVsOtK4.LisEPROE6zSJwuAso5NajoMIyFarcg7aWnvlE1biLcxjuS6s2rP67aUHuVgMxplWJwxU0zcMsUbwt.3SrTYSsQJ8LOiJTvw5N5sMHrWxJo.ZVPtlogFaIxnJsaOcCsl9VIGIPnMCrYKJrYOD0PWSeL8.a283CHGLivFvDKDEdKFAdYCCuLgfWLPJQHHsj.R2GonZqa4FLhXurN0kX2AC6SgghfWoE9VDRdWSfEpa5A39jZ1vKimRpMxjYc47Yxr1mkTNoLrc43JeJ1V1hZbByIQm1shtikAdTN4e+XA0k3tq4.KSJ7RpUig2UYxKPZ8osOoooiKiqKVNQ3ZBIT9Y0pUs0IUd1t6Aym6Oylsm9JOrSGhsB3mAKoU4tmD6ok.e50O3IfDBIuojSprQmolXswbtsgoVk1UmRRqZSfMYNwCa+BhpaJgMjBN2NfiNQ1ylThpO.6paRSJ+pjxrGcpAHA4NCopL5bFaBNXtsLG5Bijp65xVXJwXMA+dSi8XXphMjw.L3Lvv99LRkMGR0bRkIMemLJ28.tc6o6vX9oD8t8DPMJSVBihuIxa40D61KEdc4mCdIYWWF9+L+Q3ewoElURA9BADTCXZf214ohrkxz+wXigjTqI+H4rYxlNCWVYEFN+mG8H45zSI1t.nIvxzsmL6McP1FijwTMYGtZZOhqyfIZklOvQl0zcSgeNCo8jkWWF+7bvW+s8VWtC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