From e784f0c66e5c1e8ee26741987135687ca8a8a7df Mon Sep 17 00:00:00 2001 From: TiagoLr Date: Sun, 24 Dec 2023 10:54:12 +0000 Subject: [PATCH] Release SKFilter v1.0 (#354) --- Filter/tilr_SKFilter.jsfx | 194 + .../skf.Saike_Yutani_Filters.jsfx-inc | 3320 +++++++++++++++++ .../skf.Saike_Yutani_oversampling.jsfx-inc | 228 ++ .../tilr_SKFilter/skf.Saike_Yutani_upsamplers | 1838 +++++++++ 4 files changed, 5580 insertions(+) create mode 100644 Filter/tilr_SKFilter.jsfx create mode 100644 Filter/tilr_SKFilter/skf.Saike_Yutani_Filters.jsfx-inc create mode 100644 Filter/tilr_SKFilter/skf.Saike_Yutani_oversampling.jsfx-inc create mode 100644 Filter/tilr_SKFilter/skf.Saike_Yutani_upsamplers diff --git a/Filter/tilr_SKFilter.jsfx b/Filter/tilr_SKFilter.jsfx new file mode 100644 index 0000000..b56fe32 --- /dev/null +++ b/Filter/tilr_SKFilter.jsfx @@ -0,0 +1,194 @@ +desc: SKFilter +author: tilr +version: 1.0 +provides: + tilr_SKFilter/skf.Saike_Yutani_Filters.jsfx-inc + tilr_SKFilter/skf.Saike_Yutani_oversampling.jsfx-inc + tilr_SKFilter/skf.Saike_Yutani_upsamplers +about: + # SKFilter + SKFilter (or Saikes filters) is a set of unique filters extracted from [Yutani Bass](https://github.com/JoepVanlier/JSFX/tree/master/Yutani) + + #### Features + * 29 filter types + * Non-linear analog modelled filters + * Filter drive + * Filter modes and morphing + * Oversampling up to 8x + +desc:SKFilter + +slider1:filter_type=1<0,28,1{Linear,MS-20,Linear x2,Moog,Ladder,303,MS-20 asym,DblRes,DualPeak,TriplePeak,svf nl 2p,svf nl 4p,svf nl 2p inc,svf nl 4p inc,rectified resonance,Steiner,SteinerA,Muck,Pill2p,Pill4p,Pill2p Aggro,Pill4p Aggro,Pill2p Stacc,Pill4p Stacc,Ladder3,Ladder6,HLadder,SVF2,SVF4}>Filter type +slider2:drive=0<0,48,1>Filter Drive (dB) +slider3:boost=0<-6,48,1>Post Boost (dB) +slider4:cutoff=.6<0,1,.0001>Cutoff +slider5:resonance=0.7<0,1,.0001>Resonance +slider6:filter_mode=0<0,3,1{Low Pass,Band Pass,High Pass,Band Reject}>Filter Mode +slider7:morph=0<0,1,.0001>Morph + +slider10:_oversampling=0<0,7,1{Off,2x,3x,4x,5x,6x,7x,8x}>Oversampling + +import skf.Saike_Yutani_Filters.jsfx-inc +import skf.Saike_Yutani_oversampling.jsfx-inc +import skf.Saike_Yutani_upsamplers.jsfx-inc + +@init +freemem = 0; +lfilter_mode = filter_mode; +lmorph = morph; + +/* Oversampling memory */ +freemem = (sinc_hist1 = freemem) + 10000; +freemem = (sinc_hist2 = freemem) + 10000; +freemem = (sinc_flt = freemem) + 10000; +freemem = (sinc_flt2 = freemem) + 10000; +freemem = (sinc_flt3 = freemem) + 10000; +freemem = (sinc_flt4 = freemem) + 10000; +freemem = (sinc_tmp = freemem) + 10000; + +freemem = (l_buffer = freemem) + 2001; +freemem = (r_buffer = freemem) + 2001; + +freemem = (l_pdc_buffer = freemem) + 2001; +freemem = (r_pdc_buffer = freemem) + 2001; + +log10d20_conversion = .11512925464970228420089957273422; + +function rc_set(rc) + instance(a) ( + a = 1 / (rc * srate + 1); +); +function rc_lp(sample) + instance(lp, a) ( + lp += a * (sample - lp); +); +function smooth() + instance (lp, smooth) ( + lp = smooth; + smooth = this.rc_lp(this); +); + +cutoff.rc_set(0.0033); +cutoff.smooth = cutoff; +resonance.rc_set(0.0033); +resonance.smooth = resonance; +drive.rc_set(0.0033); +drive.smooth = drive; +boost.rc_set(0.0033); +boost.smooth = boost; + +@slider +oversampling = _oversampling + 1; +sampling_ratio = 44100 / srate; +sampling_factor = oversampling / sampling_ratio; +isampling_factor = 1 / sampling_factor; +israte = 1.0 / srate; +israte_radian = 2.0*$pi*israte; +current_safety_moog = (1.0 - log(safety_limit_moog * oversampling) / log(20/22050)); + +// change morph based on filter_mode +lfilter_mode != filter_mode ? ( + morph = filter_mode / 4; + lmorph = morph; + lfilter_mode = filter_mode; +); + +// change filter_mode based on morph +lmorph != morph ? ( + filter_mode = floor(morph * 4); + lfilter_mode = filter_mode; + lmorph = morph; +); + +//check_safety(); + +@sample + +spl0 || spl1 ? ( +cutoff.smooth(); +resonance.smooth(); +drive.smooth(); +boost.smooth(); + +filter.init_filter(filter_type, cutoff.smooth, cutoff.smooth, morph, morph, resonance.smooth); + +current_drive = clamp(drive.smooth, -32, 48); +current_boost = clamp(boost.smooth, -6, 48); +preamp = exp(log10d20_conversion*current_drive); +inv_preamp = exp(-log10d20_conversion*current_drive); +final_boost = exp(log10d20_conversion*current_boost); + +oversampling > 1 ? ( + upsampleL.updateUpHist(oversampling, spl0); + upsampleR.updateUpHist(oversampling, spl1); + + f = 0; + loop(oversampling, + f += 1; + ssl = oversampling*upsampleL.upSample(oversampling); + ssr = oversampling*upsampleR.upSample(oversampling); + + filter.processSample(filter_type); + ssl *= inv_preamp; + ssr *= inv_preamp; + + downL.updateDownHist(oversampling, ssl); + downR.updateDownHist(oversampling, ssr); + + ( f == 1 ) ? ( + spl0 = downL.downSample(oversampling); + spl1 = downR.downSample(oversampling); + ); + ); +) : ( + ssl = spl0 * preamp; + ssr = spl1 * preamp; + + filter.processSample(filter_type); + ssl *= inv_preamp; + ssr *= inv_preamp; + + spl0 = ssl; + spl1 = ssr; +); + +spl0 *= final_boost; +spl1 *= final_boost; +); + +@gfx 450 50 + +gfx_set(1,1,0); +gfx_x = 5; +gfx_y = 5; + +filter_type == 0 ? gfx_drawstr("2-pole linear state variable filter (12 dB/oct).") +: filter_type == 1 ? gfx_drawstr("MS-20 emulation (12 dB/oct LP, BP, 6 dB/oct HP).") +: filter_type == 2 ? gfx_drawstr("4-pole linear state variable filter (12 dB/oct)") +: filter_type == 3 ? gfx_drawstr("Moog emulation (24 dB/oct).") +: filter_type == 4 ? gfx_drawstr("Ladder filter with two stages (12 dB/oct).") +: filter_type == 5 ? gfx_drawstr("Blaukraut's 303 filter emulation") +: filter_type == 6 ? gfx_drawstr("MS-20 emulation with diode asymmetry\n(12 dB/oct LP, BP, 6 dB/oct HP).") +: filter_type == 7 ? gfx_drawstr("DblRes") +: filter_type == 8 ? gfx_drawstr("2 2-pole state variable filters in series\nwhere one is placed at four times the cutoff.\nResonance peak is saturated (approximate).") +: filter_type == 9 ? gfx_drawstr("3 2-pole state variable filters in series.\nCutoff frequencies are at one, two and four times\nthe base cutoff.\nResonance peak is saturated (approximate).") +: filter_type == 10 ? gfx_drawstr("2-pole non-linear state variable filter (12 dB/oct)\nwith asymmetry in the saturation which leads\nto flutter when driven.\nSounds nice at low resonances.") +: filter_type == 11 ? gfx_drawstr("4-pole non-linear state variable filter (24 dB/oct)\nwith asymmetry in the saturation which leads\nto flutter when driven.\nSounds nice at low resonances.") +: filter_type == 12 ? gfx_drawstr("2-pole non-linear state variable filter (12 dB/oct)\ninc") +: filter_type == 13 ? gfx_drawstr("4-pole non-linear state variable filter (24 dB/oct)\ninc") +: filter_type == 14 ? gfx_drawstr("2-pole linear state variable filter where\nthe approximate resonance is rectified.") +: filter_type == 15 ? gfx_drawstr("2-pole non-linear Steiner filter with diode clipped\n(symmetric) feedback.Be warned, over 0.5 this filter\ngoes into hard oscillation. This sounds awful unless\nthere's sufficient drive to choke it.\nResonance loss more dominant at HF.") +: filter_type == 16 ? gfx_drawstr("2-pole non-linear Steiner filter with diode clipped\n(asymmetric) feedback. Raising the drive lowers the\nresonance (chokes it). Resonance loss more dominant\nat HF.") +: filter_type == 17 ? gfx_drawstr("Damaged 4p non-linear SVF.") +: filter_type == 18 ? gfx_drawstr("2-pole pillowy non-linear filter") +: filter_type == 19 ? gfx_drawstr("4-pole pillowy non-linear filter") +: filter_type == 20 ? gfx_drawstr("2-pole pillowy non-linear filter w/ clipper in feedback") +: filter_type == 21 ? gfx_drawstr("4-pole pillowy non-linear filter w/ clipper in feedback") +: filter_type == 22 ? gfx_drawstr("2-pole pillowy non-linear filter w/ clipper in feedback\nand crossover dist") +: filter_type == 23 ? gfx_drawstr("4-pole pillowy non-linear filter w/ clipper in feedback\nand crossover dist") +: filter_type == 24 ? gfx_drawstr("Ladder filter") +: filter_type == 25 ? gfx_drawstr("Ladder filter") +: filter_type == 26 ? gfx_drawstr("2-pole ladder filter with allpass filter for resonance.\nDrive this one hard.") +: filter_type == 27 ? gfx_drawstr("2-pole SVF filter with antisaturator.\nDrive this one hard.") +: filter_type == 28 ? gfx_drawstr("4-pole SVF filter with antisaturator.\nDrive this one hard.") + diff --git a/Filter/tilr_SKFilter/skf.Saike_Yutani_Filters.jsfx-inc b/Filter/tilr_SKFilter/skf.Saike_Yutani_Filters.jsfx-inc new file mode 100644 index 0000000..98fde36 --- /dev/null +++ b/Filter/tilr_SKFilter/skf.Saike_Yutani_Filters.jsfx-inc @@ -0,0 +1,3320 @@ +/* +MIT License + +Copyright (c) 2022 Joep Vanlier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +@init +// MS-20 Simulation settings +epsilon = 0.00000001; +//epsilon = 0.01; +maxiter = 6; +maxiter_svf = 26; +safety_limit_ms20 = 0.935; +safety_limit_moog = 0.25; // Above this level the model suffers from numerical difficulties. Ensures fc < fs/8. +safety_limit_resa = 0.89; // Above this level the model suffers from numerical difficulties. Ensures fc < fs/4. +safety_limit_svf = 0.9;//0.94;//0.9; +safety_limit_svf2 = 0.85; +safety_limit_pir = 0.96; + + function tanh(x) + local() + global() + instance() + ( + (2/(1+exp(-2*x)) - 1) + ); + +function clamp(v, lb, ub) +( + min(ub, max(v, lb)) +); + +function cl01(v) +( + min(1, max(0, v)) +); + +function check_safety() +( + ((filter_type == 1) || (filter_type==6)) && (oversampling == 1) ? ( + cutoff > safety_limit_ms20 ? ( + slider_automate(cutoff = safety_limit_ms20); + warning = 75; + ); + ); + + ((filter_type == 26) && (oversampling == 1)) ? ( + cutoff > safety_limit_pir ? ( + slider_automate(cutoff = safety_limit_pir); + warning = 75; + ); + ); + + (filter_type == 3) || (filter_type == 4) ? + ( + cutoff > current_safety_moog ? ( + slider_automate(cutoff = current_safety_moog); + warning = 75; + ); + ); + + filter_type == 10 ? ( + (cutoff > safety_limit_svf) && (oversampling == 1) ? ( + slider_automate(cutoff = safety_limit_svf); + warning = 75; + ); + ); + + (filter_type == 18) || (filter_type == 19) || (filter_type == 20) || (filter_type == 21) || (filter_type == 22) || (filter_type == 23) || (filter_type == 24) || (filter_type == 25) ? ( + (cutoff > safety_limit_resa) && (oversampling == 1) ? ( + slider_automate(cutoff = safety_limit_resa); + warning = 75; + ); + ); +); + +function initialize_vowel(freemem) +instance() +local(ptr) +global(vowels) +( + vowels = freemem; + + // Omega, Gain, Q + // a + vowels[0] = 4146.9023027385265; + vowels[1] = 10681.415022205296; + vowels[2] = 15079.644737231007; + vowels[3] = 6.0; + vowels[4] = 1.0606601717798214; + vowels[5] = 1.0606601717798214; + vowels[6] = 5.0; + vowels[7] = 20.0; + vowels[8] = 20.0; + // e + vowels[9] = 3330.088212805181; + vowels[10] = 11623.892818282235; + vowels[11] = 15707.963267948966; + vowels[12] = 6.0; + vowels[13] = 1.0606601717798214; + vowels[14] = 2.121320343559643; + vowels[15] = 5.0; + vowels[16] = 20.0; + vowels[17] = 50.0; + // i + vowels[18] = 2513.2741228718346; + vowels[19] = 12566.370614359172; + vowels[20] = 16022.122533307946; + vowels[21] = 6.0; + vowels[22] = 1.0606601717798214; + vowels[23] = 2.121320343559643; + vowels[24] = 5.0; + vowels[25] = 20.0; + vowels[26] = 50.0; + // o + vowels[27] = 1884.9555921538758; + vowels[28] = 5466.37121724624; + vowels[29] = 14137.16694115407; + vowels[30] = 6.0; + vowels[31] = 1.0606601717798214; + vowels[32] = 2.121320343559643; + vowels[33] = 5.0; + vowels[34] = 20.0; + vowels[35] = 50.0; + // u + vowels[36] = 4021.238596594935; + vowels[37] = 7539.822368615503; + vowels[38] = 15079.644737231007; + vowels[39] = 6.0; + vowels[40] = 1.6836930724640595; + vowels[41] = 1.3363480772105092; + vowels[42] = 9.0; + vowels[43] = 10.0; + vowels[44] = 20.0; + // ee + vowels[45] = 1300.6193585861743; + vowels[46] = 14451.326206513048; + vowels[47] = 18849.55592153876; + vowels[48] = 6.0; + vowels[49] = 1.0606601717798214; + vowels[50] = 2.121320343559643; + vowels[51] = 5.0; + vowels[52] = 20.0; + vowels[53] = 50.0; + + freemem + 64 +); + +function initvowel(position, qin) +instance( + c, amp1, amp2, amp3, + Ab0, Ab2, Aa1, Aa2, + Bb0, Bb2,Ba1, Ba2, + Cb0, Cb2, Ca1, Ca2, +) +local( + prev, ptr, loc, rloc, irloc, srate_factor, + omega_1, omega_2, omega_3, + q1, q2, q3, + w0, cw, sw, alpha, + a0, a0i, Q ) +global(vowels, israte, oversampling) +( + loc = position * 4.9999999999999; + prev = floor(loc); + irloc = loc - prev; + rloc = 1.0 - irloc; + ptr = vowels + 9 * prev; + srate_factor = israte / oversampling; + + omega_1 = ptr[0] * rloc + ptr[9] * irloc; + omega_2 = ptr[1] * rloc + ptr[10] * irloc; + omega_3 = ptr[2] * rloc + ptr[11] * irloc; + amp1 = ptr[3] * rloc + ptr[12] * irloc; + amp2 = ptr[4] * rloc + ptr[13] * irloc; + amp3 = ptr[5] * rloc + ptr[14] * irloc; + q1 = ptr[6] * rloc + ptr[15] * irloc; + q2 = ptr[7] * rloc + ptr[16] * irloc; + q3 = ptr[8] * rloc + ptr[17] * irloc; + + // Biquads RBJ BP + Q = 2 * q1; + w0 = omega_1 * srate_factor; + cw = cos(w0); + sw = sin(w0); + alpha = 0.5 * sw / Q; + a0 = 1 + alpha; + a0i = 1 / a0; + Ab0 = alpha*a0i; + Ab2 = - alpha*a0i; + Aa1 = - (2 * cw)*a0i; + Aa2 = (1 - alpha)*a0i; + + Q = 2 * q2; + w0 = omega_2 * srate_factor; + cw = cos(w0); + sw = sin(w0); + alpha = 0.5 * sw / Q; + a0 = 1 + alpha; + a0i = 1 / a0; + Bb0 = alpha*a0i; + Bb2 = - alpha*a0i; + Ba1 = - (2 * cw)*a0i; + Ba2 = (1 - alpha)*a0i; + + Q = 2 * q3; + w0 = omega_3 * srate_factor; + cw = cos(w0); + sw = sin(w0); + alpha = 0.5 * sw / Q; + a0 = 1 + alpha; + a0i = 1 / a0; + Cb0 = alpha*a0i; + Cb2 = - alpha*a0i; + Ca1 = - (2 * cw)*a0i; + Ca2 = (1 - alpha)*a0i; +); + +function eval_vowel(sample) +instance( + amp1, amp2, amp3, + Ab0, Ab1, Ab2, + Aa1, Aa2, + Bb0, Bb1, Bb2, + Ba1, Ba2, + Cb0, Cb1, Cb2, + Ca1, Ca2, + d1x, d2x, + d1yA, d2yA, + d1yB, d2yB, + d1yC, d2yC, +) +local(out, outA, outB, outC) +global() +( + outA = Ab0 * sample + Ab2 * d2x - Aa1 * d1yA - Aa2 * d2yA; + outB = Bb0 * sample + Bb2 * d2x - Ba1 * d1yB - Ba2 * d2yB; + outC = Ab0 * sample + Cb2 * d2x - Ca1 * d1yC - Ca2 * d2yC; + + d2x = d1x; + d1x = sample; + + d2yA = d1yA; + d1yA = outA; + + d2yB = d1yB; + d1yB = outB; + + d2yC = d1yC; + d1yC = outC; + + out = amp1 * outA + amp2 * outB + amp3 * outC; +); + +function eval_vowel_b(sample) +instance( + amp1, amp2, amp3, + Ab0, Ab1, Ab2, + Aa1, Aa2, + Bb0, Bb1, Bb2, + Ba1, Ba2, + Cb0, Cb1, Cb2, + Ca1, Ca2, + d1x2, d2x2, + d1yA2, d2yA2, + d1yB2, d2yB2, + d1yC2, d2yC2, +) +local(out, outA, outB, outC) +global() +( + outA = Ab0 * sample + Ab2 * d2x2 - Aa1 * d1yA2 - Aa2 * d2yA2; + outB = Bb0 * sample + Bb2 * d2x2 - Ba1 * d1yB2 - Ba2 * d2yB2; + outC = Ab0 * sample + Cb2 * d2x2 - Ca1 * d1yC2 - Ca2 * d2yC2; + + d2x2 = d1x2; + d1x2 = sample; + + d2yA2 = d1yA2; + d1yA2 = outA; + + d2yB2 = d1yB2; + d1yB2 = outB; + + d2yC2 = d1yC2; + d1yC2 = outC; + + out = amp1 * outA + amp2 * outB + amp3 * outC; +); + +function init_303(cutoff, q) + local(dwc, dwc2, dwc3, qwc2, qwc3) + global(isampling_factor) + instance(wc, wc2, wc3, wc4, A, k, b, g, z0, z1, z2, z3, y1, y2, y3, y4, + b0, a0, a1, a2, a3, b10, a10, a11, a12, a13, b20, a20, a21, a22, a23, c2, c3, sc) + ( + // This specific filter came from + // Copyright (c) 2012 Dominique Wurtz (www.blaukraut.info) + wc = exp( (1-cutoff) * log(20/22050) ) * isampling_factor; + wc = tan(.39 * $pi * wc); + + wc2 = wc*wc; + wc3 = wc2*wc; + wc4 = wc3*wc; + b = 1.0 / ( 1.0 + 8.0*wc + 20.0*wc2 + 16.0*wc3 + 2.0*wc4); + g = 2.0 * wc4 * b; + + k = 16.95*q; + A = 1 + 0.5 * k; + + dwc = 2*wc; + dwc2 = 2*wc2; + qwc2 = 4*wc2; + dwc3 = 2*wc3; + qwc3 = 4*wc3; + + b0 = dwc+12*wc2+20*wc3+8*wc4; + a0 = 1+6*wc+10*wc2+qwc3; + a1 = dwc+8*wc2+6*wc3; + a2 = dwc2+wc3; + a3 = dwc3; + + b10 = dwc2+8*wc3+6*wc4; + a10 = wc+4*wc2+3*wc3; + a11 = 1+6*wc+11*wc2+6*wc3; + a12 = wc+qwc2+qwc3; + a13 = wc2+dwc3; + + b20 = dwc3+4*wc4; + a20 = a13; + a21 = wc+qwc2+4*wc3; + a22 = 1+6*wc+10*wc2+qwc3; + a23 = wc+qwc2+dwc3; + + c2 = a21 - a3; + c3 = 1+6*wc+9*wc2+dwc3; + + sc = (57.96533646143774 - 26.63612328945456*exp(- 0.44872755850609214 * k)) / 31.329213171983177; + ); + +function reset_303() + local(Kbig) + global(slider54) + instance(wc, wc2, wc3, wc4, A, k, b, g, z0, z1, z2, z3, y1, y2, y3, y4, + b0, a0, a1, a2, a3, b10, a10, a11, a12, a13, b20, a20, a21, a22, a23, c2, c3 ) + ( + z1 = z2 = z3 = 0; + y1 = y2 = y3 = y4 = 0; + ); + +function eval_303(input, choice, frac) + local(y0, s0, s, f1, f2, fb) + instance(wc, wc2, wc3, wc4, A, k, b, g, z0, z1, z2, z3, y1, y2, y3, y4 + b0, a0, a1, a2, a3, b10, a10, a11, a12, a13, b20, a20, a21, a22, a23, c2, c3, sc) + global() + ( + s = (z0*wc3 + z1*a20 + z2*c2 + z3*c3) * b; + y4 = (g*input + s) / (1.0 + g*k); + + fb = input - k*y4; + y0 = max(-1,min(1,fb)); + + y1 = b * (y0*b0 + z0*a0 + z1*a1 + z2*a2 + z3*a3); // #OK + y2 = b * (y0*b10 + z0*a10 + z1*a11 + z2*a12 + z3*a13); // #OK + y3 = b * (y0*b20 + z0*a20 + z1*a21 + z2*a22 + z3*a23); // + y4 = ((g*y0 + s)); + + z0 += 4*wc*(y0 - y1 + y2); + z1 += 2*wc*(y1 - 2*y2 + y3); + z2 += 2*wc*(y2 - 2*y3 + y4); + z3 += 2*wc*(y3 - 2*y4); + + (choice == 0 ) ? ( + f1 = A*y4; // LP + f2 = y4 + y2 - y1; // BP + ) : (choice == 1) ? ( + f1 = y4 + y2 - y1; // BP + f2 = -(y0 - y4)*.5; // HP + ) : (choice == 2) ? ( + frac = frac * frac; + frac = frac * frac; + f1 = -(y0 - y4)*.5; // HP + f2 = -(y0*2 + (y4 + y2 - y1))*.5; // BR + ) : (choice == 3) ? ( + f1 = (y0*2 + (y4 + y2 - y1))*.5; // BR + f2 = A*y4; // LP + ); + + (f2 * frac + f1 * (1.0-frac))*sc +); + +function init_linearSVF(freq, res) + global(isampling_factor) + local() + instance(f0, ic1eq, ic2eq, g, k, a1, a2, a3) + ( + f0 = exp( (1-freq) * log(20/22050) ) * isampling_factor; + g = tan(.5 * $pi * f0); + k = 2 - 2*res; + + a1 = 1/(1+g*(g+k)); + a2 = g*a1; + a3 = g*a2; + ); + +function init_linearSVF_absolute(f0, res) + global(srate) + local(g) + instance(f0, ic1eq, ic2eq, k, a1, a2, a3) + ( + g = tan($pi * f0 / srate); + k = 2 - 2*res; + + a1 = 1/(1+g*(g+k)); + a2 = g*a1; + a3 = g*a2; + ); + +function init_linearSVF_all(freq, res, morph) + global(isampling_factor) + local(frac) + instance(f0, ic1eq, ic2eq, k, g, a1, a2, a3, m0, m1, m2) + ( + f0 = exp( (1-freq) * log(20/22050) ) * isampling_factor; + g = tan(.5 * $pi * f0); + k = 2 - 2*res; + a1 = 1/(1+g*(g+k)); + a2 = g*a1; + a3 = g*a2; + + // v0 v1 v2 + // LP = v2 + // BP = v1; + // HP = v0 - k * v1 - v2; + // BR = v0 - v1; + morph *= 4.0; + frac = morph - floor(morph); + morph < 1 ? ( + // LP to BP + m0 = 0.0; + m1 = frac; + m2 = (1.0 - frac); + ) : ( morph < 2 ) ? ( + // BP to HP + m0 = frac; + m1 = (1.0 - frac) - k * frac; + m2 = -frac; + ) : ( morph < 3 ) ? ( + // HP to BR + m0 = (1.0 - frac) + frac; + m1 = -k * (1.0 - frac) - frac; + m2 = -(1.0 - frac); + ) : ( + m0 = (1.0 - frac); + m1 = -(1.0 - frac); + m2 = frac; + ); + + /*A = sqrt(1-res*res); + m0 *= A; + m1 *= A; + m2 *= A;*/ + ); + +function eval_linearSVF_All(v0) + global() + local(v1, v2, v3) + instance(ic1eq, ic2eq, a1, a2, a3, m0, m1, m2, k) + ( + v3 = v0 - ic2eq; + v1 = a1 * ic1eq + a2 * v3; + v2 = ic2eq + a2 * ic1eq + a3 * v3; + ic1eq = 2.0 * v1 - ic1eq; + ic2eq = 2.0 * v2 - ic2eq; + (m0 * v0 + m1 * v1 + m2 * v2) + ); + +function eval_linearSVF_All4p(v0) + global() + local(v1, v2, v3) + instance(ic1eq, ic2eq, ic3eq, ic4eq, a1, a2, a3, m0, m1, m2, k) + ( + v3 = v0 - ic2eq; + v1 = a1 * ic1eq + a2 * v3; + v2 = ic2eq + a2 * ic1eq + a3 * v3; + ic1eq = 2.0 * v1 - ic1eq; + ic2eq = 2.0 * v2 - ic2eq; + + v3 = (m0 * v0 + m1 * v1 + m2 * v2) - ic4eq; + v1 = a1 * ic3eq + a2 * v3; + v2 = ic4eq + a2 * ic3eq + a3 * v3; + ic3eq = 2.0 * v1 - ic3eq; + ic4eq = 2.0 * v2 - ic4eq; + + (m0 * v0 + m1 * v1 + m2 * v2) + ); + +function reset_linearSVF() + global() + local() + instance(ic1eq, ic2eq, k, a1, a2, a3) + ( + ic1eq = ic2eq = 0; + ); + +function eval_linearSVF_LP(v0) + global() + local(v1, v2, v3) + instance(ic1eq, ic2eq, a1, a2, a3) + ( + v3 = v0 - ic2eq; + v1 = a1 * ic1eq + a2 * v3; + v2 = ic2eq + a2 * ic1eq + a3*v3; + ic1eq = 2*v1 - ic1eq; + ic2eq = 2*v2 - ic2eq; + + v2 + ); + +function eval_linearSVF_HP(v0) + global() + local(v1, v2, v3) + instance(ic1eq, ic2eq, k, a1, a2, a3) + ( + v3 = v0 - ic2eq; + v1 = a1 * ic1eq + a2 * v3; + v2 = ic2eq + a2 * ic1eq + a3*v3; + ic1eq = 2*v1 - ic1eq; + ic2eq = 2*v2 - ic2eq; + + v0 - k*v1 - v2 + ); + +function eval_linearSVF_LPHP(v0, lphp) + global() + local(v1, v2, v3) + instance(ic1eq, ic2eq, a1, a2, a3, k) + ( + v3 = v0 - ic2eq; + v1 = a1 * ic1eq + a2 * v3; + v2 = ic2eq + a2 * ic1eq + a3*v3; + ic1eq = 2*v1 - ic1eq; + ic2eq = 2*v2 - ic2eq; + + v2 * (1.0 - lphp) - lphp * (v0 - k*v1 - v2) + ); + +function eval_linearSVF_BP(v0) + global() + local(v1, v2, v3) + instance(ic1eq, ic2eq, k, a1, a2, a3) + ( + v3 = v0 - ic2eq; + v1 = a1 * ic1eq + a2 * v3; + v2 = ic2eq + a2 * ic1eq + a3*v3; + ic1eq = 2*v1 - ic1eq; + ic2eq = 2*v2 - ic2eq; + + v1 + ); + +function eval_linearSVF_BR(v0) + global() + local(v1, v2, v3) + instance(ic1eq, ic2eq, k, a1, a2, a3) + ( + v3 = v0 - ic2eq; + v1 = a1 * ic1eq + a2 * v3; + v2 = ic2eq + a2 * ic1eq + a3*v3; + ic1eq = 2*v1 - ic1eq; + ic2eq = 2*v2 - ic2eq; + + v0 - v1 + ); + + function expensive_tanh(x) + local(em2x) + global() + ( + x = x; + em2x = exp(-2*x); + (2/(1+em2x))-1 + ); + + function init_moog3(cutoff, resonance) + local(fs, fc, g, p0s, nmp, gN, kgN, p0g, tmp, acc) + global(srate, sampling_factor) + instance(VT2, rg1, rg2, rg3, qg1, qg2, qg3, si1, sf1, sg1, si2, sf2, sg2, k0g, k0s, VT2i, q0s, r1s, k) + ( + k = resonance * 8; + fs = srate * sampling_factor; + fc = 0.5 * srate * exp( (1-cutoff) * log(20/22050) ); + + g = tan($pi / fs * fc) / sqrt(1 + k ^ 0.6666666666666666 - k ^ 0.3333333333333333); + VT2 = 0.052; + VT2i = 19.23076923076923; + + // Ladder stages + p0s = 1.0 / (1.0 + g); + q0s = 1.0 - g; + r1s = -g; + k0s = VT2 * g * p0s; + + // Global filter + nmp = (1.0 - p0s); + gN = nmp * nmp * nmp; + kgN = k * gN; + p0g = 1.0 / (1.0 + kgN); + k0g = -VT2i * p0g; + + rg1 = -3.0*kgN; + rg2 = -3.0*kgN; + rg3 = - kgN; + acc = tmp = p0s*(g - 1.0); + qg1 = -3.0*(kgN + acc); + acc = acc*tmp; + qg2 = -3.0*(kgN + acc); + acc = acc*tmp; + qg3 = - (kgN + acc); + ); + + function eval_moog3(x) + local(yi, yd, yf) + global() + instance(yo, y, A, B, rg1, rg2, rg3, qg1, qg2, qg3, si1, sf1, sg1, si2, sf2, sg2, si3, sf3, sg3, k0g, k0s, VT2i, q0s, r1s, k) + ( + yo = tanh(k0g * (x + sg1)); + A = yo; + + yi = yo; + yd = k0s * (yi + sf1); + y = yd + si1; + yo = tanh(VT2i * y); + B = yo; + + si1 = yd + y; + sf1 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf2); + y = yd + si2; + yo = tanh(VT2i * y); + + si2 = yd + y; + sf2 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf3); + y = yd + si3; + yo = tanh(VT2i * y); + + si3 = yd + y; + sf3 = r1s * yi - q0s * yo; + + yf = k * y; + + sg1 = rg1 * x + qg1 * yf + sg2; + sg2 = rg2 * x + qg2 * yf + sg3; + + sg3 = rg3 * x + qg3 * yf; + ); + + function mix_moog3(x, choice, frac) + local() + global() + instance(VT, VT2, VT2i, A, B, y, yo, k, f1, f2) + ( + this.eval_moog3(x*VT2); + + (choice == 0) ? ( + f1 = y * (1 + k); // LP + f2 = VT2 * (2*B - 2*yo); // BP + ) : (choice == 1) ? ( + f1 = VT2 * (2*B - 2*yo); // BP + f2 = VT2 * (A - B); // HP + ) : (choice == 2) ? ( + frac = frac * frac; + frac = frac * frac; + f1 = VT2 * (A - B); // HP + f2 = -VT2 * 0.5 * (B - yo * (2 + k) - A); // BR + ) : (choice == 3) ? ( + f1 = -VT2 * 0.5 * (B - yo * (2 + k) - A); // BR + f2 = y * (1 + k); // LP + ); + + (f2 * frac + f1 * (1.0-frac))*VT2i; + ); + + function init_moog6(cutoff, resonance) + local(fs, fc, g, p0s, nmp, gN, kgN, p0g, tmp, acc) + global(srate, sampling_factor) + instance(VT2, rg1, rg2, rg3, rg4, rg5, rg6, qg1, qg2, qg3, qg4, qg5, qg6, si1, sf1, sg1, si2, sf2, sg2, si3, sf3, sg3, si4, sf4, sg4, si5, sf5, sg5, si6, sf6, sg6, k0g, k0s, VT2i, q0s, r1s, k) + ( + k = resonance * 2.3703703703703694; + fs = srate * sampling_factor; + fc = 0.5 * srate * exp( (1-cutoff) * log(20/22050) ); + g = tan($pi / fs * fc); + k > 0 ? g /= sqrt(1 + k ^ 0.3333333333333333 - 2.0 * 0.8660254037844387 * k ^ 0.16666666666666666); + + VT2 = 0.052; + VT2i = 19.23076923076923; + + // Ladder stages + p0s = 1.0 / (1.0 + g); + q0s = 1.0 - g; + r1s = -g; + k0s = VT2 * g * p0s; + + // Global filter + nmp = (1.0 - p0s); + gN = nmp * nmp; + gN = gN * gN; + gN = gN * gN; + kgN = k * gN; + p0g = 1.0 / (1.0 + kgN); + k0g = -VT2i * p0g; + + rg1 = -6.0*kgN; + rg2 = -15.0*kgN; + rg3 = -20.0*kgN; + rg4 = -15.0*kgN; + rg5 = -6.0*kgN; + rg6 = -1.0*kgN; + acc = tmp = p0s*(g - 1.0); + qg1 = -6.0*(kgN + acc); + acc = acc*tmp; + qg2 = -15.0*(kgN + acc); + acc = acc*tmp; + qg3 = -20.0*(kgN + acc); + acc = acc*tmp; + qg4 = -15.0*(kgN + acc); + acc = acc*tmp; + qg5 = -6.0*(kgN + acc); + acc = acc*tmp; + qg6 = -1.0*(kgN + acc); + ); + + function eval_moog6(x) + local(yi, yd, yf) + global() + instance(yo, y, A, B, rg1, rg2, rg3, rg4, rg5, rg6, qg1, qg2, qg3, qg4, qg5, qg6, si1, sf1, sg1, si2, sf2, sg2, si3, sf3, sg3, si4, sf4, sg4, si5, sf5, sg5, si6, sf6, sg6, k0g, k0s, VT2i, q0s, r1s, k) + ( + yo = tanh(k0g * (x + sg1)); + A = yo; + + yi = yo; + yd = k0s * (yi + sf1); + y = yd + si1; + yo = tanh(VT2i * y); + B = yo; + + si1 = yd + y; + sf1 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf2); + y = yd + si2; + yo = (VT2i * y); + + si2 = yd + y; + sf2 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf3); + y = yd + si3; + yo = (VT2i * y); + + si3 = yd + y; + sf3 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf4); + y = yd + si4; + yo = (VT2i * y); + + si4 = yd + y; + sf4 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf5); + y = yd + si5; + yo = VT2i * y; + + si5 = yd + y; + sf5 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf6); + y = yd + si6; + yo = tanh(VT2i * y); + + si6 = yd + y; + sf6 = r1s * yi - q0s * yo; + + yf = k * y; + + sg1 = rg1 * x + qg1 * yf + sg2; + sg2 = rg2 * x + qg2 * yf + sg3; + sg3 = rg3 * x + qg3 * yf + sg4; + sg4 = rg4 * x + qg4 * yf + sg5; + sg5 = rg5 * x + qg5 * yf + sg6; + + sg6 = rg6 * x + qg6 * yf; + ); + + function mix_moog6(x, choice, frac) + local() + global() + instance(VT, VT2, VT2i, A, B, y, yo, k, f1, f2) + ( + this.eval_moog6(x*VT2); + + (choice == 0) ? ( + f1 = y * (1 + k); // LP + f2 = VT2 * (2*B - 2*yo); // BP + ) : (choice == 1) ? ( + f1 = VT2 * (2*B - 2*yo); // BP + f2 = VT2 * (A - B); // HP + ) : (choice == 2) ? ( + frac = frac * frac; + frac = frac * frac; + f1 = VT2 * (A - B); // HP + f2 = -VT2 * 0.5 * (B - 2.5 * yo - 2 * A); // BR + ) : (choice == 3) ? ( + f1 = -VT2 * 0.5 * (B - 2.5 * yo - 2 * A); // BR + f2 = y * (1 + k); // LP + ); + + (f2 * frac + f1 * (1.0-frac))*VT2i; + ); + + function init_moog2(cutoff, resonance) + local(fs, fc, g, p0s, nmp, gN, kgN, p0g, tmp, acc) + global(srate, sampling_factor) + instance(VT2, rg1, rg2, qg1, qg2, si1, sf1, sg1, si2, sf2, sg2, k0g, k0s, VT2i, q0s, r1s, k) + ( + k = resonance*120; + + fs = srate * sampling_factor; + fc = .5 * srate * exp( (1-cutoff) * log(20/22050) ); + g = tan($pi / fs * fc) / sqrt(1 + k); + + VT2 = 0.052; + VT2i = 19.23076923076923; + + // Ladder stages + p0s = 1.0 / (1.0 + g); + q0s = 1.0 - g; + r1s = -g; + k0s = VT2 * g * p0s; + + // Global filter + nmp = (1.0 - p0s); + gN = nmp * nmp; + kgN = k * gN; + p0g = 1.0 / (1.0 + kgN); + k0g = -VT2i * p0g; + + rg1 = -2.0*kgN; + rg2 = -1.0*kgN; + acc = tmp = p0s*(g - 1.0); + qg1 = -2.0*(kgN + acc); + acc = acc*tmp; + qg2 = -1.0*(kgN + acc); + ); + + function eval_moog2(x) + local(yi, yd, yf) + global() + instance(yo, y, A, B, rg1, rg2, qg1, qg2, si1, sf1, sg1, si2, sf2, sg2, k0g, k0s, VT2i, q0s, r1s, k) + ( + yo = tanh(k0g * (x + sg1)); + A = yo; + + yi = yo; + yd = k0s * (yi + sf1); + y = yd + si1; + yo = tanh(VT2i * y); + B = yo; + + si1 = yd + y; + sf1 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf2); + y = yd + si2; + yo = tanh(VT2i * y); + + si2 = yd + y; + sf2 = r1s * yi - q0s * yo; + + yf = k * y; + + sg1 = rg1 * x + qg1 * yf + sg2; + sg2 = rg2 * x + qg2 * yf; + ); + + function mix_moog2(x, choice, frac) + local() + global() + instance(VT, VT2, VT2i, A, B, y, yo, k, f1, f2) + ( + this.eval_moog2(x*VT2); + + (choice == 0) ? ( + f1 = y * (1 + k); // LP + f2 = VT2 * (2*B - 2*yo)*8; // BP + ) : (choice == 1) ? ( + f1 = VT2 * (2*B - 2*yo)*8; // BP + f2 = VT2 * (A - B); // HP + ) : (choice == 2) ? ( + frac = frac * frac; + frac = frac * frac; + f1 = VT2 * (A - B); // HP + f2 = -VT2 * (2*B-yo*(2+k)-A); // BR + ) : (choice == 3) ? ( + f1 = -VT2 * (2*B-yo*(2+k)-A); // BR + f2 = y * (1 + k); // LP + ); + + (f2 * frac + f1 * (1.0-frac))*VT2i; + ); + + function init_moog(cutoff, resonance) + local(fs, fc, g, p0s, nmp, gN, kgN, p0g, tmp, acc) + global(srate, sampling_factor) + instance(VT2, rg1, rg2, rg3, rg4, qg1, qg2, qg3, qg4, si1, sf1, sg1, si2, sf2, sg2, si3, sf3, sg3, si4, sf4, sg4, k0g, k0s, VT2i, q0s, r1s, k) + ( + k = resonance* 3.9999999999999987; + fc = .5 * srate * exp( (1-cutoff) * log(20/22050) ); + fs = srate * sampling_factor; + g = tan($pi * fc / fs) / sqrt(1.0 + sqrt(k) - 2 * pow(k, 0.25) * 0.7071067811865476); + VT2 = 0.052; + VT2i = 19.23076923076923; + + // Ladder stages + p0s = 1.0 / (1.0 + g); + q0s = 1.0 - g; + r1s = -g; + k0s = VT2 * g * p0s; + + // Global filter + nmp = (1.0 - p0s); + gN = nmp * nmp * nmp * nmp; + kgN = k * gN; + p0g = 1.0 / (1.0 + kgN); + k0g = -VT2i * p0g; + + rg1 = -4.0*kgN; + rg2 = -6.0*kgN; + rg3 = -4.0*kgN; + rg4 = -1.0*kgN; + acc = tmp = p0s*(g - 1.0); + qg1 = -4.0*(kgN + acc); + acc = acc*tmp; + qg2 = -6.0*(kgN + acc); + acc = acc*tmp; + qg3 = -4.0*(kgN + acc); + acc = acc*tmp; + qg4 = -1.0*(kgN + acc); + ); + + function eval_moog(x) + local(yi, yd, yf) + global() + instance(rg1, rg2, rg3, rg4, qg1, qg2, qg3, qg4, si1, sf1, sg1, si2, sf2, sg2, si3, sf3, sg3, si4, sf4, sg4, k0g, k0s, VT2i, q0s, r1s, k, + A, B, C, D, y, yo) + ( + yo = tanh(k0g * (x + sg1)); + A = yo; + + yi = yo; + yd = k0s * (yi + sf1); + y = yd + si1; + yo = tanh(VT2i * y); + B = yo; + + si1 = yd + y; + sf1 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf2); + y = yd + si2; + yo = tanh(VT2i * y); + C = yo; + + si2 = yd + y; + sf2 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf3); + y = yd + si3; + yo = tanh(VT2i * y); + D = yo; + + si3 = yd + y; + sf3 = r1s * yi - q0s * yo; + + yi = yo; + yd = k0s * (yi + sf4); + y = yd + si4; + yo = tanh(VT2i * y); + + si4 = yd + y; + sf4 = r1s * yi - q0s * yo; + yf = k * y; + + sg1 = rg1 * x + qg1 * yf + sg2; + sg2 = rg2 * x + qg2 * yf + sg3; + sg3 = rg3 * x + qg3 * yf + sg4; + sg4 = rg4 * x + qg4 * yf; + ); + + function mix_moog(x, choice, frac) + local() + global() + instance(VT, VT2, VT2i, A, B, C, D, y, yo, k, f1, f2) + ( + this.eval_moog(x*VT2); + + (choice == 0) ? ( + f1 = y * (1 + k); // LP + f2 = VT2 * (2*C - 2*B); // BP + ) : (choice == 1) ? ( + f1 = VT2 * (2*C - 2*B); // BP + //f1 = VT2 * (4*C - 8*B + 4*yo)/6; // BP + f2 = VT2 * (A - 4 * B + 6 * C - 4 * D + yo); // HP + ) : (choice == 2) ? ( + frac = frac * frac; /* Make sure the HP gets some space */ + frac = frac * frac; + f1 = VT2 * (A - 4 * B + 6 * C - 4 * D + yo); // HP + f2 = VT2 * (A - 4 * B + 6 * C - 4 * D); // Notch + ) : (choice == 3) ? ( + f1 = VT2 * (A - 4 * B + 6 * C - 4 * D); // Notch + f2 = y * (1 + k); // LP + ); + + (f2 * frac + f1 * (1.0-frac))*VT2i + ); + +function init_1p_tpt_based(freq, resonance) +instance(coeff, b1, b2, b3, K, a0) +local(i1g, gg, f0, g, ga) +global(isampling_factor) +( + K = 2 * resonance; + f0 = exp( (1 - freq) * log(20/22050) ) * isampling_factor; + g = tan(.5 * $pi * f0); + i1g = 1.0 / (1.0 + g); + coeff = g * i1g; + ga = 2.0 * coeff - 1.0; + b1 = ga * coeff; + b2 = ga * i1g; + b3 = 2.0 * i1g; + a0 = 1.0 / (1.0 + K * ga * coeff * coeff); +); + +function eval_1p_tpt_based(u, choice, frac) +instance(coeff, a0, b1, b2, b3, s1, s2, s3, K) +local(y, v, out, fb, f1, f2, bin, lps, mx, p_drive, tt, approx_gain_comp) +global(preamp) +( + fb = K * (b1 * s1 + b2 * s2 + b3 * s3); + + p_drive = (preamp - 1) * (preamp > 1); + + approx_gain_comp = sqrt(1 + p_drive); + + fb *= approx_gain_comp;//(1.0 + p_drive * 1.5); + fb > 0.3 ? fb = 0.3; + fb < -0.3 ? fb = - 0.3; + + y = a0 * (u - fb); + bin = y = y > 0 ? y / (1.0 + abs(y + 0.5 * y * y)) : y / (1.0 + abs(y));; + + // LP + v = coeff * (y - s1); + tt = y = v + s1; + s1 = y + v; + + // LP + v = coeff * (y - s2); + lps = y = v + s2; + s2 = y + v; + + // AP + v = y - s3; + s3 = s3 + 2 * coeff * v; + y = s3 - v; + + (choice == 0) ? ( + f1 = y; // LP + f2 = - 2.0 * (s3 - y); // BP + ) : (choice == 1) ? ( + f1 = - 2.0 * (s3 - y); // BP + f2 = bin - tt; // HP + ) : (choice == 2) ? ( + frac = frac * frac; /* Make sure the HP gets some space */ + f1 = bin - tt; // HP + f2 = (bin - 2.333 * (s3 - y)); // Notch + ) : (choice == 3) ? ( + f1 = (bin - 2.333 * (s3 - y)); // Notch + f2 = y; // LP + ); + + (f2 * frac + f1 * (1.0-frac)) * approx_gain_comp; +); + + function f_g_asym(s) + local() + global() + instance() + ( + s > 0 ? min(1,s) + : max(-1,s*.25) + ); + + function f_g(s) + local() + global() + instance() + ( + max(-1,min(1,s)) + ); + + function f_dg(s) + local() + global() + instance() + ( + 1 - 1 * (abs(s)>1) + ); + + function f_dg_asym(s) + local() + global() + instance() + ( + s > 0 ? 1 - 1 * (abs(s)>1) + : .25 - .25 * (abs(s)>4) + ); + + function f_g_svf(s) + local() + global() + instance() + ( + s > 0 ? min(1,s) : max(-1,s*.25) + ); + + function f_dg_svf(s) + local() + global() + instance() + ( + s > 0 ? 1 - 1 * (abs(s)>1) + : .25 - .25 * (abs(s)>4) + ); + + function reset_SVF_nonlin() + instance(y1, y2, d1, d2) + ( + d1 = d2 = y1 = y2 = 0.0; + ); + + function init_svf2(cutoff, reso, morph) + instance(k, wc, mo0, mo1, mo2) + local(f0, rm) + global(isampling_factor) + ( + f0 = exp( (1.0 - cutoff) * log(20/22050) ) * isampling_factor; + wc = tan(0.5 * $pi * f0); + k = .999 - reso + .01; + + /*hh = h * h; + h2 = 2.0 * h; + k2h = h2 * k; + denom = 1.0 / (hh + k2h + 1.0);*/ + + // The different modes can be obtained from the outputs as follows: + // x y1 y2 + // LP 0 0 1 0 + // BP 0 2 0 0.25 + // HP 1 0 -1 0.5 + // BR 1 -2 0 0.75 + ( morph < 0.25 ) ? ( + mo0 = 0; + mo1 = 8 * morph; + mo2 = 1.0 - 4 * morph; + ) : ( morph < 0.5 ) ? ( + rm = morph - 0.25; + mo0 = rm * 4; + mo1 = 2.0 - rm * 8; + mo2 = - rm * 4; + ) : ( morph < 0.75 ) ? ( + rm = morph - 0.5; + mo0 = 1.0; + mo1 = - rm * 8; + mo2 = -1.0 + rm * 4; + ) : ( morph < 1.0 ) ? ( + rm = morph - 0.75; + mo0 = 1.0 - rm * 4; + mo1 = rm * 8 - 2.0; + mo2 = rm * 4; + ); + ); + + function c_svf2(x) + local() + global() + instance() + ( + 1.25 * x + 3.75 * x * x / (1 + abs(5 * x)) + ); + + function dc_svf2(x) + local(ax) + global() + instance() + ( + ax = 1.0 / (5 * abs(x) + 1); + 7.5 * x * ax - 18.75 * x * x * sign(x) * ax * ax + 1.25 + ); + + function g_svf2(s) + local() + global() + instance() + ( + s / (1 + abs(s)); + ); + + function g_svf2_inverse(s) + ( + s / (1 - abs(s)) + ); + + function dg_svf2(q) + local(qsq) + global() + instance() + ( + qsq = q * q; + (abs(q) > 0.00001) ? abs(q) / (qsq * abs(q) + 2 * qsq + abs(q)) : 1 + ); + + function dg2_svf2(q) + local(aq) + global() + instance() + ( + aq = abs(q) + 1; + (abs(q) > 0.00001) ? - 2 * sign(q) / (aq * aq * aq) : 0 + ); + + /* Soft clipper */ + function f_svf2(s) + local() + global() + instance() + ( + s = 3 * s; + 0.8 * s / (1 + abs(2 * s)) + 0.2 * s + ); + + function df_svf2(q) + local(qsq) + global() + instance() + ( + q = 3 * q; + qsq = q * q; + (abs(q) > 0.00001) ? 0.8 * abs(q) / (4 * qsq * abs(q) + 4 * qsq + abs(q)) + 0.2 : 1 + ); + + function eval_svf2(v0) + global(epsilon, maxiter_svf, preamp) + local( + f1, f2, fh1, fh2, + f1_const, f2_const, /* Constant part of the implicit equation */ + norm, + a, b, c, d, /* Jacobian elements */ + dg_v1, cterm, + k_factor, + ) + instance(res, iter, v0n, v1, v2, k, wc, g_v1, mo0, mo1, mo2) + ( + //g_v1 = g_svf2(v1); + v0 = 3.0 * v0; + k_factor = 1.0 + preamp * (1.0 - k) * 0.2; + + /* Calculate fixed stuff from previous iteration */ + f1_const = wc * c_svf2(v0n - v2 - 2 * (v1 + f_svf2(g_v1 * (k - k_factor)))) + v1; + f2_const = wc * g_v1 + v2; + + v0n = v0; + + iter = 0; + while( + iter += 1; + + g_v1 = g_svf2(v1); + dg_v1 = dg_svf2(v1); + + // Residual + cterm = v0 - v2 - 2 * (v1 + f_svf2(g_v1 * (k - k_factor))); + f1 = wc * c_svf2(cterm) - v1 + f1_const; + f2 = wc * g_v1 - v2 + f2_const; + + //a = -2 * wc * ((k - 1) * dg_svf2(v1) + 1.0) - 1.0; + a = -2 * wc * ((k - 1) * dg_v1 * df_svf2((k - k_factor)*g_v1) + 1.0) * dc_svf2(cterm) - 1.0; + b = - wc; + c = wc * dg_v1; + d = -1; + + res = abs(f1) + abs(f2); + + norm = 1.0 / ( a * d - b * c ); + v1 = v1 - ( d*f1 - b*f2 ) * norm; + v2 = v2 - ( a*f2 - c*f1 ) * norm; + + (res > epsilon) && (iter < maxiter_svf); + ); + + //v2 = tanh(v2*0.333333) * 3; + //v1 = tanh(v1*0.333333) * 3; +// v2 * 0.33333333 + 0.33333 * (mo0 * v0 + mo1 * v1 + mo2 * v2) + ); + + function g_svf2b(s) + local(ts, nl) + global() + instance() + ( + ts = s * s * s; + nl = 5; // 5 + (s*s*s + s) / (1.0 + abs(s*s*s + nl*s)) + ); + + function dg_svf2b(s) + local(s2, s3, denom, nl) + global() + instance() + ( + s2 = s * s; + s3 = s * s2; + nl = 5; + + denom = abs(s3 + nl * s) + 1; + (3 * s2 + 1) / denom - (3 * s2 + nl) * (s3 + s) * sign(s3 + nl*s) / ((denom + 1) * (denom + 1)) + ); + + function eval_svf2b(v0) + global(epsilon, maxiter_svf, preamp) + local( + f1, f2, fh1, fh2, + f1_const, f2_const, /* Constant part of the implicit equation */ + norm, + a, b, c, d, /* Jacobian elements */ + dg_v1, cterm, + k_factor, + ) + instance(res, iter, v0n, v1, v2, k, wc, g_v1, mo0, mo1, mo2) + ( + //g_v1 = g_svf2(v1); + v0 = 3.0 * v0; + k_factor = 1.0 + preamp * (1.0 - k) * 0.2; + + /* Calculate fixed stuff from previous iteration */ + f1_const = wc * c_svf2(v0n - v2 - 2 * (v1 + g_v1 * (k - k_factor))) + v1; + f2_const = wc * g_v1 + v2; + + v0n = v0; + + iter = 0; + while( + iter += 1; + + g_v1 = g_svf2b(v1); + dg_v1 = dg_svf2b(v1); + + // Residual + cterm = v0 - v2 - 2 * (v1 + g_v1 * (k - k_factor)); + f1 = wc * c_svf2(cterm) - v1 + f1_const; + f2 = wc * g_v1 - v2 + f2_const; + + //a = -2 * wc * ((k - 1) * dg_svf2(v1) + 1.0) - 1.0; + a = -2 * wc * ((k - 1) * dg_v1 * (k - k_factor)*g_v1 + 1.0) * dc_svf2(cterm) - 1.0; + b = - wc; + c = wc * dg_v1; + d = -1; + + res = abs(f1) + abs(f2); + + norm = 1.0 / ( a * d - b * c ); + v1 = v1 - ( d*f1 - b*f2 ) * norm; + v2 = v2 - ( a*f2 - c*f1 ) * norm; + + (res > epsilon) && (iter < maxiter_svf); + ); + + //v2 = tanh(v2*0.333333) * 3; + //v1 = tanh(v1*0.333333) * 3; +// v2 * 0.33333333 + 0.33333 * (mo0 * v0 + mo1 * v1 + mo2 * v2) + ); + + function init_SVF_nonlin(cutoff, reso, morph) + instance(h, k, hh, h2, k2h, denom, mo0, mo1, mo2) + local(f0) + global(isampling_factor) + ( + f0 = exp( (1.0 - cutoff) * log(20/22050) ) * isampling_factor; + h = tan(0.5 * $pi * f0); + k = .999 - reso + .01; + hh = h * h; + h2 = 2.0 * h; + k2h = h2 * k; + denom = 1.0 / (hh + k2h + 1.0); + + // The different modes can be obtained from the outputs as follows: + // x y1 y2 + // LP 0 0 1 + // BP 0 1 0 + // HP 1 2*k -1 + // BR 1 -1 0 + ( morph < 0.25 ) ? ( + mo0 = 0; + mo1 = 16.0*morph; + mo2 = 4 - 16.0*morph; + ) : ( morph < 0.5 ) ? ( + mo0 = 16.0*morph - 4.0; + mo1 = 4*(2*k - 1)*(4.0*morph - 1.0) + 4; + mo2 = 4.0 - 16.0*morph; + ) : ( morph < 0.75 ) ? ( + mo0 = 4; + mo1 = 8*k - 4*(2*k + 1)*(4.0*morph - 2.0); + mo2 = 16.0*morph - 12.0; + ) : ( morph < 1.0 ) ? ( + mo0 = 16.0 - 16.0*morph; + mo1 = 16.0*morph - 16.0; + mo2 = 16.0*morph - 12.0; + ); + ); + + + function eval_SVF_nonlin(x) + global(epsilon, maxiter_svf) + local(iter, res, y1, y2, + fb, c1, c2, sig, mul, + a, b, c, norm, + f1, f2, y1d1, + svf_cap_c1, svf_cap_c2 + svf_cap_deriv_c1, svf_cap_deriv_c2) + instance(d0, d1, d2, h, h2, k, hh, k2h, denom, + mo0, mo1, mo2) + ( + iter = 0; + x *= .05; + + // First guess based on linear system + y1 = (d0*h - d1*hh - d1*k2h + d1 - d2*h2 + h*x) * denom; + y2 = (d0*hh + d1*h2 - d2*hh + d2*k2h + d2 + hh*x) * denom; + + while( + iter += 1; + + /* Basic SVF */ + y1d1 = y1 + d1; + fb = 2.0 * k * y1d1; + c1 = x + d0 - (y2 + d2) - f_g_svf(fb); + + mul = c1 < 0 ? 1.01 : 0.96; + svf_cap_c1 = tanh(mul*c1); + svf_cap_c2 = tanh(y1d1); + f1 = y1 - d1 - h * svf_cap_c1; + f2 = y2 - d2 - h * svf_cap_c2; + + res = abs(f1) + abs(f2); + + svf_cap_deriv_c1 = mul * (1.0 - svf_cap_c1 * svf_cap_c1); + svf_cap_deriv_c2 = (1.0 - svf_cap_c2 * svf_cap_c2); + a = 1.0 + k2h * svf_cap_deriv_c1 * f_dg_svf(fb); + b = h * svf_cap_deriv_c1; + c = -h * svf_cap_deriv_c2; + + norm = 1.0 / ( a - b*c ); + y1 = y1 - ( f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter_svf); + ); + + d0 = x; + d1 = y1; + d2 = y2; + + (mo0 * x + mo1 * y1 + mo2 * y2) * 5 + ); + + function f_g_svf_broken(s) + local() + global() + instance() + ( + s > 0 ? min(1,s*4) : max(-1,s*.25) + ); + + function f_dg_svf_broken(s) + local() + global() + instance() + ( + s > 0 ? 4 - 4 * (abs(s)>.25) + : .25 - .25 * (abs(s)>4) + ); + + function tanh_broken(x) + local(m) + global() + instance() + ( + m = x > 0 ? 17 : 3; + ((2/(1+exp(-2*x*m)) - 1)) / m + ); + + function eval_SVF_nonlin_broken(x) + global(epsilon, maxiter_svf) + local(iter, res, + fb, c1, c2, sig, + a, b, c, norm, + f1, f2, as, + svf_cap_c1, svf_cap_c2, fb_nl, + svf_cap_deriv_c1, svf_cap_deriv_c2) + instance(i, y1, y2, d0, d1, d2, h, h2, k, y1d1, hh, k2h, denom, + mo0, mo1, mo2) + ( + iter = 0; + x *= .05; + + // First guess based on linear system + y1 = (d0*h - d1*hh - d1*k2h + d1 - d2*h2 + h*x) * denom; + y2 = (d0*hh + d1*h2 - d2*hh + d2*k2h + d2 + hh*x) * denom; + + while( + iter += 1; + + /* Basic SVF */ + y1d1 = y1 + d1; + fb = 2.0 * k * y1d1; + + fb_nl = f_g_svf_broken(fb); + c1 = x + d0 - (y2 + d2) - fb_nl; + + svf_cap_c1 = tanh_broken(c1); + svf_cap_c2 = tanh_broken(y1d1); + f1 = y1 - d1 - h * svf_cap_c1; + f2 = y2 - d2 - h * svf_cap_c2; + res = abs(f1) + abs(f2); + svf_cap_deriv_c1 = (1.0 - svf_cap_c1 * svf_cap_c1); + svf_cap_deriv_c2 = (1.0 - svf_cap_c2 * svf_cap_c2); + + a = 1.0 + k2h * svf_cap_deriv_c1 * f_dg_svf_broken(fb); + b = h * svf_cap_deriv_c1; + c = -h * svf_cap_deriv_c2; + + norm = 1.0 / ( a - b*c ); + y1 = y1 - ( f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter_svf); + ); + + d0 = x; + d1 = y1; + d2 = y2; + + (mo0 * x + mo1 * y1 + mo2 * y2) * 5 + ); + + function eval_SVF_nonlin_incorrect(x) + global(epsilon, maxiter_svf, sampling_factor, isampling_factor) + local(iter, res, + fb, c1, c2, sig, mul, + a, b, c, norm, + f1, f2, + svf_cap_c1, svf_cap_c2 + svf_cap_deriv_c1, svf_cap_deriv_c2) + instance(i, y1, y2, d0, d1, d2, h, h2, k, y1d1, hh, k2h, denom, + mo0, mo1, mo2) + ( + iter = 0; + x *= .25; + + // First guess based on linear system + y1 = (d0*h - d1*hh - d1*k2h + d1 - d2*h2 + h*x) * denom; + y2 = (d0*hh + d1*h2 - d2*hh + d2*k2h + d2 + hh*x) * denom; + + while( + iter += 1; + + /* Basic SVF */ + y1d1 = y1 + d1; + fb = 2.0 * k * y1d1; + c1 = x + d0 - (y2 + d2) - f_g_svf(fb); + + sig = d1 + h * c1; + mul = sig < 0 ? 1.01 : 0.96; + svf_cap_c1 = tanh(mul*sig*isampling_factor)*sampling_factor; + svf_cap_c2 = tanh((d2 + h * y1d1)*isampling_factor)*sampling_factor; + f1 = y1 - svf_cap_c1; + f2 = y2 - svf_cap_c2; + + res = abs(f1) + abs(f2); + + svf_cap_deriv_c1 = mul * (1.0 - svf_cap_c1 * svf_cap_c1); + svf_cap_deriv_c2 = (1.0 - svf_cap_c2 * svf_cap_c2); + a = 1.0 + k2h * svf_cap_deriv_c1 * f_dg_svf(fb); + b = h * svf_cap_deriv_c1; + c = -h * svf_cap_deriv_c2; + + norm = 1.0 / ( a - b*c ); + y1 = y1 - ( f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter_svf); + ); + + d0 = x; + d1 = y1; + d2 = y2; + + (mo0 * x + mo1 * y1 + mo2 * y2) + ); + + function init_steiner(cutoff, reso, morph) + instance(h, hsq, k, Kh, normalizing_const, vref, alpha, beta, lp, bp, hp) + local(f0) + global(isampling_factor) + ( + f0 = exp( (1.0 - cutoff) * log(20/22050) ) * isampling_factor; + h = tan(0.5 * $pi * f0); + K = 3.98*reso; + hsq = h*h; + Kh = K*h; + normalizing_const = 1.0 / (-Kh + hsq + 2*h + 1); + + /*alpha = 20.94153124476462; + beta = 0.057872340425531923; + vref = log(h / (alpha * beta)) / alpha;*/ + + morph < 0.25 ? ( + lp = 1.0 - morph*4; + bp = morph * 4; + hp = 0; + ) : ( morph < 0.5 ) ? ( + hp = (morph - 0.25) * 4; + bp = 1.0 - (morph - 0.25) * 4; + lp = 0; + ) : ( morph < 0.75 ) ? ( + hp = 1.0; + bp = -2.0 * (morph - 0.5) * 4; + lp = (morph - 0.5) * 4; + ) : ( + hp = 1.0 - (morph - 0.75) * 4; + bp = -2.0 * ( 1 - (morph - 0.75) * 4 ); + lp = 1; + ); + ); + + + function diode(x, alpha, vref) + local() + global() + ( + exp(alpha*(vref + x)) - exp(alpha*vref) + ); + + function ddiode(x, diodeval, alpha, vref) + local() + global() + ( + alpha * exp(alpha * (vref + x)) + ); + + function eval_steiner(xn) + global(epsilon, maxiter_svf) + local(res, f1, f2, x_xn, + a, b, c, d, norm, s1, s2, s1_fixed, s2_fixed, + xn, v1n, v2n, iter, + fb, fb_s1, fb_clipped, kp1, + ) + instance(x, v1, v2, h, hsq, K, Kh, normalizing_const, alpha, vref, beta, + lp, hp, bp) + ( + x_xn = x + xn; + v1n = (-Kh*v1 + (bp-hp)*h*x_xn + hsq*((lp - hp) * x_xn - v1) + 2*h*v2 + v1) * normalizing_const; + v2n = (Kh*((bp-hp) * x_xn + v2 - 2.0 * v1)+ (lp-bp)*hsq*x_xn + (lp-bp)*h*x_xn - hsq*v2 + v2) * normalizing_const; + + Kp1 = K + 1.0; + fb = f_g((K + 1)*(hp*x + v1)); + s1_fixed = 2.0*bp*x - hp*x - v1 + v2 + fb; + s2_fixed = - 4.0*bp*x + hp*x - 2.0*(v2 + fb) + v1 + lp*x; + + iter = 0; + while( + iter += 1; + + fb_s1 = Kp1*(hp*xn + v1n); + fb_clipped = f_g(fb_s1); + s1 = s1_fixed - hp*xn - v1n + v2n + fb_clipped; + s2 = s2_fixed + hp*xn + lp*xn + v1n - 2.0 * (v2n + fb_clipped); + + f1 = - v1n + v1 + h * s1; + f2 = - v2n + v2 + h * s2; + + res = abs(f1) + abs(f2); + + a = h * ( Kp1 * f_dg(fb_s1) - 1.0 ) - 1.0; + b = h; + c = h * ( 1.0 - 2.0 * (K + 1.0) * f_dg(fb_s1) ); + d = -2.0 * h - 1.0; + + norm = 1.0 / ( a*d - b*c ); + v1n = v1n - ( d*f1 - b*f2 ) * norm; + v2n = v2n - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter_svf); + ); + + x = xn; + v1 = v1n; + v2 = v2n; + + (v1n + hp * xn) + ); + + function eval_steiner_asym(xn) + global(epsilon, maxiter_svf) + local(res, f1, f2, x_xn, + a, b, c, d, norm, s1, s2, s1_fixed, s2_fixed, + xn, v1n, v2n, iter, + fb, fb_s1, fb_clipped, kp1, + ) + instance(x, v1, v2, h, hsq, K, Kh, normalizing_const, alpha, vref, beta, + lp, hp, bp) + ( + x_xn = x + xn; + v1n = (-Kh*v1 + (bp-hp)*h*x_xn + hsq*((lp - hp) * x_xn - v1) + 2*h*v2 + v1) * normalizing_const; + v2n = (Kh*((bp-hp) * x_xn + v2 - 2.0 * v1)+ (lp-bp)*hsq*x_xn + (lp-bp)*h*x_xn - hsq*v2 + v2) * normalizing_const; + + Kp1 = K + 1.0; + fb = f_g_asym((K + 1)*(hp*x + v1)); + s1_fixed = 2.0*bp*x - hp*x - v1 + v2 + fb; + s2_fixed = - 4.0*bp*x + hp*x - 2.0*(v2 + fb) + v1 + lp*x; + + iter = 0; + while( + iter += 1; + + fb_s1 = Kp1*(hp*xn + v1n); + fb_clipped = f_g_asym(fb_s1); + s1 = s1_fixed - hp*xn - v1n + v2n + fb_clipped; + s2 = s2_fixed + hp*xn + lp*xn + v1n - 2.0 * (v2n + fb_clipped); + + f1 = - v1n + v1 + h * s1; + f2 = - v2n + v2 + h * s2; + + res = abs(f1) + abs(f2); + + a = h * ( Kp1 * f_dg_asym(fb_s1) - 1.0 ) - 1.0; + b = h; + c = h * ( 1.0 - 2.0 * (K + 1.0) * f_dg_asym(fb_s1) ); + d = -2.0 * h - 1.0; + + norm = 1.0 / ( a*d - b*c ); + v1n = v1n - ( d*f1 - b*f2 ) * norm; + v2n = v2n - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter_svf); + ); + + x = xn; + v1 = v1n; + v2 = v2n; + + (v1n + hp * xn) + ); + + function f_g_hyp(s) + local() + global() + instance() + ( + abs(s) > 0.0001 ? s / (1 + abs(0.25 * s)) : 0; +// abs(s) > 0.0001 ? s / (1 + abs(0.375 * s * s)) : 0; + ); + + function f_dg_hyp(s) + local(ss) + global() + instance() + ( + ss = s * s; + abs(s) > 0.0001 ? abs(s) / (0.0625 * ss * abs(s) + 0.5 *ss + abs(s)) : 1 +// (1.0 - ss) / (ss * ss + (ss + ss) + 1) +// ss = s * s; +// (0.375 - 0.140625 * ss) / (0.052734375 * ss * ss + 0.28125 * ss + 0.375) + ); + + function eval_steiner_rav_aggro(xn) + global(epsilon, maxiter_svf, avg_iter) + local(res, f1, f2, x_xn, hp_xn, + a, b, c, d, norm, s1, s2, s1_fixed, s2_fixed, + xn, v1n, v2n, iter, ss1, ss2 + fb, fb_s1, fb_clipped, kp1, + ds1, ds2, nl_st, denom1, denom2, tmp, + ) + instance(x, v1, v2, h, hsq, K, Kh, normalizing_const, alpha, vref, beta, + lp, hp, bp) + ( + x_xn = x + xn; + hp_xn = hp * xn; + + // Linear prediction is so bad for this one that it doesn't help + //v1n = (-Kh*v1 + (bp-hp)*h*x_xn + hsq*((lp - hp) * x_xn - v1) + 2*h*v2 + v1) * normalizing_const; + //v2n = (Kh*((bp-hp) * x_xn + v2 - 2.0 * v1)+ (lp-bp)*hsq*x_xn + (lp-bp)*h*x_xn - hsq*v2 + v2) * normalizing_const; + + Kp1 = K + 1.0; + fb = f_g((K + 1)*(hp*x + v1)); + s1_fixed = 2.0 * bp * x - hp * x - v1 + v2 + fb - hp_xn; + s2_fixed = - 4.0 * bp * x + hp * x - 2.0*(v2 + fb) + v1 + lp*x + hp_xn + lp * xn; + + iter = 0; + + while( + iter += 1; + + // System update + fb_s1 = Kp1 * (hp_xn + v1n); + fb_clipped = f_g(fb_s1); + s1 = s1_fixed - v1n + v2n + fb_clipped; + s2 = s2_fixed + v1n - 2.0 * (v2n + fb_clipped); + + /* Note: Written in this form to reuse the division */ + denom1 = 1 / (abs(s1) * (1.0 + abs(s1))); + denom2 = 1 / (abs(s2) * (1.0 + abs(s2))); + + // Evaluate Jacobian + ds1 = s1 * s1 * denom1 * denom1; + ds2 = s2 * s2 * denom2 * denom2; + + /* State non-linearity */ + s1 = s1 * abs(s1) * denom1; + s2 = s2 * abs(s2) * denom2; + + f1 = - v1n + v1 + h * s1; + f2 = - v2n + v2 + h * s2; + + res = abs(f1) + abs(f2); + + a = h * ( Kp1 * f_dg(fb_s1) - 1.0 ) * ds1 - 1.0; + b = h * ds1; + c = h * ( 1.0 - 2.0 * (K + 1.0) * f_dg(fb_s1) ) * ds2; + d = -2.0 * h * ds2 - 1.0; + + norm = 1.0 / ( a*d - b*c ); + v1n -= ( d*f1 - b*f2 ) * norm; + v2n -= ( a*f2 - c*f1 ) * norm; + + (res > epsilon) && (iter < maxiter_svf); + ); + + avg_iter = 0.99995 * avg_iter + 0.00005 * iter; + + x = xn; + v1 = v1n; + v2 = v2n; + + (v1n + hp * xn) + ); + + function f_g_s(s) + local() + global() + instance() + ( + max(-0.95,min(0.95,s)) + ); + + function f_dg_s(s) + local() + global() + instance() + ( + 0.95 - 0.95 * (abs(s)>0.95) + ); + + function eval_steiner_rav_stacc(xn) + global(epsilon, maxiter_svf, avg_iter) + local(res, f1, f2, x_xn, hp_xn, + a, b, c, d, norm, s1, s2, s1_fixed, s2_fixed, + xn, v1n, v2n, iter, ss1, ss2 + fb, fb_s1, fb_clipped, kp1, + ds1, ds2, nl_st, denom1, denom2, tmp, + ) + instance(x, v1, v2, h, hsq, K, Kh, normalizing_const, alpha, vref, beta, + lp, hp, bp) + ( + x_xn = x + xn; + hp_xn = hp * xn; + + // Linear prediction is so bad for this one that it doesn't help + //v1n = (-Kh*v1 + (bp-hp)*h*x_xn + hsq*((lp - hp) * x_xn - v1) + 2*h*v2 + v1) * normalizing_const; + //v2n = (Kh*((bp-hp) * x_xn + v2 - 2.0 * v1)+ (lp-bp)*hsq*x_xn + (lp-bp)*h*x_xn - hsq*v2 + v2) * normalizing_const; + + Kp1 = K + 1.0; + fb = f_g_s((K + 1)*(hp*x + v1)); + s1_fixed = 2.0 * bp * x - hp * x - v1 + v2 + fb - hp_xn; + s2_fixed = - 4.0 * bp * x + hp * x - 2.0*(v2 + fb) + v1 + lp*x + hp_xn + lp * xn; + + iter = 0; + + while( + iter += 1; + + // System update + fb_s1 = Kp1 * (hp_xn + v1n); + fb_clipped = f_g_s(fb_s1); + s1 = s1_fixed - v1n + v2n + fb_clipped; + s2 = s2_fixed + v1n - 2.0 * (v2n + fb_clipped); + + /* Note: Written in this form to reuse the division */ + denom1 = 1.0 / (s1 * s1 + abs(s1) + 0.25); + denom2 = 1.0 / (s2 * s2 + abs(s2) + 0.25); + + // Evaluate Jacobian + ds1 = (abs(s1) + 0.5) * abs(s1) * denom1 * denom1; + ds2 = (abs(s2) + 0.5) * abs(s2) * denom2 * denom2; + + /* State non-linearity */ + s1 = s1 / (1.0 + abs(s1 + 0.25 / s1)); + s2 = s2 / (1.0 + abs(s2 + 0.25 / s2)); + + f1 = - v1n + v1 + h * s1; + f2 = - v2n + v2 + h * s2; + + res = abs(f1) + abs(f2); + + a = h * ( Kp1 * f_dg_s(fb_s1) - 1.0 ) * ds1 - 1.0; + b = h * ds1; + c = h * ( 1.0 - 2.0 * (K + 1.0) * f_dg_s(fb_s1) ) * ds2; + d = -2.0 * h * ds2 - 1.0; + + norm = 1.0 / ( a*d - b*c ); + v1n -= ( d*f1 - b*f2 ) * norm; + v2n -= ( a*f2 - c*f1 ) * norm; + + (res > epsilon) && (iter < maxiter_svf); + ); + + avg_iter = 0.99995 * avg_iter + 0.00005 * iter; + + x = xn; + v1 = v1n; + v2 = v2n; + + (v1n + hp * xn) + ); + + function eval_steiner_rav(xn) + global(epsilon, maxiter_svf, avg_iter) + local(res, f1, f2, x_xn, hp_xn, + a, b, c, d, norm, s1, s2, s1_fixed, s2_fixed, + xn, v1n, v2n, iter, ss1, ss2 + fb, fb_s1, fb_clipped, kp1, + ds1, ds2, nl_st, denom1, denom2, tmp, + ) + instance(x, v1, v2, h, hsq, K, Kh, normalizing_const, alpha, vref, beta, + lp, hp, bp) + ( + x_xn = x + xn; + hp_xn = hp * xn; + + // Linear prediction is so bad for this one that it doesn't help + //v1n = (-Kh*v1 + (bp-hp)*h*x_xn + hsq*((lp - hp) * x_xn - v1) + 2*h*v2 + v1) * normalizing_const; + //v2n = (Kh*((bp-hp) * x_xn + v2 - 2.0 * v1)+ (lp-bp)*hsq*x_xn + (lp-bp)*h*x_xn - hsq*v2 + v2) * normalizing_const; + + Kp1 = K + 1.0; + fb = f_g_hyp((K + 1)*(hp*x + v1)); + s1_fixed = 2.0 * bp * x - hp * x - v1 + v2 + fb - hp_xn; + s2_fixed = - 4.0 * bp * x + hp * x - 2.0*(v2 + fb) + v1 + lp*x + hp_xn + lp * xn; + + iter = 0; + + while( + iter += 1; + + // System update + fb_s1 = Kp1 * (hp_xn + v1n); + fb_clipped = f_g_hyp(fb_s1); + s1 = s1_fixed - v1n + v2n + fb_clipped; + s2 = s2_fixed + v1n - 2.0 * (v2n + fb_clipped); + + /* Note: Written in this form to reuse the division */ + denom1 = 1 / (abs(s1) * (1.0 + abs(s1))); + denom2 = 1 / (abs(s2) * (1.0 + abs(s2))); + + // Evaluate Jacobian + ds1 = s1 * s1 * denom1 * denom1; + ds2 = s2 * s2 * denom2 * denom2; + + /* State non-linearity */ + s1 = s1 * abs(s1) * denom1; + s2 = s2 * abs(s2) * denom2; + + f1 = - v1n + v1 + h * s1; + f2 = - v2n + v2 + h * s2; + + res = abs(f1) + abs(f2); + + + a = h * ( Kp1 * f_dg_hyp(fb_s1) - 1.0 ) * ds1 - 1.0; + b = h * ds1; + c = h * ( 1.0 - 2.0 * (K + 1.0) * f_dg_hyp(fb_s1) ) * ds2; + d = -2.0 * h * ds2 - 1.0; + + norm = 1.0 / ( a*d - b*c ); + v1n -= ( d*f1 - b*f2 ) * norm; + v2n -= ( a*f2 - c*f1 ) * norm; + + (res > epsilon) && (iter < maxiter_svf); + ); + + avg_iter = 0.99995 * avg_iter + 0.00005 * iter; + + x = xn; + v1 = v1n; + v2 = v2n; + + (v1n + hp * xn) + ); + + function eval_steiner_old(xn) + global(epsilon, maxiter_svf) + local(scaling, res, f1, f2, x_xn, + a, b, c, d, norm, s1, s2 + xn, v1n, v2n, diodev2v1, diodexv2, diodev2nv1n, diodexnv2n, ddiodev2nv1n, ddiodexnv2n, iter) + instance(x, v1, v2, h, hsq, K, Kh, normalizing_const, alpha, vref, beta, + lp, hp, bp) + ( + // First guess based on linear system + // v1n = (-K*h*v1 - hsq*v1 + hsq*x + hsq*xn + 2*h*v2 + v1) * normalizing_const; + // v2n = (-2*K*h*v1 + K*h*v2 - hsq*v2 + hsq*x + hsq*xn + h*x + h*xn + v2) * normalizing_const; + + scaling = 1;//0.005; + xn *= scaling; + + x_xn = x + xn; + v1n = (-Kh*v1 + (bp-hp)*h*x_xn + hsq*((lp - hp) * x_xn - v1) + 2*h*v2 + v1) * normalizing_const; + v2n = (Kh*((bp-hp) * x_xn + v2 - 2.0 * v1)+ (lp-bp)*hsq*x_xn + (lp-bp)*h*x_xn - hsq*v2 + v2) * normalizing_const; + + /* + diodev2v1 = diode(v2 - v1, alpha, vref); + diodexv2 = diode(x - v2, alpha, vref); + + iter = 0; + while( + iter += 1; + + diodev2nv1n = diode(v2n - v1n, alpha, vref); + diodexnv2n = diode(xn - v2n, alpha, vref); + + ddiodev2nv1n = ddiode(v2n - v1n, diodev2nv1n, alpha, vref); + ddiodexnv2n = ddiode(xn - v2n, diodexnv2n, alpha, vref); + + s1 = diodev2nv1n + diodev2v1; + s2 = diodexnv2n + K * diodev2nv1n + diodexv2 + K * diodev2v1; + f1 = v1n - v1 - beta * s1; + f2 = v2n - v2 - beta * s2; + + res = abs(f1) + abs(f2); + + a = 1.0 + beta * ddiodev2nv1n; + b = - beta * ddiodev2nv1n; + c = K * beta * ddiodev2nv1n; + d = 1.0 - beta * ( K * ddiodev2nv1n - ddiodexnv2n); + + norm = 1.0 / ( a*d - b*c ); + v1n = v1n - ( d*f1 - b*f2 ) * norm; + v2n = v2n - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter_svf); + );*/ + + /*v1n = tanh(v1n); + v2n = tanh(v2n);*/ + + + x = xn; + v1 = v1n; + v2 = v2n; + + (1.0 + K) * (v1n + hp * xn) / scaling + ); + + function init_MS20(freq, reso) + global(sampling_factor, isampling_factor, srate) + local(f0) + instance(y1, y2, d1, d2, h, hh, k) + ( + f0 = exp( (1-freq) * log(20/22050) ) * $pi * isampling_factor; + h = tan(f0 / (2.1 * sampling_factor)) * 2.1 * sampling_factor; + hh = 0.5 * h; + k = 2*reso; + ); + + function eval_MS20_nonlin_tanh(x) + global(epsilon, maxiter) + local(iter, res, gd2k, ky2, gky2, dgky2, + f1, f2, a, b, c, d, norm, sig1, thsig1, thsig1sq, sig2, thsig2, thsig2sq, tanhterm1, tanhterm2, hhthsig1sqm1, hhthsig2sqm1 ) + instance(i, y1, y2, d1, d2, h, hh, k, obs) + ( + gd2k = f_g(d2*k); + tanhterm1 = tanh(-d1 + x - gd2k); + tanhterm2 = tanh(d1 - d2 + gd2k); + + iter = 0; + while( + iter += 1; + ky2 = k*y2; + gky2 = f_g(ky2); + dgky2 = f_dg(ky2); + + sig1 = x - y1 - gky2; + thsig1 = tanh(sig1); + thsig1sq = thsig1 * thsig1; + + sig2 = y1 - y2 + gky2; + thsig2 = tanh(sig2); + thsig2sq = thsig2 * thsig2; + hhthsig1sqm1 = hh*(thsig1sq - 1); + hhthsig2sqm1 = hh*(thsig2sq - 1); + + f1 = y1 - d1 - hh*(tanhterm1 + thsig1); + f2 = y2 - d2 - hh*(tanhterm2 + thsig2); + res = abs(f1) + abs(f2); + + a = -hhthsig1sqm1 + 1; + b = -k*hhthsig1sqm1*dgky2; + c = hhthsig2sqm1; + d = (k*dgky2 - 1)*hhthsig2sqm1 + 1; + + norm = 1 / ( a*d - b*c ); + y1 = y1 - ( d*f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter); + ); + + d1 = y1; + d2 = y2; + ); + + + function eval_MS20_nonlinBP_tanh(x) + global(epsilon, maxiter) + local(iter, res, gd2k, ky2, gky2, dgky2, kc, + f1, f2, a, b, c, d, norm, sig1, thsig1, thsig1sq, sig2, thsig2, thsig2sq, tanhterm1, tanhterm2, hhthsig1sqm1, hhthsig2sqm1 ) + instance(i, y1, y2, d1, d2, h, hh, k, obs) + ( + kc = .95*k; + gd2k = f_g(d2*kc); + tanhterm1 = tanh(-d1 - x - gd2k); + tanhterm2 = tanh(d1 - d2 + x + gd2k); + + iter = 0; + while( + iter += 1; + ky2 = kc*y2; + gky2 = f_g(ky2); + dgky2 = f_dg(ky2); + + sig1 = -x - y1 - gky2; + thsig1 = tanh(sig1); + thsig1sq = thsig1 * thsig1; + + sig2 = x + y1 - y2 + gky2; + thsig2 = tanh(sig2); + thsig2sq = thsig2 * thsig2; + + hhthsig1sqm1 = hh*(thsig1sq - 1); + hhthsig2sqm1 = hh*(thsig2sq - 1); + + f1 = y1 - d1 - hh*(tanhterm1 + thsig1); + f2 = y2 - d2 - hh*(tanhterm2 + thsig2); + res = abs(f1) + abs(f2); + + a = 1 - hhthsig1sqm1; + b = -kc*hhthsig1sqm1*dgky2; + c = hhthsig2sqm1; + d = (kc*dgky2 - 1)*hhthsig2sqm1 + 1; + + norm = 1 / ( a*d - b*c ); + y1 = y1 - ( d*f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter); + ); + + d1 = y1; + d2 = y2; + ); + + function eval_MS20_nonlinBR_tanh(x) + global(epsilon, maxiter) + local(iter, res, gd2k, ky2, gky2, dgky2, + f1, f2, a, b, c, d, norm, sig1, thsig1, thsig1sq, sig2, thsig2, thsig2sq, tanhterm1, tanhterm2, hhthsig1sqm1, hhthsig2sqm1 ) + instance(i, y1, y2, d1, d2, h, hh, k, obs) + ( + gd2k = f_g(d2*k); + tanhterm1 = tanh(-d1 - x - gd2k); + tanhterm2 = tanh(d1 - d2 + x + gd2k); + + iter = 0; + while( + iter += 1; + ky2 = k*y2; + gky2 = f_g(ky2); + dgky2 = f_dg(ky2); + + sig1 = -x - y1 - gky2; + thsig1 = tanh(sig1); + thsig1sq = thsig1 * thsig1; + + sig2 = x + y1 - y2 + gky2; + thsig2 = tanh(sig2); + thsig2sq = thsig2 * thsig2; + + hhthsig1sqm1 = hh*(thsig1sq - 1); + hhthsig2sqm1 = hh*(thsig2sq - 1); + + f1 = y1 - d1 - hh*(tanhterm1 + thsig1); + f2 = y2 - d2 - hh*(tanhterm2 + thsig2); + res = abs(f1) + abs(f2); + + a = 1 - hhthsig1sqm1; + b = -k*hhthsig1sqm1*dgky2; + c = hhthsig2sqm1; + d = (k*dgky2 - 1)*hhthsig2sqm1 + 1; + + norm = 1 / ( a*d - b*c ); + y1 = y1 - ( d*f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter); + ); + + d1 = y1; + d2 = y2; + x - y2; + ); + + function eval_MS20_nonlinHP_tanh(x) + global(epsilon, maxiter) + local(iter, res, gkd2px, kxpy2, gkxpy2, dgky2px, kc, + f1, f2, a, b, c, d, norm, sig1, thsig1, thsig1sq, sig2, thsig2, thsig2sq, tanhterm1, tanhterm2, hhthsig1sqm1, hhthsig2sqm1 ) + instance(i, y1, y2, d1, d2, h, hh, k, obs) + ( + kc = .85*k; + gkd2px = f_g(kc*(d2 + x)); + tanhterm1 = tanh(-d1 - gkd2px); + tanhterm2 = tanh(d1 - d2 - x + gkd2px); + + iter = 0; + while( + iter += 1; + kxpy2 = kc*(x + y2); + gkxpy2 = f_g(kxpy2); + dgky2px = f_dg(kxpy2); + + sig1 = -y1 - gkxpy2; + thsig1 = tanh(sig1); + thsig1sq = thsig1 * thsig1; + + sig2 = -x + y1 - y2 + gkxpy2; + thsig2 = tanh(sig2); + thsig2sq = thsig2 * thsig2; + + hhthsig1sqm1 = (thsig1sq - 1); + hhthsig2sqm1 = (thsig2sq - 1); + + f1 = y1 - d1 - hh*(tanhterm1 + thsig1); + f2 = y2 - d2 - hh*(tanhterm2 + thsig2); + res = abs(f1) + abs(f2); + + a = -hhthsig1sqm1 + 1; + b = -kc*hhthsig1sqm1*dgky2px; + c = hhthsig2sqm1; + d = (kc*dgky2px - 1)*hhthsig2sqm1 + 1; + + norm = 1 / ( a*d - b*c ); + y1 = y1 - ( d*f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter); + ); + + d1 = y1; + d2 = y2; + + y2 + x + ); + + function eval_MS20_nonlin_tanh_asym(x) + global(epsilon, maxiter) + local(iter, res, gd2k, ky2, gky2, dgky2, qq, + f1, f2, a, b, c, d, norm, sig1, thsig1, thsig1sq, sig2, thsig2, thsig2sq, tanhterm1, tanhterm2, hhthsig1sqm1, hhthsig2sqm1 ) + instance(i, y1, y2, d1, d2, h, hh, k, obs) + ( + gd2k = f_g_asym(d2*k); + sig1 = -d1 + x - gd2k; + qq = sig1 < 0 ? .6 : 1.0; + sig1 *= qq; + tanhterm1 = tanh(sig1); + tanhterm2 = tanh(d1 - d2 + gd2k); + + iter = 0; + while( + iter += 1; + ky2 = k*y2; + gky2 = f_g_asym(ky2); + dgky2 = f_dg_asym(ky2); + + sig1 = x - y1 - gky2; + qq = sig1 < 0 ? .6 : 1.0; + sig1 *= qq; + thsig1 = tanh(sig1); + thsig1sq = thsig1 * thsig1; + + sig2 = y1 - y2 + gky2; + thsig2 = tanh(sig2); + thsig2sq = thsig2 * thsig2; + hhthsig1sqm1 = hh*(thsig1sq - 1); + hhthsig2sqm1 = hh*(thsig2sq - 1); + + f1 = y1 - d1 - hh*(tanhterm1 + thsig1); + f2 = y2 - d2 - hh*(tanhterm2 + thsig2); + res = abs(f1) + abs(f2); + + a = -qq*hhthsig1sqm1 + 1; + b = -qq*k*hhthsig1sqm1*dgky2; + c = hhthsig2sqm1; + d = (k*dgky2 - 1)*hhthsig2sqm1 + 1; + + norm = 1 / ( a*d - b*c ); + y1 = y1 - ( d*f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter); + ); + + d1 = y1; + d2 = y2; + ); + + + function eval_MS20_nonlinBP_tanh_asym(x) + global(epsilon, maxiter) + local(iter, res, gd2k, ky2, gky2, dgky2, kc, qq, + f1, f2, a, b, c, d, norm, sig1, thsig1, thsig1sq, sig2, thsig2, thsig2sq, tanhterm1, tanhterm2, hhthsig1sqm1, hhthsig2sqm1 ) + instance(i, y1, y2, d1, d2, h, hh, k, obs) + ( + kc = k; + gd2k = f_g_asym(d2*kc); + sig1 = -d1 - x - gd2k; + qq = sig1 < 0 ? .6 : 1.0; + sig1 *= qq; + tanhterm1 = tanh(sig1); + tanhterm2 = tanh(d1 - d2 + x + gd2k); + + iter = 0; + while( + iter += 1; + ky2 = kc*y2; + gky2 = f_g_asym(ky2); + dgky2 = f_dg_asym(ky2); + + sig1 = -x - y1 - gky2; + qq = sig1 < 0 ? .8 : 1.0; + sig1 *= qq; + thsig1 = tanh(sig1); + thsig1sq = thsig1 * thsig1; + + sig2 = x + y1 - y2 + gky2; + thsig2 = tanh(sig2); + thsig2sq = thsig2 * thsig2; + + hhthsig1sqm1 = hh*(thsig1sq - 1); + hhthsig2sqm1 = hh*(thsig2sq - 1); + + f1 = y1 - d1 - hh*(tanhterm1 + thsig1); + f2 = y2 - d2 - hh*(tanhterm2 + thsig2); + res = abs(f1) + abs(f2); + + a = 1 - qq*hhthsig1sqm1; + b = -qq*kc*hhthsig1sqm1*dgky2; + c = hhthsig2sqm1; + d = (kc*dgky2 - 1)*hhthsig2sqm1 + 1; + + norm = 1 / ( a*d - b*c ); + y1 = y1 - ( d*f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter); + ); + + d1 = y1; + d2 = y2; + ); + + function eval_MS20_nonlinBR_tanh_asym(x) + global(epsilon, maxiter) + local(iter, res, gd2k, ky2, gky2, dgky2, + f1, f2, a, b, c, d, norm, sig1, thsig1, thsig1sq, sig2, thsig2, thsig2sq, tanhterm1, tanhterm2, hhthsig1sqm1, hhthsig2sqm1 ) + instance(i, y1, y2, d1, d2, h, hh, k, obs) + ( + gd2k = f_g_asym(d2*k); + tanhterm1 = tanh(-d1 - x - gd2k); + tanhterm2 = tanh(d1 - d2 + x + gd2k); + + iter = 0; + while( + iter += 1; + ky2 = k*y2; + gky2 = f_g_asym(ky2); + dgky2 = f_dg_asym(ky2); + + sig1 = -x - y1 - gky2; + thsig1 = tanh(sig1); + thsig1sq = thsig1 * thsig1; + + sig2 = x + y1 - y2 + gky2; + thsig2 = tanh(sig2); + thsig2sq = thsig2 * thsig2; + + hhthsig1sqm1 = hh*(thsig1sq - 1); + hhthsig2sqm1 = hh*(thsig2sq - 1); + + f1 = y1 - d1 - hh*(tanhterm1 + thsig1); + f2 = y2 - d2 - hh*(tanhterm2 + thsig2); + res = abs(f1) + abs(f2); + + a = 1 - hhthsig1sqm1; + b = -k*hhthsig1sqm1*dgky2; + c = hhthsig2sqm1; + d = (k*dgky2 - 1)*hhthsig2sqm1 + 1; + + norm = 1 / ( a*d - b*c ); + y1 = y1 - ( d*f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter); + ); + + d1 = y1; + d2 = y2; + x - y2; + ); + + function eval_MS20_nonlinHP_tanh_asym(x) + global(epsilon, maxiter) + local(iter, res, gkd2px, kxpy2, gkxpy2, dgky2px, kc, + f1, f2, a, b, c, d, norm, sig1, thsig1, thsig1sq, sig2, thsig2, thsig2sq, tanhterm1, tanhterm2, hhthsig1sqm1, hhthsig2sqm1 ) + instance(i, y1, y2, d1, d2, h, hh, k, obs) + ( + kc = k; + gkd2px = f_g_asym(kc*(d2 + x)); + tanhterm1 = tanh(-d1 - gkd2px); + tanhterm2 = tanh(d1 - d2 - x + gkd2px); + + iter = 0; + while( + iter += 1; + kxpy2 = kc*(x + y2); + gkxpy2 = f_g_asym(kxpy2); + dgky2px = f_dg_asym(kxpy2); + + sig1 = -y1 - gkxpy2; + thsig1 = tanh(sig1); + thsig1sq = thsig1 * thsig1; + + sig2 = -x + y1 - y2 + gkxpy2; + thsig2 = tanh(sig2); + thsig2sq = thsig2 * thsig2; + + hhthsig1sqm1 = (thsig1sq - 1); + hhthsig2sqm1 = (thsig2sq - 1); + + f1 = y1 - d1 - hh*(tanhterm1 + thsig1); + f2 = y2 - d2 - hh*(tanhterm2 + thsig2); + res = abs(f1) + abs(f2); + + a = -hhthsig1sqm1 + 1; + b = -kc*hhthsig1sqm1*dgky2px; + c = hhthsig2sqm1; + d = (kc*dgky2px - 1)*hhthsig2sqm1 + 1; + + norm = 1.0 / ( a*d - b*c ); + y1 = y1 - ( d*f1 - b*f2 ) * norm; + y2 = y2 - ( a*f2 - c*f1 ) * norm; + (res > epsilon) && (iter < maxiter); + ); + + d1 = y1; + d2 = y2; + + y2 + x + ); + + function processSample_ms20(s, choice) + local() + instance(BP, HP, BR, LP) + global() + ( + (choice == 1) ? ( + BP.eval_MS20_nonlinBP_tanh(s) + ) : (choice == 2) ? ( + HP.eval_MS20_nonlinHP_tanh(s) + ) : (choice == 3) ? ( + BR.eval_MS20_nonlinBR_tanh(s) + ) : ( + // LP is last and first + LP.eval_MS20_nonlin_tanh(s) + ); + ); + + function processSample_ms20_asym(s, choice) + local() + instance(BP, HP, BR, LP) + global() + ( + (choice == 1) ? ( + BP.eval_MS20_nonlinBP_tanh_asym(s) + ) : (choice == 2) ? ( + HP.eval_MS20_nonlinHP_tanh_asym(s) + ) : (choice == 3) ? ( + BR.eval_MS20_nonlinBR_tanh_asym(s) + ) : ( + // LP is last and first + LP.eval_MS20_nonlin_tanh_asym(s) + ); + ); + + function processSample_broken(s, choice) + local() + instance(BP, HP, BR, LP) + global() + ( + (choice == 1) ? ( + BP.eval_MS20_nonlinBP_tanh_asym(s) + ) : (choice == 2) ? ( + HP.eval_MS20_nonlinHP_tanh_asym(s) + ) : (choice == 3) ? ( + BR.eval_MS20_nonlinBR_tanh_asym(s) + ) : ( + // LP is last and first + LP.eval_MS20_nonlin_tanh_asym(s) + ); + ); + +function init_rectpeak(freq, res, morph) + global() + local(lhf) + instance(svf_res, svf_res2, svf_none, svf_overall) + ( + lhf = cl01(freq + log(2) / (log(20/22050)) ); + svf_res.init_linearSVF_all(lhf, clamp(res, 0, .92), morph); + + //svf_res2.init_linearSVF_all(lhf, clamp(res, 0, .92), morph); + //svf_none.init_linearSVF_all(lhf, clamp(res, 0, .92), morph); + svf_none.a1 = svf_res2.a1 = svf_res.a1; + svf_none.a2 = svf_res2.a2 = svf_res.a2; + svf_none.a3 = svf_res2.a3 = svf_res.a3; + svf_none.k = svf_res2.k = svf_res.k; + svf_none.m0 = svf_res2.m0 = svf_res.m0; + svf_none.m1 = svf_res2.m1 = svf_res.m1; + svf_none.m2 = svf_res2.m2 = svf_res.m2; + + svf_overall.init_linearSVF_all(freq, 0, morph); + ); + +function eval_rectpeak(x0) + global() + local(resonance, base, peak) + instance(svf_res, svf_res2, svf_none, svf_overall) + ( + base = svf_none.eval_linearSVF_All(x0); + peak = svf_res2.eval_linearSVF_All(svf_res.eval_linearSVF_All(x0)); + + svf_overall.eval_linearSVF_All(base + tanh(abs(peak - base))) + ); + +function init_momo(freq, res) + global() + local() + instance(svf_res, svf_none, svf_peak) + ( + svf_res.init_linearSVF(freq, clamp(res, 0, .9)); + svf_none.init_linearSVF(freq, 0); + svf_peak.init_linearSVF(cl01(freq + log(4) / (log(20/22050)) ), .5 + res*.4); + ); + +function init_dualpeak(freq, res, morph) + global() + local(h, r) + instance(svf_base, svf_no_base, svf_no_peak, svf_two, mo1, mo2, mo3) + ( + h = cl01(freq - log(4) / (log(20/22050))); + svf_no_base.init_linearSVF(freq, 0); + svf_no_peak.init_linearSVF(h, 0); + + // Optimization: Avoid tans by not doing full function call for same frequencies + //svf_base.init_linearSVF(freq, .95*res); + //svf_two.init_linearSVF(h, .95*res); + + r = 2 - 2 * .98 * res; + svf_base.k = r; + svf_base.a1 = 1.0/(1.0+svf_no_base.g*(svf_no_base.g+r)); + svf_base.a2 = svf_no_base.g*svf_base.a1; + svf_base.a3 = svf_no_base.g*svf_base.a2; + + svf_two.k = r; + svf_two.a1 = 1.0/(1.0+svf_no_peak.g*(svf_no_peak.g+r)); + svf_two.a2 = svf_no_peak.g*svf_two.a1; + svf_two.a3 = svf_no_peak.g*svf_two.a2; + + morph < 0.25 ? ( + mo1 = morph * 4; + mo2 = 0; + mo3 = 0; + ) : ( morph < 0.5 ) ? ( + mo1 = 1; + mo2 = (morph - 0.25) * 4; + mo3 = 0; + ) : ( morph < 0.75 ) ? ( + mo1 = 1.0; + mo2 = 1.0 - (morph - 0.5) * 4; + mo3 = (morph - 0.5) * 4; + ) : ( + mo1 = 1 - (morph - 0.75) * 4; + mo2 = 0; + mo3 = 1 - (morph - 0.75) * 4; + ); + ); + +function init_triple_peak(freq, res, morph) + global() + local(m, h, r) + instance(svf_no_low, svf_no_mid, svf_no_high, svf_low, svf_mid, svf_high, mo1, mo2, mo3) + ( + h = cl01(freq - log(4) / (log(20/22050)) ); + m = cl01(freq - log(2) / (log(20/22050)) ); + svf_no_low.init_linearSVF(freq, 0); + svf_no_mid.init_linearSVF(m, 0); + svf_no_high.init_linearSVF(h, 0); + + //res *= .97; + //svf_low.init_linearSVF(freq, res); + //svf_mid.init_linearSVF(m, res); + //svf_high.init_linearSVF(h, res); + + // Optimization: Avoid tans by not doing full function call for same frequencies + r = 2.0 - 2.0 * .98 * res; + svf_low.k = r; + svf_low.a1 = 1.0/(1.0+svf_no_low.g*(svf_no_low.g+svf_low.k)); + svf_low.a2 = svf_no_low.g * svf_low.a1; + svf_low.a3 = svf_no_low.g * svf_low.a2; + + svf_mid.k = r; + svf_mid.a1 = 1.0/(1.0+svf_no_mid.g*(svf_no_mid.g+svf_mid.k)); + svf_mid.a2 = svf_no_mid.g * svf_mid.a1; + svf_mid.a3 = svf_no_mid.g * svf_mid.a2; + + svf_high.k = r; + svf_high.a1 = 1.0/(1.0+svf_no_high.g*(svf_no_high.g+svf_high.k)); + svf_high.a2 = svf_no_high.g * svf_high.a1; + svf_high.a3 = svf_no_high.g * svf_high.a2; + + morph < 0.25 ? ( + mo1 = morph * 4; + mo2 = 0; + mo3 = 0; + ) : ( morph < 0.5 ) ? ( + mo1 = 1; + mo2 = (morph - 0.25) * 4; + mo3 = 0; + ) : ( morph < 0.75 ) ? ( + mo1 = 1.0; + mo2 = 1.0 - (morph - 0.5) * 4; + mo3 = (morph - 0.5) * 4; + ) : ( + mo1 = 1 - (morph - 0.75) * 4; + mo2 = 0; + mo3 = 1 - (morph - 0.75) * 4; + ); + ); + +function eval_momo(x0) + global() + local(base, peak, bp) + instance(svf_res, svf_none, svf_peak) + ( + peak = svf_res.eval_linearSVF_LP(x0); + base = svf_none.eval_linearSVF_LP(x0); + peak -= base; + peak = expensive_tanh(peak); + base = expensive_tanh(base); + bp = expensive_tanh(svf_peak.eval_linearSVF_BP(base)); + expensive_tanh(base + peak + bp) + ); + +function eval_dualpeak(x0) + global() + local(base, s) + instance(svf_base, svf_no_base, svf_no_peak, svf_two, mo1, mo2, mo3) + ( + base = mo3 * x0 + svf_no_peak.eval_linearSVF_LPHP(svf_no_base.eval_linearSVF_LPHP(x0, mo1), mo2); + s = mo3 * x0 + svf_two.eval_linearSVF_LPHP(svf_base.eval_linearSVF_LPHP(x0, mo1), mo2); + base + expensive_tanh((s - base)) + ); + +function eval_triple_peak(x0) + global() + local(base, s) + instance(svf_no_low, svf_no_mid, svf_no_high, svf_low, svf_mid, svf_high, mo1, mo2, mo3) + ( + base = mo3 * x0 + svf_no_mid.eval_linearSVF_BR(svf_no_high.eval_linearSVF_LPHP(svf_no_low.eval_linearSVF_LPHP(x0, mo1), mo2)); + s = mo3 * x0 + svf_mid.eval_linearSVF_BR(svf_high.eval_linearSVF_LPHP(svf_low.eval_linearSVF_LPHP(x0, mo1), mo2)); + base + expensive_tanh(s - base) + ); + +function init_duoreso(cutoff, reso, morph) +local(f0) +instance( + T, Tsq, Tbw, T2, k, bw, denom, + ybp1d, ybp1, y1d, y1, + ybp2d, ybp2, y2d, y2, + ybp3d, ybp3, y3d, y3, + ybp4d, ybp4, y4d, y4, +) +global(isampling_factor) +( + f0 = exp( (1.0 - cutoff) * log(20/22050) ) * isampling_factor; + T = tan(0.5 * $pi * f0); + T2 = T + T; + Tsq = T * T; + Tbw = T * bw; + denom = 1.0 / (Tsq + T*bw + 1.0); + //k = .999 - reso + .01; + k = reso; + + bw = 1.0 - morph; +); + +function eval_duoreso(x) +local() +instance( + T, Tsq, T2, Tbw, k, bw, denom, + ybp1d, ybp1, y1d, y1, + ybp2d, ybp2, y2d, y2, + ybp3d, ybp3, y3d, y3, + ybp4d, ybp4, y4d, y4, +) +global() +( + ybp1 = (-Tsq * ybp1d + Tbw * (2 * x + tanh(- 64 * k * ybp4)) - Tbw * ybp1d - T2 * y1d + ybp1d) * denom; + y1 = y1d + T * (ybp1 + ybp1d); + ybp1d = ybp1; y1d = y1; + + ybp2 = (-Tsq * ybp2d + Tbw * ybp1 - Tbw * ybp2d - T2 * y2d + ybp2d) * denom; + y2 = y2d + T * (ybp2 + ybp2d); + ybp2d = ybp2; y2d = y2; + + ybp3 = (-Tsq * ybp3d + Tbw * ybp2 - Tbw * ybp3d - T2 * y3d + ybp3d) * denom; + y3 = y3d + T * (ybp3 + ybp3d); + ybp3d = ybp3; y3d = y3; + + ybp4 = (-Tsq * ybp4d + Tbw * ybp3 - Tbw * ybp4d - T2 * y4d + ybp4d) * denom; + y4 = y4d + T * (ybp4 + ybp4d); + ybp4d = ybp4; y4d = y4; + + ybp4 * 64 +); + +function init_filter(filter_type, sliderCutoffL, sliderCutoffR, sliderMorphL, sliderMorphR, sliderReso) +local() +instance( + L, R, L2, R2, + filter_choiceL, frac_morphL, i_morphL, + filter_choiceR, frac_morphR, i_morphR, +) +global(oversampling, safety_limit_pir, safety_limit_ms20, safety_limit_moog, current_safety_moog, safety_limit_svf, safety_limit_svf2, safety_limit_resa) +( + (filter_type < 10) ?( + filter_type == 0 ? ( + L.init_linearSVF_all(sliderCutoffL, sliderReso, sliderMorphL); + R.init_linearSVF_all(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 1 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_ms20 ? safety_limit_ms20 : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_ms20 ? safety_limit_ms20 : sliderCutoffR; + ); + + L.LP.init_MS20(sliderCutoffL, sliderReso); + L.HP.hh = L.BR.hh = L.BP.hh = L.LP.hh; + L.HP.h = L.BR.h = L.BP.h = L.LP.h; + L.HP.k = L.BR.k = L.BP.k = L.LP.k; + + R.LP.init_MS20(sliderCutoffR, sliderReso); + R.HP.hh = R.BR.hh = R.BP.hh = R.LP.hh; + R.HP.h = R.BR.h = R.BP.h = R.LP.h; + R.HP.k = R.BR.k = R.BP.k = R.LP.k; + ) : ( filter_type == 2 ) ? ( + L.init_linearSVF_all(sliderCutoffL, sliderReso, sliderMorphL); + R.init_linearSVF_all(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 3 ) ? ( + sliderCutoffL = sliderCutoffL > current_safety_moog ? current_safety_moog : sliderCutoffL; + sliderCutoffR = sliderCutoffR > current_safety_moog ? current_safety_moog : sliderCutoffR; + + L.moog.init_moog(sliderCutoffL, sliderReso); + R.moog.init_moog(sliderCutoffR, sliderReso); + ) : ( filter_type == 4 ) ? ( + sliderCutoffL = sliderCutoffL > current_safety_moog ? current_safety_moog : sliderCutoffL; + sliderCutoffR = sliderCutoffR > current_safety_moog ? current_safety_moog : sliderCutoffR; + + L.moog2.init_moog2(sliderCutoffL, sliderReso); + R.moog2.init_moog2(sliderCutoffR, sliderReso); + ) : ( filter_type == 5 ) ? ( + L.b303.init_303(sliderCutoffL, sliderReso); + R.b303.init_303(sliderCutoffR, sliderReso); + ) : ( filter_type == 6 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_ms20 ? safety_limit_ms20 : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_ms20 ? safety_limit_ms20 : sliderCutoffR; + ); + + L.LP.init_MS20(sliderCutoffL, sliderReso); + L.HP.hh = L.BR.hh = L.BP.hh = L.LP.hh; + L.HP.h = L.BR.h = L.BP.h = L.LP.h; + L.HP.k = L.BR.k = L.BP.k = L.LP.k; + + R.LP.init_MS20(sliderCutoffR, sliderReso); + R.HP.hh = R.BR.hh = R.BP.hh = R.LP.hh; + R.HP.h = R.BR.h = R.BP.h = R.LP.h; + R.HP.k = R.BR.k = R.BP.k = R.LP.k; + ) : ( filter_type == 7 ) ? ( + L.init_momo(sliderCutoffL, sliderReso); + R.init_momo(sliderCutoffR, sliderReso); + ) : ( filter_type == 8 ) ? ( + L.init_dualpeak(sliderCutoffL, sliderReso, sliderMorphL); + R.init_dualpeak(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 9 ) ? ( + L.init_triple_peak(sliderCutoffL, sliderReso, sliderMorphL); + R.init_triple_peak(sliderCutoffR, sliderReso, sliderMorphR); + ); + ) : ( + ( filter_type == 10 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_svf ? safety_limit_svf : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_svf ? safety_limit_svf : sliderCutoffR; + ); + L.init_SVF_nonlin(sliderCutoffL, sliderReso, sliderMorphL); + R.init_SVF_nonlin(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 11 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_svf ? safety_limit_svf : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_svf ? safety_limit_svf : sliderCutoffR; + ); + L.init_SVF_nonlin(sliderCutoffL, sliderReso, sliderMorphL); + R.init_SVF_nonlin(sliderCutoffR, sliderReso, sliderMorphR); + L2.init_SVF_nonlin(sliderCutoffL, sliderReso, sliderMorphL); + R2.init_SVF_nonlin(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 12 ) ? ( + L.init_SVF_nonlin(sliderCutoffL, sliderReso, sliderMorphL); + R.init_SVF_nonlin(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 13 ) ? ( + L.init_SVF_nonlin(sliderCutoffL, sliderReso, sliderMorphL); + R.init_SVF_nonlin(sliderCutoffR, sliderReso, sliderMorphR); + L2.init_SVF_nonlin(sliderCutoffL, sliderReso, sliderMorphL); + R2.init_SVF_nonlin(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 14 ) ? ( + L.init_rectpeak(sliderCutoffL, sliderReso, sliderMorphL); + R.init_rectpeak(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 15 ) ? ( + L.init_steiner(sliderCutoffL, sliderReso, sliderMorphL); + R.init_steiner(sliderCutoffR, sliderReso, sliderMorphL); + ) : ( filter_type == 16 ) ? ( + L.init_steiner(sliderCutoffL, sliderReso, sliderMorphL); + R.init_steiner(sliderCutoffR, sliderReso, sliderMorphL); + ) : ( filter_type == 17 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_svf2 ? safety_limit_svf2 : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_svf2 ? safety_limit_svf2 : sliderCutoffR; + ); + sliderReso *= .975; + L2.init_linearSVF_all(sliderCutoffL, sliderReso, sliderMorphL); + R2.init_linearSVF_all(sliderCutoffR, sliderReso, sliderMorphR); + L.init_SVF_nonlin(sliderCutoffL, sliderReso, sliderMorphL); + R.init_SVF_nonlin(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 18 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_resa ? safety_limit_resa : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_resa ? safety_limit_resa : sliderCutoffR; + ); + + L.init_steiner(sliderCutoffL, sliderReso / 2, sliderMorphL); + R.init_steiner(sliderCutoffR, sliderReso / 2, sliderMorphL); + ) : ( filter_type == 19 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_resa ? safety_limit_resa : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_resa ? safety_limit_resa : sliderCutoffR; + ); + + L.init_steiner(sliderCutoffL, sliderReso / 2, sliderMorphL); + R.init_steiner(sliderCutoffR, sliderReso / 2, sliderMorphL); + L2.init_steiner(sliderCutoffL * (0.93 + 0.07 * sliderCutoffL), sliderReso / 2, sliderMorphL); + R2.init_steiner(sliderCutoffR * (0.93 + 0.07 * sliderCutoffR), sliderReso / 2, sliderMorphL); + ) : ( filter_type == 20 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_resa ? safety_limit_resa : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_resa ? safety_limit_resa : sliderCutoffR; + ); + + L.init_steiner(sliderCutoffL, sliderReso / 2, sliderMorphL); + R.init_steiner(sliderCutoffR, sliderReso / 2, sliderMorphL); + ) : ( filter_type == 21 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_resa ? safety_limit_resa : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_resa ? safety_limit_resa : sliderCutoffR; + ); + + L.init_steiner(sliderCutoffL, sliderReso / 2, sliderMorphL); + R.init_steiner(sliderCutoffR, sliderReso / 2, sliderMorphL); + L2.init_steiner(sliderCutoffL * (0.93 + 0.07 * sliderCutoffL), sliderReso / 2, sliderMorphL); + R2.init_steiner(sliderCutoffR * (0.93 + 0.07 * sliderCutoffR), sliderReso / 2, sliderMorphL); + ) : ( filter_type == 22 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_resa ? safety_limit_resa : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_resa ? safety_limit_resa : sliderCutoffR; + ); + + L.init_steiner(sliderCutoffL, sliderReso / 2, sliderMorphL); + R.init_steiner(sliderCutoffR, sliderReso / 2, sliderMorphL); + ) : ( filter_type == 23 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_resa ? safety_limit_resa : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_resa ? safety_limit_resa : sliderCutoffR; + ); + + L.init_steiner(sliderCutoffL, sliderReso / 2, sliderMorphL); + R.init_steiner(sliderCutoffR, sliderReso / 2, sliderMorphL); + L2.init_steiner(sliderCutoffL * (0.93 + 0.07 * sliderCutoffL), sliderReso / 2, sliderMorphL); + R2.init_steiner(sliderCutoffR * (0.93 + 0.07 * sliderCutoffR), sliderReso / 2, sliderMorphL); + ) : ( filter_type == 24 ) ? ( + sliderCutoffL = sliderCutoffL > current_safety_moog ? current_safety_moog : sliderCutoffL; + sliderCutoffR = sliderCutoffR > current_safety_moog ? current_safety_moog : sliderCutoffR; + + L.moog3.init_moog3(sliderCutoffL, sliderReso); + R.moog3.init_moog3(sliderCutoffR, sliderReso); + ) : ( filter_type == 25 ) ? ( + sliderCutoffL = sliderCutoffL > current_safety_moog ? current_safety_moog : sliderCutoffL; + sliderCutoffR = sliderCutoffR > current_safety_moog ? current_safety_moog : sliderCutoffR; + + L.moog6.init_moog6(sliderCutoffL, sliderReso); + R.moog6.init_moog6(sliderCutoffR, sliderReso); + ) : ( filter_type == 26 ) ? ( + (oversampling == 1) ? ( + sliderCutoffL = sliderCutoffL > safety_limit_pir ? safety_limit_pir : sliderCutoffL; + sliderCutoffR = sliderCutoffR > safety_limit_pir ? safety_limit_pir : sliderCutoffR; + ); + L.hla.init_1p_tpt_based(sliderCutoffL, sliderReso); + R.hla.init_1p_tpt_based(sliderCutoffR, sliderReso); + ) : ( filter_type == 27 ) ? ( + L.init_svf2(sliderCutoffL, sliderReso, sliderMorphL); + R.init_svf2(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 28 ) ? ( + L.init_svf2(sliderCutoffL, 0, sliderMorphL); + R.init_svf2(sliderCutoffR, 0, sliderMorphR); + L2.init_svf2(sliderCutoffL, sliderReso, sliderMorphL); + R2.init_svf2(sliderCutoffR, sliderReso, sliderMorphR); + ) : ( filter_type == 29 ) ? ( + L.duo.init_duoreso(sliderCutoffL, sliderReso, sliderMorphL); + R.duo.init_duoreso(sliderCutoffR, sliderReso, sliderMorphR); + ); + ); + + filter_choiceL = floor(sliderMorphL*4); + frac_morphL = sliderMorphL*4 - filter_choiceL; + i_morphL = 1.0 - frac_morphL; + + filter_choiceR = floor(sliderMorphR*4); + frac_morphR = sliderMorphR*4 - filter_choiceR; + i_morphR = 1.0 - frac_morphR; +); + +function processSample(filter_type) +local(csl, csr) +instance( + L, R, L2, R2, + filter_choiceL, frac_morphL, i_morphL, + filter_choiceR, frac_morphR, i_morphR, +) +global(ssl, ssr, epsilon) +( + (filter_type < 10) ? + ( + filter_type == 0 ? ( + ssl = L.eval_linearSVF_All(ssl); + ssr = R.eval_linearSVF_All(ssr); + ) : ( filter_type == 1 ) ? ( + csl = ssl; + csr = ssr; + ssl = L.processSample_ms20(csl, filter_choiceL) * i_morphL; + ssr = R.processSample_ms20(csr, filter_choiceR) * i_morphR; + frac_morphL > epsilon ? ssl += L.processSample_ms20(csl, filter_choiceL + 1) * frac_morphL; + frac_morphL > epsilon ? ssr += R.processSample_ms20(csr, filter_choiceR + 1) * frac_morphR; + ) : ( filter_type == 2 ) ? ( + ssl = L.eval_linearSVF_All4p(ssl); + ssr = R.eval_linearSVF_All4p(ssr); + ) : ( filter_type == 3 ) ? ( + ssl = L.moog.mix_moog(ssl, filter_choiceL, frac_morphL); + ssr = R.moog.mix_moog(ssr, filter_choiceR, frac_morphR); + ) : ( filter_type == 4 ) ? ( + ssl = L.moog2.mix_moog2(ssl, filter_choiceL, frac_morphL); + ssr = R.moog2.mix_moog2(ssr, filter_choiceR, frac_morphR); + ) : ( filter_type == 5 ) ? ( + ssl = L.b303.eval_303(ssl, filter_choiceL, frac_morphL); + ssr = R.b303.eval_303(ssr, filter_choiceR, frac_morphR); + ) : ( filter_type == 6 ) ? ( + csl = ssl; + csr = ssr; + ssl = L.processSample_ms20_asym(csl, filter_choiceL) * i_morphL; + ssr = R.processSample_ms20_asym(csr, filter_choiceR) * i_morphR; + frac_morphL > epsilon ? ssl += L.processSample_ms20_asym(csl, filter_choiceL + 1) * frac_morphL; + frac_morphR > epsilon ? ssr += R.processSample_ms20_asym(csr, filter_choiceR + 1) * frac_morphR; + ) : ( filter_type == 7 ) ? ( + ssl = L.eval_momo(ssl); + ssr = R.eval_momo(ssr); + ) : ( filter_type == 8 ) ? ( + ssl = L.eval_dualpeak(ssl); + ssr = R.eval_dualpeak(ssr); + ) : ( + ssl = L.eval_triple_peak(ssl); + ssr = R.eval_triple_peak(ssr); + ); + ) : ( + (filter_type < 15) ? ( + ( filter_type == 10 ) ? ( + ssl = L.eval_svf_nonlin(ssl); + ssr = R.eval_svf_nonlin(ssr); + ) : ( filter_type == 11 ) ? ( + ssl = L2.eval_svf_nonlin(L.eval_svf_nonlin(ssl)); + ssr = R2.eval_svf_nonlin(R.eval_svf_nonlin(ssr)); + ) : ( filter_type == 12 ) ? ( + ssl = L.eval_svf_nonlin_incorrect(ssl); + ssr = R.eval_svf_nonlin_incorrect(ssr); + ) : ( filter_type == 13 ) ? ( + ssl = L2.eval_svf_nonlin_incorrect(L.eval_svf_nonlin_incorrect(ssl)); + ssr = R2.eval_svf_nonlin_incorrect(R.eval_svf_nonlin_incorrect(ssr)); + ) : ( filter_type == 14 ) ? ( + ssl = L.eval_rectpeak(ssl); + ssr = R.eval_rectpeak(ssr); + ); + ) : ( + ( filter_type == 15 ) ? ( + ssl = L.eval_steiner(ssl); + ssr = R.eval_steiner(ssr); + ) : ( filter_type == 16 ) ? ( + ssl = L.eval_steiner_asym(ssl); + ssr = R.eval_steiner_asym(ssr); + ) : ( filter_type == 17 ) ? ( + ssl = L.eval_SVF_nonlin_broken(L2.eval_linearSVF_All(ssl)); + ssr = R.eval_SVF_nonlin_broken(R2.eval_linearSVF_All(ssr)); + ) : ( filter_type == 18 ) ? ( + ssl = L.eval_steiner_rav(ssl); + ssr = R.eval_steiner_rav(ssr); + ) : ( filter_type == 19 ) ? ( + ssl = L2.eval_steiner_rav(L.eval_steiner_rav(ssl)); + ssr = R2.eval_steiner_rav(R.eval_steiner_rav(ssr)); + ) : ( filter_type == 20 ) ? ( + ssl = L.eval_steiner_rav_aggro(ssl); + ssr = R.eval_steiner_rav_aggro(ssr); + ) : ( filter_type == 21 ) ? ( + ssl = L2.eval_steiner_rav_aggro(L.eval_steiner_rav_aggro(ssl)); + ssr = R2.eval_steiner_rav_aggro(R.eval_steiner_rav_aggro(ssr)); + ) : ( filter_type == 22 ) ? ( + ssl = L.eval_steiner_rav_stacc(ssl); + ssr = R.eval_steiner_rav_stacc(ssr); + ) : ( filter_type == 23 ) ? ( + ssl = L2.eval_steiner_rav_stacc(L.eval_steiner_rav_stacc(ssl)); + ssr = R2.eval_steiner_rav_stacc(R.eval_steiner_rav_stacc(ssr)); + ) : ( filter_type == 24 ) ? ( + ssl = L.moog3.mix_moog3(ssl, filter_choiceL, frac_morphL); + ssr = R.moog3.mix_moog3(ssr, filter_choiceR, frac_morphR); + ) : ( filter_type == 25 ) ? ( + ssl = L.moog6.mix_moog6(ssl, filter_choiceL, frac_morphL); + ssr = R.moog6.mix_moog6(ssr, filter_choiceR, frac_morphR); + ) : ( filter_type == 26 ) ? ( + ssl = L.hla.eval_1p_tpt_based(ssl, filter_choiceL, frac_morphL); + ssr = R.hla.eval_1p_tpt_based(ssr, filter_choiceL, frac_morphL); + ) : ( filter_type == 27 ) ? ( + ssl = L.eval_svf2(ssl); + ssr = R.eval_svf2(ssr); + ) : ( filter_type == 28 ) ? ( + ssl = L2.eval_svf2b(L.eval_svf2(ssl)); + ssr = R2.eval_svf2b(R.eval_svf2(ssr)); + ) : ( filter_type == 29 ) ? ( + ssl = L.duo.eval_duoreso(ssl); + ssr = R.duo.eval_duoreso(ssr); + ); + ); + ); +); + + +function quick_ellip(x) +local() +instance(y, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16) +global() +( + // Elliptical filter at 0.25 + y = 0.03974403712835188 * x + s1; + s1 = 0.11443117839583584 * x - -1.2209793606380654 * y + s2; + s2 = 0.4102732984609602 * x - 6.918940386446262 * y + s3; + s3 = 0.8255281436307241 * x - -7.438409047076798 * y + s4; + s4 = 1.6689828207164152 * x - 20.47654014058037 * y + s5; + s5 = 2.5256753272317622 * x - -19.21733444638215 * y + s6; + s6 = 3.6193770241123127 * x - 33.69411950162771 * y + s7; + s7 = 4.250403515943048 * x - -27.235417392156258 * y + s8; + s8 = 4.641846929462009 * x - 33.46680351213294 * y + s9; + s9 = 4.25040351594302 * x - -22.8021725145997 * y + s10; + s10 = 3.6193770241123016 * x - 20.29444701618275 * y + s11; + s11 = 2.525675327231766 * x - -11.231790923026374 * y + s12; + s12 = 1.6689828207164181 * x - 7.173357397659418 * y + s13; + s13 = 0.8255281436307251 * x - -2.9956603900306376 * y + s14; + s14 = 0.41027329846095995 * x - 1.2866484319363045 * y + s15; + s15 = 0.11443117839583594 * x - -0.3305293493933626 * y + s16; + s16 = 0.0397440371283519 * x - 0.07745428581611816 * y; + + y +); + +function init_cheapest_freq_shifter(shift) +instance(osc_coeff_t1, osc_coeff_t2, + cos_t1_1, cos_t1_2, sin_t1_1, sin_t1_2, + cos_t2_1, cos_t2_2, sin_t2_1, sin_t2_2, + t1, t2, dt1, dt2) +local(ip, piblock, ipiblock, w) +global(srate) +( + piblock = 628.318530718;// 200 * $pi; + ipiblock = 0.00159154943; + + + //dt1 = 2.0 * $pi * 0.251; // oscillating at srate / 4 + dt1 = 2.0 * $pi * 0.25; // oscillating at srate / 4 + dt2 = dt1 + 2.0 * $pi * shift / srate; + + (abs(t1) > piblock) ? t1 -= floor(t1 * ipiblock) * piblock; + (abs(t2) > piblock) ? t2 -= floor(t2 * ipiblock) * piblock; + + w = dt1; + osc_coeff_t1 = 2.0 * cos(w); + t1 += dt1; + cos_t1_1 = sin(- w + t1); + cos_t1_2 = sin(- 2.0*w + t1); + sin_t1_1 = - cos(- w + t1); + sin_t1_2 = - cos(- 2.0*w + t1); + t1 -= dt1; + + w = dt2; + osc_coeff_t2 = 2.0 * cos(w); + t2 += dt2; + cos_t2_1 = sin(- w + t2); + cos_t2_2 = sin(- 2.0 * w + t2); + sin_t2_1 = - cos(- w + t2); + sin_t2_2 = - cos(- 2.0 * w + t2); + t2 -= dt2; +); + + +function eval_cheapest_freq_shifter(v0) +instance( + osc_coeff_t1, osc_coeff_t2, + l1, l2, + dt1, dt2, + t1, t2, + cos_t1_1, cos_t1_2, sin_t1_1, sin_t1_2, + cos_t2_1, cos_t2_2, sin_t2_1, sin_t2_2, +) +local(ct1, st1, ct2, st2) +global() +( + t1 += dt1; + t2 += dt2; + + ct1 = osc_coeff_t1 * cos_t1_1 - cos_t1_2; + cos_t1_2 = cos_t1_1; + cos_t1_1 = ct1; + + ct2 = osc_coeff_t2 * cos_t2_1 - cos_t2_2; + cos_t2_2 = cos_t2_1; + cos_t2_1 = ct2; + + st1 = osc_coeff_t1 * sin_t1_1 - sin_t1_2; + sin_t1_2 = sin_t1_1; + sin_t1_1 = st1; + + st2 = osc_coeff_t2 * sin_t2_1 - sin_t2_2; + sin_t2_2 = sin_t2_1; + sin_t2_1 = st2; + + l1.quick_ellip(v0 * ct1) * ct2 + l2.quick_ellip(v0 * st1) * st2; +); + +function allpass32(y0, m, m_last, sat) +local( + x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9, x10, y10, x11, y11, x12, y12, x13, y13, x14, y14, x15, y15, x16, y16, x17, y17, x18, y18, x19, y19, x20, y20, x21, y21, x22, y22, x23, y23, x24, y24, x25, y25, x26, y26, x27, y27, x28, y28, x29, y29, x30, y30, x31, y31, x32, y32, +) +instance( + x1_last, y1_last, x2_last, y2_last, x3_last, y3_last, x4_last, y4_last, x5_last, y5_last, x6_last, y6_last, x7_last, y7_last, x8_last, y8_last, x9_last, y9_last, x10_last, y10_last, x11_last, y11_last, x12_last, y12_last, x13_last, y13_last, x14_last, y14_last, x15_last, y15_last, x16_last, y16_last, x17_last, y17_last, x18_last, y18_last, x19_last, y19_last, x20_last, y20_last, x21_last, y21_last, x22_last, y22_last, x23_last, y23_last, x24_last, y24_last, x25_last, y25_last, x26_last, y26_last, x27_last, y27_last, x28_last, y28_last, x29_last, y29_last, x30_last, y30_last, x31_last, y31_last, x32_last, y32_last, +) +global() +( + x1 = y0; y1 = x1_last + x1 * m - y1_last * m_last; x1_last = x1; y1_last = y1; + y1 = y1 / (1.0 + sat * abs(y1)); + x2 = y1; y2 = x2_last + x2 * m - y2_last * m_last; x2_last = x2; y2_last = y2; + y2 = y2 / (1.0 + sat * abs(y2)); + x3 = y2; y3 = x3_last + x3 * m - y3_last * m_last; x3_last = x3; y3_last = y3; + y3 = y3 / (1.0 + sat * abs(y3)); + x4 = y3; y4 = x4_last + x4 * m - y4_last * m_last; x4_last = x4; y4_last = y4; + y4 = y4 / (1.0 + sat * abs(y4)); + x5 = y4; y5 = x5_last + x5 * m - y5_last * m_last; x5_last = x5; y5_last = y5; + y5 = y5 / (1.0 + sat * abs(y5)); + x6 = y5; y6 = x6_last + x6 * m - y6_last * m_last; x6_last = x6; y6_last = y6; + y6 = y6 / (1.0 + sat * abs(y6)); + x7 = y6; y7 = x7_last + x7 * m - y7_last * m_last; x7_last = x7; y7_last = y7; + y7 = y7 / (1.0 + sat * abs(y7)); + x8 = y7; y8 = x8_last + x8 * m - y8_last * m_last; x8_last = x8; y8_last = y8; + y8 = y8 / (1.0 + sat * abs(y8)); + x9 = y8; y9 = x9_last + x9 * m - y9_last * m_last; x9_last = x9; y9_last = y9; + y9 = y9 / (1.0 + sat * abs(y9)); + x10 = y9; y10 = x10_last + x10 * m - y10_last * m_last; x10_last = x10; y10_last = y10; + y10 = y10 / (1.0 + sat * abs(y10)); + x11 = y10; y11 = x11_last + x11 * m - y11_last * m_last; x11_last = x11; y11_last = y11; + y11 = y11 / (1.0 + sat * abs(y11)); + x12 = y11; y12 = x12_last + x12 * m - y12_last * m_last; x12_last = x12; y12_last = y12; + y12 = y12 / (1.0 + sat * abs(y12)); + x13 = y12; y13 = x13_last + x13 * m - y13_last * m_last; x13_last = x13; y13_last = y13; + y13 = y13 / (1.0 + sat * abs(y13)); + x14 = y13; y14 = x14_last + x14 * m - y14_last * m_last; x14_last = x14; y14_last = y14; + y14 = y14 / (1.0 + sat * abs(y14)); + x15 = y14; y15 = x15_last + x15 * m - y15_last * m_last; x15_last = x15; y15_last = y15; + y15 = y15 / (1.0 + sat * abs(y15)); + x16 = y15; y16 = x16_last + x16 * m - y16_last * m_last; x16_last = x16; y16_last = y16; + y16 = y16 / (1.0 + sat * abs(y16)); + x17 = y16; y17 = x17_last + x17 * m - y17_last * m_last; x17_last = x17; y17_last = y17; + y17 = y17 / (1.0 + sat * abs(y17)); + x18 = y17; y18 = x18_last + x18 * m - y18_last * m_last; x18_last = x18; y18_last = y18; + y18 = y18 / (1.0 + sat * abs(y18)); + x19 = y18; y19 = x19_last + x19 * m - y19_last * m_last; x19_last = x19; y19_last = y19; + y19 = y19 / (1.0 + sat * abs(y19)); + x20 = y19; y20 = x20_last + x20 * m - y20_last * m_last; x20_last = x20; y20_last = y20; + y20 = y20 / (1.0 + sat * abs(y20)); + x21 = y20; y21 = x21_last + x21 * m - y21_last * m_last; x21_last = x21; y21_last = y21; + y21 = y21 / (1.0 + sat * abs(y21)); + x22 = y21; y22 = x22_last + x22 * m - y22_last * m_last; x22_last = x22; y22_last = y22; + y22 = y22 / (1.0 + sat * abs(y22)); + x23 = y22; y23 = x23_last + x23 * m - y23_last * m_last; x23_last = x23; y23_last = y23; + y23 = y23 / (1.0 + sat * abs(y23)); + x24 = y23; y24 = x24_last + x24 * m - y24_last * m_last; x24_last = x24; y24_last = y24; + y24 = y24 / (1.0 + sat * abs(y24)); + x25 = y24; y25 = x25_last + x25 * m - y25_last * m_last; x25_last = x25; y25_last = y25; + y25 = y25 / (1.0 + sat * abs(y25)); + x26 = y25; y26 = x26_last + x26 * m - y26_last * m_last; x26_last = x26; y26_last = y26; + y26 = y26 / (1.0 + sat * abs(y26)); + x27 = y26; y27 = x27_last + x27 * m - y27_last * m_last; x27_last = x27; y27_last = y27; + y27 = y27 / (1.0 + sat * abs(y27)); + x28 = y27; y28 = x28_last + x28 * m - y28_last * m_last; x28_last = x28; y28_last = y28; + y28 = y28 / (1.0 + sat * abs(y28)); + x29 = y28; y29 = x29_last + x29 * m - y29_last * m_last; x29_last = x29; y29_last = y29; + y29 = y29 / (1.0 + sat * abs(y29)); + x30 = y29; y30 = x30_last + x30 * m - y30_last * m_last; x30_last = x30; y30_last = y30; + y30 = y30 / (1.0 + sat * abs(y30)); + x31 = y30; y31 = x31_last + x31 * m - y31_last * m_last; x31_last = x31; y31_last = y31; + y31 = y31 / (1.0 + sat * abs(y31)); + x32 = y31; y32 = x32_last + x32 * m - y32_last * m_last; x32_last = x32; y32_last = y32; + y32 = y32 / (1.0 + sat * abs(y32)); + + y32 +); + + +function allpass_coeff(normalized_freq) +local(f0, factor) +instance() +global(isampling_factor) +( + f0 = exp((1.0 - normalized_freq) * log(20/22050)) * isampling_factor; + factor = tan($pi * f0); + (factor - 1.0) / (factor + 1.0); +); + diff --git a/Filter/tilr_SKFilter/skf.Saike_Yutani_oversampling.jsfx-inc b/Filter/tilr_SKFilter/skf.Saike_Yutani_oversampling.jsfx-inc new file mode 100644 index 0000000..3cc20a5 --- /dev/null +++ b/Filter/tilr_SKFilter/skf.Saike_Yutani_oversampling.jsfx-inc @@ -0,0 +1,228 @@ +/* +MIT License + +Copyright (c) 2022 Joep Vanlier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +@init + // UP / DOWNSAMPLING + // Generate windowed sinc filter at memory location FIR + // Inputs are: + // fir - Memory location to store windowed sinc + // nt - Number of taps + // bw - Fractional bandwidth + // g - Gain + function sinc(fir, nt, bw, g) + local(a, ys, yg, yw, i, pibw2, pifc2, pidnt2, hnt) + global() + ( + pibw2 = 2.0*$pi*bw; + pidnt2 = 2.0*$pi/nt; + hnt = 0.5*nt; + i = 1; + + loop(nt-1, + // Sinc width + a = (i - hnt) * pibw2; + + // Sinc + ys = (a != 0) ? sin(a)/a : 1.0; + + // Window gain + yg = g * (4.0 * bw); + + // Hamming window (could be replaced with Kaiser in the future) + yw = 0.54 - 0.46 * cos(i * pidnt2); + + // Calc FIR coeffs + fir[i-1] = yw * yg * ys; + + i += 1; + ); + ); + + // Generate sinc filters for a specific upsampling ratio + // + // Upsampling leads to a sample followed by N-1 zeroes. Hence + // to compute each subsample, we only need 1/Nth of the taps. + // This is why we set up a specific filter for each subsample. + // i.e. for N=4, you get something like f1*Zn + f5*Zn-1 + ... + // + // Inputs: + // N_in - oversampling factor + // tapsPerFilter - Taps per subfilter (should be 8 in this implementation) + // targetmem - Location to store the coefficients + // tmp - Working memory + function updateSincFilter(N_in, tapsPerFilter, targetmem, tmp) + local(nHist, iFilt, nTaps) + instance(h0, h1, h2, h3, h4, h5, h6, coeffs, loc, N, delta) + global() + ( + N = N_in; + nHist = tapsPerFilter; + loc = 0; + coeffs = targetmem; + nTaps = N*nHist; + + // Memory being set is conservatively large. + memset(coeffs,0,10000); + memset(tmp,0,10000); + + sinc(tmp, nTaps, .5/N, .5*N); + + // Divide sinc over the different filters + iFilt = 0; // Filter idx for which subsample this filter is + delta = 0; // Sample idx + loop(nTaps, + coeffs[delta + iFilt*100] = tmp[]; + iFilt += 1; + iFilt == N ? ( iFilt = 0; delta += 1 ); + tmp += 1; + ); + ); + + // Generate downsample filter + // Here, the full N*nHist tap filter has to be evaluated for every sample, + // but only every Nth sample has to be evaluated. + function updateSincDownsampleFilter(N_in, nTaps_in, histmem, coeffmem) + global() + instance(hist, hend, hptr, coeffs, loc, N, delta, nTaps) + local() + ( + N = N_in; + hist = histmem; + coeffs = coeffmem; + nTaps = nTaps_in; + hptr = hist; + hend = hist + nTaps; + + memset(coeffs,0,10000); + sinc(coeffs, nTaps, .5/N, .5); + ); + + function advanceHist(sample) + global() + instance(hist, hptr, hend, coeffs, loc, N, delta, nTaps) + local(nHist, nTaps) + ( + hptr += 1; + ( hptr == hend ) ? hptr = hist; + hptr[] = sample; + ); + + function sincDownSample() + global() + instance(hist, hptr, hend, coeffs, loc, N, delta, nTaps) + local(nHist, hm1, hptr2, out, cfptr) + ( + hm1 = hist-1; + hptr2 = hptr; + cfptr = coeffs; + out = 0; + + loop(nTaps, + out = out + hptr2[] * cfptr[]; + + cfptr += 1; + hptr2 -= 1; + ( hptr2 == hm1 ) ? hptr2 = hend-1; + ); + + out + ); + + function resetSincDown() + global() + instance(hist, hptr, hend, coeffs, loc, N, delta, nTaps) + local(nHist, hm1, hptr2) + ( + hm1 = hist-1; + hptr2 = hptr; + + loop(nTaps, + hptr2[] = 0; + + hptr2 -= 1; + ( hptr2 == hm1 ) ? hptr2 = hend-1; + ); + ); + + // Maintain input sample history. Hardcoded for speed. + // Note h7 is omitted because for integer upsampling it is always zero! + function advanceSinc(sample) + instance(h0, h1, h2, h3, h4, h5, h6, coeffs, loc, N) + global() + local(filt) + ( + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + h0 = sample; + loc = 0; + ); + + function resetSincUp() + instance(h0, h1, h2, h3, h4, h5, h6, coeffs, loc, N) + global() + local(filt) + ( + h0 = h1 = h2 = h3 = h4 = h5 = h6 = 0; + ); + + // Note h7 is omitted because for integer upsampling it is always zero! + function getSubSample() + instance(h0, h1, h2, h3, h4, h5, h6, coeffs, loc, N) + global() + local(filt, out) + ( + filt = coeffs + loc; + out = filt[] * h0 + filt[1] * h1 + filt[2] * h2 + filt[3] * h3 + filt[4] * h4 + filt[5] * h5 + filt[6] * h6; + + loc += 100; + out + ); + + function inputFilter(sample) + instance(len, d1, d2, d3, d4, o1, o2, o3, o4, a1, a2, b0, b1, b2) + local (out) + global () + ( + out = sample*b0 + d1*b1 + d2*b2 - d3*a1 - d4*a2; + d2 = d1; + d1 = sample; + d4 = d3; + d3 = out; + ); + + function outputFilter(sample) + instance(len, d1, d2, d3, d4, o1, o2, o3, o4, a1, a2, b0, b1, b2) + local (out) + global () + ( + out = sample*b0 + o1*b1 + o2*b2 - o3*a1 - o4*a2; + o2 = o1; + o1 = sample; + o4 = o3; + o3 = out; + ); diff --git a/Filter/tilr_SKFilter/skf.Saike_Yutani_upsamplers b/Filter/tilr_SKFilter/skf.Saike_Yutani_upsamplers new file mode 100644 index 0000000..ed21469 --- /dev/null +++ b/Filter/tilr_SKFilter/skf.Saike_Yutani_upsamplers @@ -0,0 +1,1838 @@ +/* +MIT License + +Copyright (c) 2022 Joep Vanlier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +@init +function init_upSampler2() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64) + global() + local() + ( + h0 = h1 = h2 = h3 = h4 = h5 = h6 = h7 = h8 = h9 = h10 = h11 = h12 = h13 = h14 = h15 = h16 = h17 = h18 = h19 = h20 = h21 = h22 = h23 = h24 = h25 = h26 = h27 = h28 = h29 = h30 = h31 = h32 = h33 = h34 = h35 = h36 = h37 = h38 = h39 = h40 = h41 = h42 = h43 = h44 = h45 = h46 = h47 = h48 = h49 = h50 = h51 = h52 = h53 = h54 = h55 = h56 = h57 = h58 = h59 = h60 = h61 = h62 = h63 = h64 = 0 + ); + +function update_upHist2(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, idx) + global() + local() + ( + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function update_downHist2(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, idx) + global() + local() + ( + h65 = h64; + h64 = h63; + h63 = h62; + h62 = h61; + h61 = h60; + h60 = h59; + h59 = h58; + h58 = h57; + h57 = h56; + h56 = h55; + h55 = h54; + h54 = h53; + h53 = h52; + h52 = h51; + h51 = h50; + h50 = h49; + h49 = h48; + h48 = h47; + h47 = h46; + h46 = h45; + h45 = h44; + h44 = h43; + h43 = h42; + h42 = h41; + h41 = h40; + h40 = h39; + h39 = h38; + h38 = h37; + h37 = h36; + h36 = h35; + h35 = h34; + h34 = h33; + h33 = h32; + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function downSample2() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64) + global() + local() + ( + - 0.0000000000000000000099181713 * (h0 + h64) - 0.0000157684019076028459651045 * (h1 + h63) + 0.0000000000000000001890212759 * (h2 + h62) + 0.0000668896391717849198152099 * (h3 + h61) - 0.0000000000000000001992354234 * (h4 + h60) - 0.0001891989906380298460189526 * (h5 + h59) - 0.0000000000000000005752212179 * (h6 + h58) + 0.0004377128379096322354294135 * (h7 + h57) - 0.0000000000000000009298561215 * (h8 + h56) - 0.0008906785065136706321109461 * (h9 + h55) + 0.0000000000000000060050299396 * (h10 + h54) + 0.0016533331700159757931406501 * (h11 + h53) - 0.0000000000000000026844636138 * (h12 + h52) - 0.0028619810722864957863720292 * (h13 + h51) + 0.0000000000000000040627689494 * (h14 + h50) + 0.0046904282259888118236657029 * (h15 + h49) - 0.0000000000000000057849349670 * (h16 + h48) - 0.0073635540137577323860362810 * (h17 + h47) + 0.0000000000000000078079915472 * (h18 + h46) + 0.0111887532178094675772150879 * (h19 + h45) - 0.0000000000000000100436068618 * (h20 + h44) - 0.0166308919344621067293310546 * (h21 + h43) + 0.0000000000000000123616084976 * (h22 + h42) + 0.0245002933530227423597480652 * (h23 + h41) - 0.0000000000000000146007297630 * (h24 + h40) - 0.0364790852956249495031570973 * (h25 + h39) + 0.0000000000000000165855976951 * (h26 + h38) + 0.0569279209706458830253517078 * (h27 + h37) - 0.0000000000000000181476788196 * (h28 + h36) - 0.1019328347498759945732871302 * (h29 + h35) + 0.0000000000000000191469682927 * (h30 + h34) + 0.3168974327353483722014004798 * (h31 + h33) + 0.5000000000000000000000000000 * (h32) + ); + + +function upSample2() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, idx ) + global() + local() + ( + idx += 1; + ( idx == 0 ) ? ( + - 0.0000000000000000000099181713 * (h0 + h32) + 0.0000000000000000001890212759 * (h1 + h31) - 0.0000000000000000001992354234 * (h2 + h30) - 0.0000000000000000005752212179 * (h3 + h29) - 0.0000000000000000009298561215 * (h4 + h28) + 0.0000000000000000060050299396 * (h5 + h27) - 0.0000000000000000026844636138 * (h6 + h26) + 0.0000000000000000040627689494 * (h7 + h25) - 0.0000000000000000057849349670 * (h8 + h24) + 0.0000000000000000078079915472 * (h9 + h23) - 0.0000000000000000100436068618 * (h10 + h22) + 0.0000000000000000123616084976 * (h11 + h21) - 0.0000000000000000146007297630 * (h12 + h20) + 0.0000000000000000165855976951 * (h13 + h19) - 0.0000000000000000181476788196 * (h14 + h18) + 0.0000000000000000191469682927 * (h15 + h17) + 0.5000000000000000000000000000 * (h16) + ) : ( idx == 1 ) ? ( + - 0.0000157684019076028459651045 * (h0 + h31) + 0.0000668896391717849198152099 * (h1 + h30) - 0.0001891989906380298460189526 * (h2 + h29) + 0.0004377128379096322354294135 * (h3 + h28) - 0.0008906785065136706321109461 * (h4 + h27) + 0.0016533331700159757931406501 * (h5 + h26) - 0.0028619810722864957863720292 * (h6 + h25) + 0.0046904282259888118236657029 * (h7 + h24) - 0.0073635540137577323860362810 * (h8 + h23) + 0.0111887532178094675772150879 * (h9 + h22) - 0.0166308919344621067293310546 * (h10 + h21) + 0.0245002933530227423597480652 * (h11 + h20) - 0.0364790852956249495031570973 * (h12 + h19) + 0.0569279209706458830253517078 * (h13 + h18) - 0.1019328347498759945732871302 * (h14 + h17) + 0.3168974327353483722014004798 * (h15 + h16) + ) + ); + +function init_upSampler3() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96) + global() + local() + ( + h0 = h1 = h2 = h3 = h4 = h5 = h6 = h7 = h8 = h9 = h10 = h11 = h12 = h13 = h14 = h15 = h16 = h17 = h18 = h19 = h20 = h21 = h22 = h23 = h24 = h25 = h26 = h27 = h28 = h29 = h30 = h31 = h32 = h33 = h34 = h35 = h36 = h37 = h38 = h39 = h40 = h41 = h42 = h43 = h44 = h45 = h46 = h47 = h48 = h49 = h50 = h51 = h52 = h53 = h54 = h55 = h56 = h57 = h58 = h59 = h60 = h61 = h62 = h63 = h64 = h65 = h66 = h67 = h68 = h69 = h70 = h71 = h72 = h73 = h74 = h75 = h76 = h77 = h78 = h79 = h80 = h81 = h82 = h83 = h84 = h85 = h86 = h87 = h88 = h89 = h90 = h91 = h92 = h93 = h94 = h95 = h96 = 0 + ); + +function update_upHist3(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, idx) + global() + local() + ( + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function update_downHist3(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, idx) + global() + local() + ( + h97 = h96; + h96 = h95; + h95 = h94; + h94 = h93; + h93 = h92; + h92 = h91; + h91 = h90; + h90 = h89; + h89 = h88; + h88 = h87; + h87 = h86; + h86 = h85; + h85 = h84; + h84 = h83; + h83 = h82; + h82 = h81; + h81 = h80; + h80 = h79; + h79 = h78; + h78 = h77; + h77 = h76; + h76 = h75; + h75 = h74; + h74 = h73; + h73 = h72; + h72 = h71; + h71 = h70; + h70 = h69; + h69 = h68; + h68 = h67; + h67 = h66; + h66 = h65; + h65 = h64; + h64 = h63; + h63 = h62; + h62 = h61; + h61 = h60; + h60 = h59; + h59 = h58; + h58 = h57; + h57 = h56; + h56 = h55; + h55 = h54; + h54 = h53; + h53 = h52; + h52 = h51; + h51 = h50; + h50 = h49; + h49 = h48; + h48 = h47; + h47 = h46; + h46 = h45; + h45 = h44; + h44 = h43; + h43 = h42; + h42 = h41; + h41 = h40; + h40 = h39; + h39 = h38; + h38 = h37; + h37 = h36; + h36 = h35; + h35 = h34; + h34 = h33; + h33 = h32; + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function downSample3() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96) + global() + local() + ( + - 0.0000000000000000000066121142 * (h0 + h96) - 0.0000065876445494106254432954 * (h1 + h95) - 0.0000121671875267996685741293 * (h2 + h94) + 0.0000000000000000001260141839 * (h3 + h93) + 0.0000315282859974594324562781 * (h4 + h92) + 0.0000468259781374402386409581 * (h5 + h91) - 0.0000000000000000001328236156 * (h6 + h90) - 0.0000934166103276844840075724 * (h7 + h89) - 0.0001270453090432086408045204 * (h8 + h88) + 0.0000000000000000010062436728 * (h9 + h87) + 0.0002220046797640929801993803 * (h10 + h86) + 0.0002866664164929718207688869 * (h11 + h85) - 0.0000000000000000006199040810 * (h12 + h84) - 0.0004600789817233408534984107 * (h13 + h83) - 0.0005733145806488167952816304 * (h14 + h82) + 0.0000000000000000040033532930 * (h15 + h81) + 0.0008656515972657312808086205 * (h16 + h80) + 0.0010505580751447142831556114 * (h17 + h79) - 0.0000000000000000069814144954 * (h18 + h78) - 0.0015142299368397637172184433 * (h19 + h77) - 0.0018003775571569121099341215 * (h20 + h76) + 0.0000000000000000114389844054 * (h21 + h75) + 0.0025021704768435778197532837 * (h22 + h74) + 0.0029273153917977420314378012 * (h23 + h73) - 0.0000000000000000038566233113 * (h24 + h72) - 0.0039535267431878920452170689 * (h25 + h71) - 0.0045674611580107504077430391 * (h26 + h70) + 0.0000000000000000052053276982 * (h27 + h69) + 0.0060357948241555898355459320 * (h28 + h68) + 0.0069093933017410737520980213 * (h29 + h67) - 0.0000000000000000066957379078 * (h30 + h66) - 0.0089972683720108970195639131 * (h31 + h65) - 0.0102443810443442022417581683 * (h32 + h64) + 0.0000000000000000321485127637 * (h33 + h63) + 0.0132596240390790414548360943 * (h34 + h62) + 0.0150939952445445519507716270 * (h35 + h61) - 0.0000000000000000097338198420 * (h36 + h60) - 0.0196710725273944314617224904 * (h37 + h59) - 0.0225769162988834239114144253 * (h38 + h58) + 0.0000000000000000110570651301 * (h39 + h57) + 0.0303390231990166119036000936 * (h40 + h56) + 0.0357287597153385858006480191 * (h41 + h55) - 0.0000000000000000120984525464 * (h42 + h54) - 0.0524687268568565026716221666 * (h43 + h53) - 0.0667677831802520743709195017 * (h44 + h52) + 0.0000000000000000127646455285 * (h45 + h51) + 0.1367466000743488840907247095 * (h46 + h50) + 0.2751201919563462938711495553 * (h47 + h49) + 0.3333333333333333148296162562 * (h48) + ); + + +function upSample3() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, idx ) + global() + local() + ( + idx += 1; + ( idx == 0 ) ? ( + - 0.0000000000000000000066121142 * (h0 + h32) + 0.0000000000000000001260141839 * (h1 + h31) - 0.0000000000000000001328236156 * (h2 + h30) + 0.0000000000000000010062436728 * (h3 + h29) - 0.0000000000000000006199040810 * (h4 + h28) + 0.0000000000000000040033532930 * (h5 + h27) - 0.0000000000000000069814144954 * (h6 + h26) + 0.0000000000000000114389844054 * (h7 + h25) - 0.0000000000000000038566233113 * (h8 + h24) + 0.0000000000000000052053276982 * (h9 + h23) - 0.0000000000000000066957379078 * (h10 + h22) + 0.0000000000000000321485127637 * (h11 + h21) - 0.0000000000000000097338198420 * (h12 + h20) + 0.0000000000000000110570651301 * (h13 + h19) - 0.0000000000000000120984525464 * (h14 + h18) + 0.0000000000000000127646455285 * (h15 + h17) + 0.3333333333333333148296162562 * (h16) + ) : ( idx == 1 ) ? ( + - 0.0000065876445494106254432954 * (h0) - 0.0000121671875267996685741293 * (h31) + 0.0000315282859974594324562781 * (h1) + 0.0000468259781374402386409581 * (h30) - 0.0000934166103276844840075724 * (h2) - 0.0001270453090432086408045204 * (h29) + 0.0002220046797640929801993803 * (h3) + 0.0002866664164929718207688869 * (h28) - 0.0004600789817233408534984107 * (h4) - 0.0005733145806488167952816304 * (h27) + 0.0008656515972657312808086205 * (h5) + 0.0010505580751447142831556114 * (h26) - 0.0015142299368397637172184433 * (h6) - 0.0018003775571569121099341215 * (h25) + 0.0025021704768435778197532837 * (h7) + 0.0029273153917977420314378012 * (h24) - 0.0039535267431878920452170689 * (h8) - 0.0045674611580107504077430391 * (h23) + 0.0060357948241555898355459320 * (h9) + 0.0069093933017410737520980213 * (h22) - 0.0089972683720108970195639131 * (h10) - 0.0102443810443442022417581683 * (h21) + 0.0132596240390790414548360943 * (h11) + 0.0150939952445445519507716270 * (h20) - 0.0196710725273944314617224904 * (h12) - 0.0225769162988834239114144253 * (h19) + 0.0303390231990166119036000936 * (h13) + 0.0357287597153385858006480191 * (h18) - 0.0524687268568565026716221666 * (h14) - 0.0667677831802520743709195017 * (h17) + 0.1367466000743488840907247095 * (h15) + 0.2751201919563462938711495553 * (h16) + ) : ( idx == 2 ) ? ( + - 0.0000065876445494106254432954 * (h31) - 0.0000121671875267996685741293 * (h0) + 0.0000315282859974594324562781 * (h30) + 0.0000468259781374402386409581 * (h1) - 0.0000934166103276844840075724 * (h29) - 0.0001270453090432086408045204 * (h2) + 0.0002220046797640929801993803 * (h28) + 0.0002866664164929718207688869 * (h3) - 0.0004600789817233408534984107 * (h27) - 0.0005733145806488167952816304 * (h4) + 0.0008656515972657312808086205 * (h26) + 0.0010505580751447142831556114 * (h5) - 0.0015142299368397637172184433 * (h25) - 0.0018003775571569121099341215 * (h6) + 0.0025021704768435778197532837 * (h24) + 0.0029273153917977420314378012 * (h7) - 0.0039535267431878920452170689 * (h23) - 0.0045674611580107504077430391 * (h8) + 0.0060357948241555898355459320 * (h22) + 0.0069093933017410737520980213 * (h9) - 0.0089972683720108970195639131 * (h21) - 0.0102443810443442022417581683 * (h10) + 0.0132596240390790414548360943 * (h20) + 0.0150939952445445519507716270 * (h11) - 0.0196710725273944314617224904 * (h19) - 0.0225769162988834239114144253 * (h12) + 0.0303390231990166119036000936 * (h18) + 0.0357287597153385858006480191 * (h13) - 0.0524687268568565026716221666 * (h17) - 0.0667677831802520743709195017 * (h14) + 0.1367466000743488840907247095 * (h16) + 0.2751201919563462938711495553 * (h15) + ) + ); + +function init_upSampler4() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128) + global() + local() + ( + h0 = h1 = h2 = h3 = h4 = h5 = h6 = h7 = h8 = h9 = h10 = h11 = h12 = h13 = h14 = h15 = h16 = h17 = h18 = h19 = h20 = h21 = h22 = h23 = h24 = h25 = h26 = h27 = h28 = h29 = h30 = h31 = h32 = h33 = h34 = h35 = h36 = h37 = h38 = h39 = h40 = h41 = h42 = h43 = h44 = h45 = h46 = h47 = h48 = h49 = h50 = h51 = h52 = h53 = h54 = h55 = h56 = h57 = h58 = h59 = h60 = h61 = h62 = h63 = h64 = h65 = h66 = h67 = h68 = h69 = h70 = h71 = h72 = h73 = h74 = h75 = h76 = h77 = h78 = h79 = h80 = h81 = h82 = h83 = h84 = h85 = h86 = h87 = h88 = h89 = h90 = h91 = h92 = h93 = h94 = h95 = h96 = h97 = h98 = h99 = h100 = h101 = h102 = h103 = h104 = h105 = h106 = h107 = h108 = h109 = h110 = h111 = h112 = h113 = h114 = h115 = h116 = h117 = h118 = h119 = h120 = h121 = h122 = h123 = h124 = h125 = h126 = h127 = h128 = 0 + ); + +function update_upHist4(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, idx) + global() + local() + ( + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function update_downHist4(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, idx) + global() + local() + ( + h129 = h128; + h128 = h127; + h127 = h126; + h126 = h125; + h125 = h124; + h124 = h123; + h123 = h122; + h122 = h121; + h121 = h120; + h120 = h119; + h119 = h118; + h118 = h117; + h117 = h116; + h116 = h115; + h115 = h114; + h114 = h113; + h113 = h112; + h112 = h111; + h111 = h110; + h110 = h109; + h109 = h108; + h108 = h107; + h107 = h106; + h106 = h105; + h105 = h104; + h104 = h103; + h103 = h102; + h102 = h101; + h101 = h100; + h100 = h99; + h99 = h98; + h98 = h97; + h97 = h96; + h96 = h95; + h95 = h94; + h94 = h93; + h93 = h92; + h92 = h91; + h91 = h90; + h90 = h89; + h89 = h88; + h88 = h87; + h87 = h86; + h86 = h85; + h85 = h84; + h84 = h83; + h83 = h82; + h82 = h81; + h81 = h80; + h80 = h79; + h79 = h78; + h78 = h77; + h77 = h76; + h76 = h75; + h75 = h74; + h74 = h73; + h73 = h72; + h72 = h71; + h71 = h70; + h70 = h69; + h69 = h68; + h68 = h67; + h67 = h66; + h66 = h65; + h65 = h64; + h64 = h63; + h63 = h62; + h62 = h61; + h61 = h60; + h60 = h59; + h59 = h58; + h58 = h57; + h57 = h56; + h56 = h55; + h55 = h54; + h54 = h53; + h53 = h52; + h52 = h51; + h51 = h50; + h50 = h49; + h49 = h48; + h48 = h47; + h47 = h46; + h46 = h45; + h45 = h44; + h44 = h43; + h43 = h42; + h42 = h41; + h41 = h40; + h40 = h39; + h39 = h38; + h38 = h37; + h37 = h36; + h36 = h35; + h35 = h34; + h34 = h33; + h33 = h32; + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function downSample4() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128) + global() + local() + ( + - 0.0000000000000000000049590856 * (h0 + h128) - 0.0000033757231426914220009483 * (h1 + h127) - 0.0000078842009538014229825522 * (h2 + h126) - 0.0000085289094933942085101017 * (h3 + h125) + 0.0000000000000000000945106379 * (h4 + h124) + 0.0000173704096919697869292644 * (h5 + h123) + 0.0000334448195858924599076049 * (h6 + h122) + 0.0000314676513835836232728903 * (h7 + h121) - 0.0000000000000000000996177117 * (h8 + h120) - 0.0000527876562282808908473965 * (h9 + h119) - 0.0000945994953190149230094763 * (h10 + h118) - 0.0000837447779586459115216610 * (h11 + h117) - 0.0000000000000000002876106089 * (h12 + h116) + 0.0001272462008927691297366369 * (h13 + h115) + 0.0002188564189548161177147068 * (h14 + h114) + 0.0001867347348124971499489649 * (h15 + h113) - 0.0000000000000000004649280607 * (h16 + h112) - 0.0002662294539509409531732875 * (h17 + h111) - 0.0004453392532568353160554731 * (h18 + h110) - 0.0003703653962742688740376884 * (h19 + h109) + 0.0000000000000000030025149698 * (h20 + h108) + 0.0005044354914877378958174003 * (h21 + h107) + 0.0008266665850079878965703251 * (h22 + h106) + 0.0006744394357876423934730625 * (h23 + h105) - 0.0000000000000000013422318069 * (h24 + h104) - 0.0008871474448981886244680606 * (h25 + h103) - 0.0014309905361432478931860146 * (h26 + h102) - 0.0011501899711908994319159438 * (h27 + h101) + 0.0000000000000000020313844747 * (h28 + h100) + 0.0014721915626140886449585432 * (h29 + h99) + 0.0023452141129944059118328514 * (h30 + h98) + 0.0018629731561917639223735499 * (h31 + h97) - 0.0000000000000000028924674835 * (h32 + h96) - 0.0023338616348788105564482365 * (h33 + h95) - 0.0036817770068788661930181405 * (h34 + h94) - 0.0028981644904514727856259526 * (h35 + h93) + 0.0000000000000000039039957736 * (h36 + h92) + 0.0035719011586020370414840119 * (h37 + h91) + 0.0055943766089047337886075439 * (h38 + h90) + 0.0043749359551812942378812288 * (h39 + h89) - 0.0000000000000000050218034309 * (h40 + h88) - 0.0053327653893248576702501573 * (h41 + h87) - 0.0083154459672310533646655273 * (h42 + h86) - 0.0064793859444149210988217469 * (h43 + h85) + 0.0000000000000000061808042488 * (h44 + h84) + 0.0078620405765405087378239202 * (h45 + h83) + 0.0122501466765113711798740326 * (h46 + h82) + 0.0095493791503994621822082323 * (h47 + h81) - 0.0000000000000000073003648815 * (h48 + h80) - 0.0116462054453138064147310615 * (h49 + h79) - 0.0182395426478124747515785486 * (h50 + h78) - 0.0143218836975414522127980632 * (h51 + h77) + 0.0000000000000000082927988476 * (h52 + h76) + 0.0178697620839786477930921649 * (h53 + h75) + 0.0284639604853229415126758539 * (h54 + h74) + 0.0228458254220083416263786802 * (h55 + h73) - 0.0000000000000000090738394098 * (h56 + h72) - 0.0304449875627864352534146519 * (h57 + h71) - 0.0509664173749379972866435651 * (h58 + h70) - 0.0437803489925406158489451514 * (h59 + h69) + 0.0000000000000000095734841463 * (h60 + h68) + 0.0742791559061112965922646367 * (h61 + h67) + 0.1584487163676741861007002399 * (h62 + h66) + 0.2248290167387327342929381757 * (h63 + h65) + 0.2500000000000000000000000000 * (h64) + ); + + +function upSample4() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, idx ) + global() + local() + ( + idx += 1; + ( idx == 0 ) ? ( + - 0.0000000000000000000049590856 * (h0 + h32) + 0.0000000000000000000945106379 * (h1 + h31) - 0.0000000000000000000996177117 * (h2 + h30) - 0.0000000000000000002876106089 * (h3 + h29) - 0.0000000000000000004649280607 * (h4 + h28) + 0.0000000000000000030025149698 * (h5 + h27) - 0.0000000000000000013422318069 * (h6 + h26) + 0.0000000000000000020313844747 * (h7 + h25) - 0.0000000000000000028924674835 * (h8 + h24) + 0.0000000000000000039039957736 * (h9 + h23) - 0.0000000000000000050218034309 * (h10 + h22) + 0.0000000000000000061808042488 * (h11 + h21) - 0.0000000000000000073003648815 * (h12 + h20) + 0.0000000000000000082927988476 * (h13 + h19) - 0.0000000000000000090738394098 * (h14 + h18) + 0.0000000000000000095734841463 * (h15 + h17) + 0.2500000000000000000000000000 * (h16) + ) : ( idx == 1 ) ? ( + - 0.0000033757231426914220009483 * (h0) - 0.0000085289094933942085101017 * (h31) + 0.0000173704096919697869292644 * (h1) + 0.0000314676513835836232728903 * (h30) - 0.0000527876562282808908473965 * (h2) - 0.0000837447779586459115216610 * (h29) + 0.0001272462008927691297366369 * (h3) + 0.0001867347348124971499489649 * (h28) - 0.0002662294539509409531732875 * (h4) - 0.0003703653962742688740376884 * (h27) + 0.0005044354914877378958174003 * (h5) + 0.0006744394357876423934730625 * (h26) - 0.0008871474448981886244680606 * (h6) - 0.0011501899711908994319159438 * (h25) + 0.0014721915626140886449585432 * (h7) + 0.0018629731561917639223735499 * (h24) - 0.0023338616348788105564482365 * (h8) - 0.0028981644904514727856259526 * (h23) + 0.0035719011586020370414840119 * (h9) + 0.0043749359551812942378812288 * (h22) - 0.0053327653893248576702501573 * (h10) - 0.0064793859444149210988217469 * (h21) + 0.0078620405765405087378239202 * (h11) + 0.0095493791503994621822082323 * (h20) - 0.0116462054453138064147310615 * (h12) - 0.0143218836975414522127980632 * (h19) + 0.0178697620839786477930921649 * (h13) + 0.0228458254220083416263786802 * (h18) - 0.0304449875627864352534146519 * (h14) - 0.0437803489925406158489451514 * (h17) + 0.0742791559061112965922646367 * (h15) + 0.2248290167387327342929381757 * (h16) + ) : ( idx == 2 ) ? ( + - 0.0000078842009538014229825522 * (h0 + h31) + 0.0000334448195858924599076049 * (h1 + h30) - 0.0000945994953190149230094763 * (h2 + h29) + 0.0002188564189548161177147068 * (h3 + h28) - 0.0004453392532568353160554731 * (h4 + h27) + 0.0008266665850079878965703251 * (h5 + h26) - 0.0014309905361432478931860146 * (h6 + h25) + 0.0023452141129944059118328514 * (h7 + h24) - 0.0036817770068788661930181405 * (h8 + h23) + 0.0055943766089047337886075439 * (h9 + h22) - 0.0083154459672310533646655273 * (h10 + h21) + 0.0122501466765113711798740326 * (h11 + h20) - 0.0182395426478124747515785486 * (h12 + h19) + 0.0284639604853229415126758539 * (h13 + h18) - 0.0509664173749379972866435651 * (h14 + h17) + 0.1584487163676741861007002399 * (h15 + h16) + ) : ( idx == 3 ) ? ( + - 0.0000033757231426914220009483 * (h31) - 0.0000085289094933942085101017 * (h0) + 0.0000173704096919697869292644 * (h30) + 0.0000314676513835836232728903 * (h1) - 0.0000527876562282808908473965 * (h29) - 0.0000837447779586459115216610 * (h2) + 0.0001272462008927691297366369 * (h28) + 0.0001867347348124971499489649 * (h3) - 0.0002662294539509409531732875 * (h27) - 0.0003703653962742688740376884 * (h4) + 0.0005044354914877378958174003 * (h26) + 0.0006744394357876423934730625 * (h5) - 0.0008871474448981886244680606 * (h25) - 0.0011501899711908994319159438 * (h6) + 0.0014721915626140886449585432 * (h24) + 0.0018629731561917639223735499 * (h7) - 0.0023338616348788105564482365 * (h23) - 0.0028981644904514727856259526 * (h8) + 0.0035719011586020370414840119 * (h22) + 0.0043749359551812942378812288 * (h9) - 0.0053327653893248576702501573 * (h21) - 0.0064793859444149210988217469 * (h10) + 0.0078620405765405087378239202 * (h20) + 0.0095493791503994621822082323 * (h11) - 0.0116462054453138064147310615 * (h19) - 0.0143218836975414522127980632 * (h12) + 0.0178697620839786477930921649 * (h18) + 0.0228458254220083416263786802 * (h13) - 0.0304449875627864352534146519 * (h17) - 0.0437803489925406158489451514 * (h14) + 0.0742791559061112965922646367 * (h16) + 0.2248290167387327342929381757 * (h15) + ) + ); + +function init_upSampler5() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160) + global() + local() + ( + h0 = h1 = h2 = h3 = h4 = h5 = h6 = h7 = h8 = h9 = h10 = h11 = h12 = h13 = h14 = h15 = h16 = h17 = h18 = h19 = h20 = h21 = h22 = h23 = h24 = h25 = h26 = h27 = h28 = h29 = h30 = h31 = h32 = h33 = h34 = h35 = h36 = h37 = h38 = h39 = h40 = h41 = h42 = h43 = h44 = h45 = h46 = h47 = h48 = h49 = h50 = h51 = h52 = h53 = h54 = h55 = h56 = h57 = h58 = h59 = h60 = h61 = h62 = h63 = h64 = h65 = h66 = h67 = h68 = h69 = h70 = h71 = h72 = h73 = h74 = h75 = h76 = h77 = h78 = h79 = h80 = h81 = h82 = h83 = h84 = h85 = h86 = h87 = h88 = h89 = h90 = h91 = h92 = h93 = h94 = h95 = h96 = h97 = h98 = h99 = h100 = h101 = h102 = h103 = h104 = h105 = h106 = h107 = h108 = h109 = h110 = h111 = h112 = h113 = h114 = h115 = h116 = h117 = h118 = h119 = h120 = h121 = h122 = h123 = h124 = h125 = h126 = h127 = h128 = h129 = h130 = h131 = h132 = h133 = h134 = h135 = h136 = h137 = h138 = h139 = h140 = h141 = h142 = h143 = h144 = h145 = h146 = h147 = h148 = h149 = h150 = h151 = h152 = h153 = h154 = h155 = h156 = h157 = h158 = h159 = h160 = 0 + ); + +function update_upHist5(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, idx) + global() + local() + ( + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function update_downHist5(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, idx) + global() + local() + ( + h161 = h160; + h160 = h159; + h159 = h158; + h158 = h157; + h157 = h156; + h156 = h155; + h155 = h154; + h154 = h153; + h153 = h152; + h152 = h151; + h151 = h150; + h150 = h149; + h149 = h148; + h148 = h147; + h147 = h146; + h146 = h145; + h145 = h144; + h144 = h143; + h143 = h142; + h142 = h141; + h141 = h140; + h140 = h139; + h139 = h138; + h138 = h137; + h137 = h136; + h136 = h135; + h135 = h134; + h134 = h133; + h133 = h132; + h132 = h131; + h131 = h130; + h130 = h129; + h129 = h128; + h128 = h127; + h127 = h126; + h126 = h125; + h125 = h124; + h124 = h123; + h123 = h122; + h122 = h121; + h121 = h120; + h120 = h119; + h119 = h118; + h118 = h117; + h117 = h116; + h116 = h115; + h115 = h114; + h114 = h113; + h113 = h112; + h112 = h111; + h111 = h110; + h110 = h109; + h109 = h108; + h108 = h107; + h107 = h106; + h106 = h105; + h105 = h104; + h104 = h103; + h103 = h102; + h102 = h101; + h101 = h100; + h100 = h99; + h99 = h98; + h98 = h97; + h97 = h96; + h96 = h95; + h95 = h94; + h94 = h93; + h93 = h92; + h92 = h91; + h91 = h90; + h90 = h89; + h89 = h88; + h88 = h87; + h87 = h86; + h86 = h85; + h85 = h84; + h84 = h83; + h83 = h82; + h82 = h81; + h81 = h80; + h80 = h79; + h79 = h78; + h78 = h77; + h77 = h76; + h76 = h75; + h75 = h74; + h74 = h73; + h73 = h72; + h72 = h71; + h71 = h70; + h70 = h69; + h69 = h68; + h68 = h67; + h67 = h66; + h66 = h65; + h65 = h64; + h64 = h63; + h63 = h62; + h62 = h61; + h61 = h60; + h60 = h59; + h59 = h58; + h58 = h57; + h57 = h56; + h56 = h55; + h55 = h54; + h54 = h53; + h53 = h52; + h52 = h51; + h51 = h50; + h50 = h49; + h49 = h48; + h48 = h47; + h47 = h46; + h46 = h45; + h45 = h44; + h44 = h43; + h43 = h42; + h42 = h41; + h41 = h40; + h40 = h39; + h39 = h38; + h38 = h37; + h37 = h36; + h36 = h35; + h35 = h34; + h34 = h33; + h33 = h32; + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function downSample5() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160) + global() + local() + ( + - 0.0000000000000000000039672685 * (h0 + h160) - 0.0000020040784318467392476027 * (h1 + h159) - 0.0000049636593540504435166649 * (h2 + h158) - 0.0000071633353882701092035855 * (h3 + h157) - 0.0000061340766418378592938652 * (h4 + h156) - 0.0000000000000000000240690941 * (h5 + h155) + 0.0000108253096983519385469947 * (h6 + h154) + 0.0000225597852236812819980150 * (h7 + h153) + 0.0000285976732926204015646388 * (h8 + h152) + 0.0000221036723710291892414440 * (h9 + h151) - 0.0000000000000000000796941694 * (h10 + h150) - 0.0000334267394639819646288276 * (h11 + h149) - 0.0000655718766920392493336572 * (h12 + h148) - 0.0000788520702166965487423661 * (h13 + h147) - 0.0000581731106148586154538059 * (h14 + h146) - 0.0000000000000000002300884871 * (h15 + h145) + 0.0000812885364278627533607749 * (h16 + h144) + 0.0001541288504632941207001667 * (h17 + h143) + 0.0001796721815035577586756876 * (h18 + h142) + 0.0001288193523382497637352201 * (h19 + h141) - 0.0000000000000000003719424486 * (h20 + h140) - 0.0001710737879368568945242374 * (h21 + h139) - 0.0003170482895769423446578894 * (h22 + h138) - 0.0003617886471048386664954577 * (h23 + h137) - 0.0002542520270353692277490176 * (h24 + h136) - 0.0000000000000000010812391722 * (h25 + h135) + 0.0003255298241389545290530583 * (h26 + h134) + 0.0005932740411023884998312217 * (h27 + h133) + 0.0006663417376881307233396634 * (h28 + h132) + 0.0004612925302986218829663645 * (h29 + h131) + 0.0000000000000000020412778062 * (h30 + h130) - 0.0005743929430109174670213146 * (h31 + h129) - 0.0010333917139092665959942963 * (h32 + h128) - 0.0011464753753984140583616069 * (h33 + h127) - 0.0007844277619955119119216080 * (h34 + h126) - 0.0000000000000000036131754838 * (h35 + h125) + 0.0009556552871967618394480337 * (h36 + h124) + 0.0017019283676469108661233332 * (h37 + h123) + 0.0018699505341761618517487653 * (h38 + h122) + 0.0012676655265794014616764773 * (h39 + h121) - 0.0000000000000000023139739868 * (h40 + h120) - 0.0015180737634252010857804915 * (h41 + h119) - 0.0026821130890590594644806721 * (h42 + h118) - 0.0029247490220080107903299904 * (h43 + h117) - 0.0019686223775265869820327858 * (h44 + h116) + 0.0000000000000000031231966189 * (h45 + h115) + 0.0023268949177368100818263930 * (h46 + h114) + 0.0040868586598085858765938561 * (h47 + h113) + 0.0044321045911488079344087154 * (h48 + h112) + 0.0029680888615995410818870770 * (h49 + h111) - 0.0000000000000000040174427447 * (h50 + h110) - 0.0034773889908164888444541685 * (h51 + h109) - 0.0060848633748633263948479843 * (h52 + h108) - 0.0065776689850511370696861668 * (h53 + h107) - 0.0043930768998547099421503326 * (h54 + h106) - 0.0000000000000000093998208602 * (h55 + h105) + 0.0051281163111687629030388536 * (h56 + h104) + 0.0089655987817445180476649824 * (h57 + h103) + 0.0096902925932619687204860881 * (h58 + h102) + 0.0064761156532928496748491298 * (h59 + h101) - 0.0000000000000000058402919052 * (h60 + h100) - 0.0075903257385385733760352345 * (h61 + h99) - 0.0133186453281675595827771019 * (h62 + h98) - 0.0144660372448623900792918917 * (h63 + h97) - 0.0097296501550104830258192123 * (h64 + h96) + 0.0000000000000000066342390781 * (h65 + h95) + 0.0116129539613201195058511672 * (h66 + h94) + 0.0206334159092098588794694791 * (h67 + h93) + 0.0227587083433087242201331435 * (h68 + h92) + 0.0156000068103777905087481415 * (h69 + h91) - 0.0000000000000000072590715279 * (h70 + h90) - 0.0196212203355458983389247862 * (h71 + h89) - 0.0361531912940253399857404304 * (h72 + h88) - 0.0417630571018613311329303883 * (h73 + h87) - 0.0303934815691062065745597920 * (h74 + h86) + 0.0000000000000000076587873171 * (h75 + h85) + 0.0462447722576860287269084893 * (h76 + h84) + 0.1002660003900417012845380782 * (h77 + h83) + 0.1509351738893692784770905746 * (h78 + h82) + 0.1869647991286631505403192932 * (h79 + h81) + 0.2000000000000000111022302463 * (h80) + ); + + +function upSample5() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, idx ) + global() + local() + ( + idx += 1; + ( idx == 0 ) ? ( + - 0.0000000000000000000039672685 * (h0 + h32) - 0.0000000000000000000240690941 * (h1 + h31) - 0.0000000000000000000796941694 * (h2 + h30) - 0.0000000000000000002300884871 * (h3 + h29) - 0.0000000000000000003719424486 * (h4 + h28) - 0.0000000000000000010812391722 * (h5 + h27) + 0.0000000000000000020412778062 * (h6 + h26) - 0.0000000000000000036131754838 * (h7 + h25) - 0.0000000000000000023139739868 * (h8 + h24) + 0.0000000000000000031231966189 * (h9 + h23) - 0.0000000000000000040174427447 * (h10 + h22) - 0.0000000000000000093998208602 * (h11 + h21) - 0.0000000000000000058402919052 * (h12 + h20) + 0.0000000000000000066342390781 * (h13 + h19) - 0.0000000000000000072590715279 * (h14 + h18) + 0.0000000000000000076587873171 * (h15 + h17) + 0.2000000000000000111022302463 * (h16) + ) : ( idx == 1 ) ? ( + - 0.0000020040784318467392476027 * (h0) - 0.0000061340766418378592938652 * (h31) + 0.0000108253096983519385469947 * (h1) + 0.0000221036723710291892414440 * (h30) - 0.0000334267394639819646288276 * (h2) - 0.0000581731106148586154538059 * (h29) + 0.0000812885364278627533607749 * (h3) + 0.0001288193523382497637352201 * (h28) - 0.0001710737879368568945242374 * (h4) - 0.0002542520270353692277490176 * (h27) + 0.0003255298241389545290530583 * (h5) + 0.0004612925302986218829663645 * (h26) - 0.0005743929430109174670213146 * (h6) - 0.0007844277619955119119216080 * (h25) + 0.0009556552871967618394480337 * (h7) + 0.0012676655265794014616764773 * (h24) - 0.0015180737634252010857804915 * (h8) - 0.0019686223775265869820327858 * (h23) + 0.0023268949177368100818263930 * (h9) + 0.0029680888615995410818870770 * (h22) - 0.0034773889908164888444541685 * (h10) - 0.0043930768998547099421503326 * (h21) + 0.0051281163111687629030388536 * (h11) + 0.0064761156532928496748491298 * (h20) - 0.0075903257385385733760352345 * (h12) - 0.0097296501550104830258192123 * (h19) + 0.0116129539613201195058511672 * (h13) + 0.0156000068103777905087481415 * (h18) - 0.0196212203355458983389247862 * (h14) - 0.0303934815691062065745597920 * (h17) + 0.0462447722576860287269084893 * (h15) + 0.1869647991286631505403192932 * (h16) + ) : ( idx == 2 ) ? ( + - 0.0000049636593540504435166649 * (h0) - 0.0000071633353882701092035855 * (h31) + 0.0000225597852236812819980150 * (h1) + 0.0000285976732926204015646388 * (h30) - 0.0000655718766920392493336572 * (h2) - 0.0000788520702166965487423661 * (h29) + 0.0001541288504632941207001667 * (h3) + 0.0001796721815035577586756876 * (h28) - 0.0003170482895769423446578894 * (h4) - 0.0003617886471048386664954577 * (h27) + 0.0005932740411023884998312217 * (h5) + 0.0006663417376881307233396634 * (h26) - 0.0010333917139092665959942963 * (h6) - 0.0011464753753984140583616069 * (h25) + 0.0017019283676469108661233332 * (h7) + 0.0018699505341761618517487653 * (h24) - 0.0026821130890590594644806721 * (h8) - 0.0029247490220080107903299904 * (h23) + 0.0040868586598085858765938561 * (h9) + 0.0044321045911488079344087154 * (h22) - 0.0060848633748633263948479843 * (h10) - 0.0065776689850511370696861668 * (h21) + 0.0089655987817445180476649824 * (h11) + 0.0096902925932619687204860881 * (h20) - 0.0133186453281675595827771019 * (h12) - 0.0144660372448623900792918917 * (h19) + 0.0206334159092098588794694791 * (h13) + 0.0227587083433087242201331435 * (h18) - 0.0361531912940253399857404304 * (h14) - 0.0417630571018613311329303883 * (h17) + 0.1002660003900417012845380782 * (h15) + 0.1509351738893692784770905746 * (h16) + ) : ( idx == 3 ) ? ( + - 0.0000049636593540504435166649 * (h31) - 0.0000071633353882701092035855 * (h0) + 0.0000225597852236812819980150 * (h30) + 0.0000285976732926204015646388 * (h1) - 0.0000655718766920392493336572 * (h29) - 0.0000788520702166965487423661 * (h2) + 0.0001541288504632941207001667 * (h28) + 0.0001796721815035577586756876 * (h3) - 0.0003170482895769423446578894 * (h27) - 0.0003617886471048386664954577 * (h4) + 0.0005932740411023884998312217 * (h26) + 0.0006663417376881307233396634 * (h5) - 0.0010333917139092665959942963 * (h25) - 0.0011464753753984140583616069 * (h6) + 0.0017019283676469108661233332 * (h24) + 0.0018699505341761618517487653 * (h7) - 0.0026821130890590594644806721 * (h23) - 0.0029247490220080107903299904 * (h8) + 0.0040868586598085858765938561 * (h22) + 0.0044321045911488079344087154 * (h9) - 0.0060848633748633263948479843 * (h21) - 0.0065776689850511370696861668 * (h10) + 0.0089655987817445180476649824 * (h20) + 0.0096902925932619687204860881 * (h11) - 0.0133186453281675595827771019 * (h19) - 0.0144660372448623900792918917 * (h12) + 0.0206334159092098588794694791 * (h18) + 0.0227587083433087242201331435 * (h13) - 0.0361531912940253399857404304 * (h17) - 0.0417630571018613311329303883 * (h14) + 0.1002660003900417012845380782 * (h16) + 0.1509351738893692784770905746 * (h15) + ) : ( idx == 4 ) ? ( + - 0.0000020040784318467392476027 * (h31) - 0.0000061340766418378592938652 * (h0) + 0.0000108253096983519385469947 * (h30) + 0.0000221036723710291892414440 * (h1) - 0.0000334267394639819646288276 * (h29) - 0.0000581731106148586154538059 * (h2) + 0.0000812885364278627533607749 * (h28) + 0.0001288193523382497637352201 * (h3) - 0.0001710737879368568945242374 * (h27) - 0.0002542520270353692277490176 * (h4) + 0.0003255298241389545290530583 * (h26) + 0.0004612925302986218829663645 * (h5) - 0.0005743929430109174670213146 * (h25) - 0.0007844277619955119119216080 * (h6) + 0.0009556552871967618394480337 * (h24) + 0.0012676655265794014616764773 * (h7) - 0.0015180737634252010857804915 * (h23) - 0.0019686223775265869820327858 * (h8) + 0.0023268949177368100818263930 * (h22) + 0.0029680888615995410818870770 * (h9) - 0.0034773889908164888444541685 * (h21) - 0.0043930768998547099421503326 * (h10) + 0.0051281163111687629030388536 * (h20) + 0.0064761156532928496748491298 * (h11) - 0.0075903257385385733760352345 * (h19) - 0.0097296501550104830258192123 * (h12) + 0.0116129539613201195058511672 * (h18) + 0.0156000068103777905087481415 * (h13) - 0.0196212203355458983389247862 * (h17) - 0.0303934815691062065745597920 * (h14) + 0.0462447722576860287269084893 * (h16) + 0.1869647991286631505403192932 * (h15) + ) + ); + +function init_upSampler6() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192) + global() + local() + ( + h0 = h1 = h2 = h3 = h4 = h5 = h6 = h7 = h8 = h9 = h10 = h11 = h12 = h13 = h14 = h15 = h16 = h17 = h18 = h19 = h20 = h21 = h22 = h23 = h24 = h25 = h26 = h27 = h28 = h29 = h30 = h31 = h32 = h33 = h34 = h35 = h36 = h37 = h38 = h39 = h40 = h41 = h42 = h43 = h44 = h45 = h46 = h47 = h48 = h49 = h50 = h51 = h52 = h53 = h54 = h55 = h56 = h57 = h58 = h59 = h60 = h61 = h62 = h63 = h64 = h65 = h66 = h67 = h68 = h69 = h70 = h71 = h72 = h73 = h74 = h75 = h76 = h77 = h78 = h79 = h80 = h81 = h82 = h83 = h84 = h85 = h86 = h87 = h88 = h89 = h90 = h91 = h92 = h93 = h94 = h95 = h96 = h97 = h98 = h99 = h100 = h101 = h102 = h103 = h104 = h105 = h106 = h107 = h108 = h109 = h110 = h111 = h112 = h113 = h114 = h115 = h116 = h117 = h118 = h119 = h120 = h121 = h122 = h123 = h124 = h125 = h126 = h127 = h128 = h129 = h130 = h131 = h132 = h133 = h134 = h135 = h136 = h137 = h138 = h139 = h140 = h141 = h142 = h143 = h144 = h145 = h146 = h147 = h148 = h149 = h150 = h151 = h152 = h153 = h154 = h155 = h156 = h157 = h158 = h159 = h160 = h161 = h162 = h163 = h164 = h165 = h166 = h167 = h168 = h169 = h170 = h171 = h172 = h173 = h174 = h175 = h176 = h177 = h178 = h179 = h180 = h181 = h182 = h183 = h184 = h185 = h186 = h187 = h188 = h189 = h190 = h191 = h192 = 0 + ); + +function update_upHist6(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, idx) + global() + local() + ( + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function update_downHist6(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, idx) + global() + local() + ( + h193 = h192; + h192 = h191; + h191 = h190; + h190 = h189; + h189 = h188; + h188 = h187; + h187 = h186; + h186 = h185; + h185 = h184; + h184 = h183; + h183 = h182; + h182 = h181; + h181 = h180; + h180 = h179; + h179 = h178; + h178 = h177; + h177 = h176; + h176 = h175; + h175 = h174; + h174 = h173; + h173 = h172; + h172 = h171; + h171 = h170; + h170 = h169; + h169 = h168; + h168 = h167; + h167 = h166; + h166 = h165; + h165 = h164; + h164 = h163; + h163 = h162; + h162 = h161; + h161 = h160; + h160 = h159; + h159 = h158; + h158 = h157; + h157 = h156; + h156 = h155; + h155 = h154; + h154 = h153; + h153 = h152; + h152 = h151; + h151 = h150; + h150 = h149; + h149 = h148; + h148 = h147; + h147 = h146; + h146 = h145; + h145 = h144; + h144 = h143; + h143 = h142; + h142 = h141; + h141 = h140; + h140 = h139; + h139 = h138; + h138 = h137; + h137 = h136; + h136 = h135; + h135 = h134; + h134 = h133; + h133 = h132; + h132 = h131; + h131 = h130; + h130 = h129; + h129 = h128; + h128 = h127; + h127 = h126; + h126 = h125; + h125 = h124; + h124 = h123; + h123 = h122; + h122 = h121; + h121 = h120; + h120 = h119; + h119 = h118; + h118 = h117; + h117 = h116; + h116 = h115; + h115 = h114; + h114 = h113; + h113 = h112; + h112 = h111; + h111 = h110; + h110 = h109; + h109 = h108; + h108 = h107; + h107 = h106; + h106 = h105; + h105 = h104; + h104 = h103; + h103 = h102; + h102 = h101; + h101 = h100; + h100 = h99; + h99 = h98; + h98 = h97; + h97 = h96; + h96 = h95; + h95 = h94; + h94 = h93; + h93 = h92; + h92 = h91; + h91 = h90; + h90 = h89; + h89 = h88; + h88 = h87; + h87 = h86; + h86 = h85; + h85 = h84; + h84 = h83; + h83 = h82; + h82 = h81; + h81 = h80; + h80 = h79; + h79 = h78; + h78 = h77; + h77 = h76; + h76 = h75; + h75 = h74; + h74 = h73; + h73 = h72; + h72 = h71; + h71 = h70; + h70 = h69; + h69 = h68; + h68 = h67; + h67 = h66; + h66 = h65; + h65 = h64; + h64 = h63; + h63 = h62; + h62 = h61; + h61 = h60; + h60 = h59; + h59 = h58; + h58 = h57; + h57 = h56; + h56 = h55; + h55 = h54; + h54 = h53; + h53 = h52; + h52 = h51; + h51 = h50; + h50 = h49; + h49 = h48; + h48 = h47; + h47 = h46; + h46 = h45; + h45 = h44; + h44 = h43; + h43 = h42; + h42 = h41; + h41 = h40; + h40 = h39; + h39 = h38; + h38 = h37; + h37 = h36; + h36 = h35; + h35 = h34; + h34 = h33; + h33 = h32; + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function downSample6() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192) + global() + local() + ( + - 0.0000000000000000000033060571 * (h0 + h192) - 0.0000013130145912945136275359 * (h1 + h191) - 0.0000032938222747053127216477 * (h2 + h190) - 0.0000052561339692009486550348 * (h3 + h189) - 0.0000060835937633998342870647 * (h4 + h188) - 0.0000045766934787663860988833 * (h5 + h187) + 0.0000000000000000000630070920 * (h6 + h186) + 0.0000073439443760792366905701 * (h7 + h185) + 0.0000157641429987297162281391 * (h8 + h184) + 0.0000222965463905949744011139 * (h9 + h183) + 0.0000234129890687201193204790 * (h10 + h182) + 0.0000162445946569879465801525 * (h11 + h181) - 0.0000000000000000000664118078 * (h12 + h180) - 0.0000229272977242405951142212 * (h13 + h179) - 0.0000467083051638422420037862 * (h14 + h178) - 0.0000630663302126766153396509 * (h15 + h177) - 0.0000635226545216043204022602 * (h16 + h176) - 0.0000424442055122803863376896 * (h17 + h175) + 0.0000000000000000005031218364 * (h18 + h174) + 0.0000560903708277947542562569 * (h19 + h173) + 0.0001110023398820464900996902 * (h20 + h172) + 0.0001459042793032107722481922 * (h21 + h171) + 0.0001433332082464859103844435 * (h22 + h170) + 0.0000935630488359698937912701 * (h23 + h169) - 0.0000000000000000003099520405 * (h24 + h168) - 0.0001185121436409100045611051 * (h25 + h167) - 0.0002300394908616704267492054 * (h26 + h166) - 0.0002968928355045568593002792 * (h27 + h165) - 0.0002866572903244083976408152 * (h28 + h164) - 0.0001840734075925766445244736 * (h29 + h163) + 0.0000000000000000020016766465 * (h30 + h162) + 0.0002261639754569758911043748 * (h31 + h161) + 0.0004328257986328656404043103 * (h32 + h160) + 0.0005511110566719920394671006 * (h33 + h159) + 0.0005252790375723571415778057 * (h34 + h158) + 0.0003331558875107856927677563 * (h35 + h157) - 0.0000000000000000034907072477 * (h36 + h156) - 0.0003999481657687324132402495 * (h37 + h155) - 0.0007571149684198818586092217 * (h38 + h154) - 0.0009539936907621653344041546 * (h39 + h153) - 0.0009001887785784560549670608 * (h40 + h152) - 0.0005654560596576519619985146 * (h41 + h151) + 0.0000000000000000057194922027 * (h42 + h150) + 0.0006665801863784329281056862 * (h43 + h149) + 0.0012510852384217889098766419 * (h44 + h148) + 0.0015634760753296041580623355 * (h45 + h147) + 0.0014636576958988710157189006 * (h46 + h146) + 0.0009124316699355662294013136 * (h47 + h145) - 0.0000000000000000019283116557 * (h48 + h144) - 0.0010603213855115130401923773 * (h49 + h143) - 0.0019767633715939460226085345 * (h50 + h142) - 0.0024545180045859103616645580 * (h51 + h141) - 0.0022837305790053752038715196 * (h52 + h140) - 0.0014153323471542266377004582 * (h53 + h139) + 0.0000000000000000026026638491 * (h54 + h138) + 0.0016269241021066927540411617 * (h55 + h137) + 0.0030178974120777949177729660 * (h56 + h136) + 0.0037295844059364899152064776 * (h57 + h135) + 0.0034546966508705368760490106 * (h58 + h134) + 0.0021321773335247766641142864 * (h59 + h133) - 0.0000000000000000033478689539 * (h60 + h132) - 0.0024329502999875947909236285 * (h61 + h131) - 0.0044986341860054485097819565 * (h62 + h130) - 0.0055436306448207028213515102 * (h63 + h129) - 0.0051221905221721011208790841 * (h64 + h128) - 0.0031545944797414429000559366 * (h65 + h127) + 0.0000000000000000160742563819 * (h66 + h126) + 0.0035886322644059901777746635 * (h67 + h125) + 0.0066298120195395207274180471 * (h68 + h124) + 0.0081667644510075802083415297 * (h69 + h123) + 0.0075469976222722759753858135 * (h70 + h122) + 0.0046512772851241019483881090 * (h71 + h121) - 0.0000000000000000048669099210 * (h72 + h120) - 0.0053090559209842420190783585 * (h73 + h119) - 0.0098355362636972157308612452 * (h74 + h118) - 0.0121596950985416504126268578 * (h75 + h117) - 0.0112884581494417119557072127 * (h76 + h116) - 0.0069965758337235794267483513 * (h77 + h115) + 0.0000000000000000055285325650 * (h78 + h114) + 0.0081077644703959755867472836 * (h79 + h113) + 0.0151695115995083059518000468 * (h80 + h112) + 0.0189759736568819621649328866 * (h81 + h111) + 0.0178643798576692929003240096 * (h82 + h110) + 0.0112579594474530118169974813 * (h83 + h109) - 0.0000000000000000060492262732 * (h84 + h108) - 0.0136265521459370854417958441 * (h85 + h107) - 0.0262343634284282513358110833 * (h86 + h106) - 0.0339776115832919958781310754 * (h87 + h105) - 0.0333838915901260371854597508 * (h88 + h104) - 0.0221919713131508364312161063 * (h89 + h103) + 0.0000000000000000063823227642 * (h90 + h102) + 0.0314400272193331165038188146 * (h91 + h101) + 0.0683733000371744420453623547 * (h92 + h100) + 0.1056324775784494574004668266 * (h93 + h99) + 0.1375600959781731469355747777 * (h94 + h98) + 0.1590763343355732495343346500 * (h95 + h97) + 0.1666666666666666574148081281 * (h96) + ); + + +function upSample6() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, idx ) + global() + local() + ( + idx += 1; + ( idx == 0 ) ? ( + - 0.0000000000000000000033060571 * (h0 + h32) + 0.0000000000000000000630070920 * (h1 + h31) - 0.0000000000000000000664118078 * (h2 + h30) + 0.0000000000000000005031218364 * (h3 + h29) - 0.0000000000000000003099520405 * (h4 + h28) + 0.0000000000000000020016766465 * (h5 + h27) - 0.0000000000000000034907072477 * (h6 + h26) + 0.0000000000000000057194922027 * (h7 + h25) - 0.0000000000000000019283116557 * (h8 + h24) + 0.0000000000000000026026638491 * (h9 + h23) - 0.0000000000000000033478689539 * (h10 + h22) + 0.0000000000000000160742563819 * (h11 + h21) - 0.0000000000000000048669099210 * (h12 + h20) + 0.0000000000000000055285325650 * (h13 + h19) - 0.0000000000000000060492262732 * (h14 + h18) + 0.0000000000000000063823227642 * (h15 + h17) + 0.1666666666666666574148081281 * (h16) + ) : ( idx == 1 ) ? ( + - 0.0000013130145912945136275359 * (h0) - 0.0000045766934787663860988833 * (h31) + 0.0000073439443760792366905701 * (h1) + 0.0000162445946569879465801525 * (h30) - 0.0000229272977242405951142212 * (h2) - 0.0000424442055122803863376896 * (h29) + 0.0000560903708277947542562569 * (h3) + 0.0000935630488359698937912701 * (h28) - 0.0001185121436409100045611051 * (h4) - 0.0001840734075925766445244736 * (h27) + 0.0002261639754569758911043748 * (h5) + 0.0003331558875107856927677563 * (h26) - 0.0003999481657687324132402495 * (h6) - 0.0005654560596576519619985146 * (h25) + 0.0006665801863784329281056862 * (h7) + 0.0009124316699355662294013136 * (h24) - 0.0010603213855115130401923773 * (h8) - 0.0014153323471542266377004582 * (h23) + 0.0016269241021066927540411617 * (h9) + 0.0021321773335247766641142864 * (h22) - 0.0024329502999875947909236285 * (h10) - 0.0031545944797414429000559366 * (h21) + 0.0035886322644059901777746635 * (h11) + 0.0046512772851241019483881090 * (h20) - 0.0053090559209842420190783585 * (h12) - 0.0069965758337235794267483513 * (h19) + 0.0081077644703959755867472836 * (h13) + 0.0112579594474530118169974813 * (h18) - 0.0136265521459370854417958441 * (h14) - 0.0221919713131508364312161063 * (h17) + 0.0314400272193331165038188146 * (h15) + 0.1590763343355732495343346500 * (h16) + ) : ( idx == 2 ) ? ( + - 0.0000032938222747053127216477 * (h0) - 0.0000060835937633998342870647 * (h31) + 0.0000157641429987297162281391 * (h1) + 0.0000234129890687201193204790 * (h30) - 0.0000467083051638422420037862 * (h2) - 0.0000635226545216043204022602 * (h29) + 0.0001110023398820464900996902 * (h3) + 0.0001433332082464859103844435 * (h28) - 0.0002300394908616704267492054 * (h4) - 0.0002866572903244083976408152 * (h27) + 0.0004328257986328656404043103 * (h5) + 0.0005252790375723571415778057 * (h26) - 0.0007571149684198818586092217 * (h6) - 0.0009001887785784560549670608 * (h25) + 0.0012510852384217889098766419 * (h7) + 0.0014636576958988710157189006 * (h24) - 0.0019767633715939460226085345 * (h8) - 0.0022837305790053752038715196 * (h23) + 0.0030178974120777949177729660 * (h9) + 0.0034546966508705368760490106 * (h22) - 0.0044986341860054485097819565 * (h10) - 0.0051221905221721011208790841 * (h21) + 0.0066298120195395207274180471 * (h11) + 0.0075469976222722759753858135 * (h20) - 0.0098355362636972157308612452 * (h12) - 0.0112884581494417119557072127 * (h19) + 0.0151695115995083059518000468 * (h13) + 0.0178643798576692929003240096 * (h18) - 0.0262343634284282513358110833 * (h14) - 0.0333838915901260371854597508 * (h17) + 0.0683733000371744420453623547 * (h15) + 0.1375600959781731469355747777 * (h16) + ) : ( idx == 3 ) ? ( + - 0.0000052561339692009486550348 * (h0 + h31) + 0.0000222965463905949744011139 * (h1 + h30) - 0.0000630663302126766153396509 * (h2 + h29) + 0.0001459042793032107722481922 * (h3 + h28) - 0.0002968928355045568593002792 * (h4 + h27) + 0.0005511110566719920394671006 * (h5 + h26) - 0.0009539936907621653344041546 * (h6 + h25) + 0.0015634760753296041580623355 * (h7 + h24) - 0.0024545180045859103616645580 * (h8 + h23) + 0.0037295844059364899152064776 * (h9 + h22) - 0.0055436306448207028213515102 * (h10 + h21) + 0.0081667644510075802083415297 * (h11 + h20) - 0.0121596950985416504126268578 * (h12 + h19) + 0.0189759736568819621649328866 * (h13 + h18) - 0.0339776115832919958781310754 * (h14 + h17) + 0.1056324775784494574004668266 * (h15 + h16) + ) : ( idx == 4 ) ? ( + - 0.0000032938222747053127216477 * (h31) - 0.0000060835937633998342870647 * (h0) + 0.0000157641429987297162281391 * (h30) + 0.0000234129890687201193204790 * (h1) - 0.0000467083051638422420037862 * (h29) - 0.0000635226545216043204022602 * (h2) + 0.0001110023398820464900996902 * (h28) + 0.0001433332082464859103844435 * (h3) - 0.0002300394908616704267492054 * (h27) - 0.0002866572903244083976408152 * (h4) + 0.0004328257986328656404043103 * (h26) + 0.0005252790375723571415778057 * (h5) - 0.0007571149684198818586092217 * (h25) - 0.0009001887785784560549670608 * (h6) + 0.0012510852384217889098766419 * (h24) + 0.0014636576958988710157189006 * (h7) - 0.0019767633715939460226085345 * (h23) - 0.0022837305790053752038715196 * (h8) + 0.0030178974120777949177729660 * (h22) + 0.0034546966508705368760490106 * (h9) - 0.0044986341860054485097819565 * (h21) - 0.0051221905221721011208790841 * (h10) + 0.0066298120195395207274180471 * (h20) + 0.0075469976222722759753858135 * (h11) - 0.0098355362636972157308612452 * (h19) - 0.0112884581494417119557072127 * (h12) + 0.0151695115995083059518000468 * (h18) + 0.0178643798576692929003240096 * (h13) - 0.0262343634284282513358110833 * (h17) - 0.0333838915901260371854597508 * (h14) + 0.0683733000371744420453623547 * (h16) + 0.1375600959781731469355747777 * (h15) + ) : ( idx == 5 ) ? ( + - 0.0000013130145912945136275359 * (h31) - 0.0000045766934787663860988833 * (h0) + 0.0000073439443760792366905701 * (h30) + 0.0000162445946569879465801525 * (h1) - 0.0000229272977242405951142212 * (h29) - 0.0000424442055122803863376896 * (h2) + 0.0000560903708277947542562569 * (h28) + 0.0000935630488359698937912701 * (h3) - 0.0001185121436409100045611051 * (h27) - 0.0001840734075925766445244736 * (h4) + 0.0002261639754569758911043748 * (h26) + 0.0003331558875107856927677563 * (h5) - 0.0003999481657687324132402495 * (h25) - 0.0005654560596576519619985146 * (h6) + 0.0006665801863784329281056862 * (h24) + 0.0009124316699355662294013136 * (h7) - 0.0010603213855115130401923773 * (h23) - 0.0014153323471542266377004582 * (h8) + 0.0016269241021066927540411617 * (h22) + 0.0021321773335247766641142864 * (h9) - 0.0024329502999875947909236285 * (h21) - 0.0031545944797414429000559366 * (h10) + 0.0035886322644059901777746635 * (h20) + 0.0046512772851241019483881090 * (h11) - 0.0053090559209842420190783585 * (h19) - 0.0069965758337235794267483513 * (h12) + 0.0081077644703959755867472836 * (h18) + 0.0112579594474530118169974813 * (h13) - 0.0136265521459370854417958441 * (h17) - 0.0221919713131508364312161063 * (h14) + 0.0314400272193331165038188146 * (h16) + 0.1590763343355732495343346500 * (h15) + ) + ); + +function init_upSampler7() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, h194, h195, h196, h197, h198, h199, h200, h201, h202, h203, h204, h205, h206, h207, h208, h209, h210, h211, h212, h213, h214, h215, h216, h217, h218, h219, h220, h221, h222, h223, h224) + global() + local() + ( + h0 = h1 = h2 = h3 = h4 = h5 = h6 = h7 = h8 = h9 = h10 = h11 = h12 = h13 = h14 = h15 = h16 = h17 = h18 = h19 = h20 = h21 = h22 = h23 = h24 = h25 = h26 = h27 = h28 = h29 = h30 = h31 = h32 = h33 = h34 = h35 = h36 = h37 = h38 = h39 = h40 = h41 = h42 = h43 = h44 = h45 = h46 = h47 = h48 = h49 = h50 = h51 = h52 = h53 = h54 = h55 = h56 = h57 = h58 = h59 = h60 = h61 = h62 = h63 = h64 = h65 = h66 = h67 = h68 = h69 = h70 = h71 = h72 = h73 = h74 = h75 = h76 = h77 = h78 = h79 = h80 = h81 = h82 = h83 = h84 = h85 = h86 = h87 = h88 = h89 = h90 = h91 = h92 = h93 = h94 = h95 = h96 = h97 = h98 = h99 = h100 = h101 = h102 = h103 = h104 = h105 = h106 = h107 = h108 = h109 = h110 = h111 = h112 = h113 = h114 = h115 = h116 = h117 = h118 = h119 = h120 = h121 = h122 = h123 = h124 = h125 = h126 = h127 = h128 = h129 = h130 = h131 = h132 = h133 = h134 = h135 = h136 = h137 = h138 = h139 = h140 = h141 = h142 = h143 = h144 = h145 = h146 = h147 = h148 = h149 = h150 = h151 = h152 = h153 = h154 = h155 = h156 = h157 = h158 = h159 = h160 = h161 = h162 = h163 = h164 = h165 = h166 = h167 = h168 = h169 = h170 = h171 = h172 = h173 = h174 = h175 = h176 = h177 = h178 = h179 = h180 = h181 = h182 = h183 = h184 = h185 = h186 = h187 = h188 = h189 = h190 = h191 = h192 = h193 = h194 = h195 = h196 = h197 = h198 = h199 = h200 = h201 = h202 = h203 = h204 = h205 = h206 = h207 = h208 = h209 = h210 = h211 = h212 = h213 = h214 = h215 = h216 = h217 = h218 = h219 = h220 = h221 = h222 = h223 = h224 = 0 + ); + +function update_upHist7(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, idx) + global() + local() + ( + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function update_downHist7(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, h194, h195, h196, h197, h198, h199, h200, h201, h202, h203, h204, h205, h206, h207, h208, h209, h210, h211, h212, h213, h214, h215, h216, h217, h218, h219, h220, h221, h222, h223, h224, h225, idx) + global() + local() + ( + h225 = h224; + h224 = h223; + h223 = h222; + h222 = h221; + h221 = h220; + h220 = h219; + h219 = h218; + h218 = h217; + h217 = h216; + h216 = h215; + h215 = h214; + h214 = h213; + h213 = h212; + h212 = h211; + h211 = h210; + h210 = h209; + h209 = h208; + h208 = h207; + h207 = h206; + h206 = h205; + h205 = h204; + h204 = h203; + h203 = h202; + h202 = h201; + h201 = h200; + h200 = h199; + h199 = h198; + h198 = h197; + h197 = h196; + h196 = h195; + h195 = h194; + h194 = h193; + h193 = h192; + h192 = h191; + h191 = h190; + h190 = h189; + h189 = h188; + h188 = h187; + h187 = h186; + h186 = h185; + h185 = h184; + h184 = h183; + h183 = h182; + h182 = h181; + h181 = h180; + h180 = h179; + h179 = h178; + h178 = h177; + h177 = h176; + h176 = h175; + h175 = h174; + h174 = h173; + h173 = h172; + h172 = h171; + h171 = h170; + h170 = h169; + h169 = h168; + h168 = h167; + h167 = h166; + h166 = h165; + h165 = h164; + h164 = h163; + h163 = h162; + h162 = h161; + h161 = h160; + h160 = h159; + h159 = h158; + h158 = h157; + h157 = h156; + h156 = h155; + h155 = h154; + h154 = h153; + h153 = h152; + h152 = h151; + h151 = h150; + h150 = h149; + h149 = h148; + h148 = h147; + h147 = h146; + h146 = h145; + h145 = h144; + h144 = h143; + h143 = h142; + h142 = h141; + h141 = h140; + h140 = h139; + h139 = h138; + h138 = h137; + h137 = h136; + h136 = h135; + h135 = h134; + h134 = h133; + h133 = h132; + h132 = h131; + h131 = h130; + h130 = h129; + h129 = h128; + h128 = h127; + h127 = h126; + h126 = h125; + h125 = h124; + h124 = h123; + h123 = h122; + h122 = h121; + h121 = h120; + h120 = h119; + h119 = h118; + h118 = h117; + h117 = h116; + h116 = h115; + h115 = h114; + h114 = h113; + h113 = h112; + h112 = h111; + h111 = h110; + h110 = h109; + h109 = h108; + h108 = h107; + h107 = h106; + h106 = h105; + h105 = h104; + h104 = h103; + h103 = h102; + h102 = h101; + h101 = h100; + h100 = h99; + h99 = h98; + h98 = h97; + h97 = h96; + h96 = h95; + h95 = h94; + h94 = h93; + h93 = h92; + h92 = h91; + h91 = h90; + h90 = h89; + h89 = h88; + h88 = h87; + h87 = h86; + h86 = h85; + h85 = h84; + h84 = h83; + h83 = h82; + h82 = h81; + h81 = h80; + h80 = h79; + h79 = h78; + h78 = h77; + h77 = h76; + h76 = h75; + h75 = h74; + h74 = h73; + h73 = h72; + h72 = h71; + h71 = h70; + h70 = h69; + h69 = h68; + h68 = h67; + h67 = h66; + h66 = h65; + h65 = h64; + h64 = h63; + h63 = h62; + h62 = h61; + h61 = h60; + h60 = h59; + h59 = h58; + h58 = h57; + h57 = h56; + h56 = h55; + h55 = h54; + h54 = h53; + h53 = h52; + h52 = h51; + h51 = h50; + h50 = h49; + h49 = h48; + h48 = h47; + h47 = h46; + h46 = h45; + h45 = h44; + h44 = h43; + h43 = h42; + h42 = h41; + h41 = h40; + h40 = h39; + h39 = h38; + h38 = h37; + h37 = h36; + h36 = h35; + h35 = h34; + h34 = h33; + h33 = h32; + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function downSample7() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, h194, h195, h196, h197, h198, h199, h200, h201, h202, h203, h204, h205, h206, h207, h208, h209, h210, h211, h212, h213, h214, h215, h216, h217, h218, h219, h220, h221, h222, h223, h224) + global() + local() + ( + - 0.0000000000000000000028337632 * (h0 + h224) - 0.0000009216163905494045722593 * (h1 + h223) - 0.0000023056658627698541076635 * (h2 + h222) - 0.0000038417389529282175070538 * (h3 + h221) - 0.0000049913017360818245649881 * (h4 + h220) - 0.0000050891494452033029534778 * (h5 + h219) - 0.0000035291979415113102401481 * (h6 + h218) + 0.0000000000000000000540060788 * (h7 + h217) + 0.0000052919032927216100019199 * (h8 + h216) + 0.0000114877644211315289136206 * (h9 + h215) + 0.0000171034027145189642846960 * (h10 + h214) + 0.0000202598378664954129600197 * (h11 + h213) + 0.0000191104631386301232010092 * (h12 + h212) + 0.0000123958706921492685588179 * (h13 + h211) - 0.0000000000000000002928362962 * (h14 + h210) - 0.0000166540129366328577462629 * (h15 + h209) - 0.0000345272925086780559035711 * (h16 + h208) - 0.0000493180721931350330485694 * (h17 + h207) - 0.0000562616150274062706208682 * (h18 + h206) - 0.0000512749277693074691111645 * (h19 + h205) - 0.0000322235527615813324275179 * (h20 + h204) + 0.0000000000000000004312472883 * (h21 + h203) + 0.0000409201899831446077584682 * (h22 + h202) + 0.0000827178714405936102048097 * (h23 + h201) + 0.0001153907318793145767368835 * (h24 + h200) + 0.0001287472023828216752261433 * (h25 + h199) + 0.0001149102035842205631359023 * (h26 + h198) + 0.0000708053129213741803179433 * (h27 + h197) - 0.0000000000000000002656731776 * (h28 + h196) - 0.0000867068814117001569015050 * (h29 + h195) - 0.0001723539708339743366412311 * (h30 + h194) - 0.0002366195985770357893690496 * (h31 + h193) - 0.0002600153729756948675980177 * (h32 + h192) - 0.0002287177507233066251456088 * (h33 + h191) - 0.0001389836178512661554913799 * (h34 + h190) + 0.0000000000000000017157228399 * (h35 + h189) + 0.0001658122848563750508388975 * (h36 + h188) + 0.0003255815601830407135519607 * (h37 + h187) + 0.0004417469989478828773163399 * (h38 + h186) + 0.0004799571766397800996750700 * (h39 + h185) + 0.0004176077282406142027020024 * (h40 + h184) + 0.0002511144059100562536158974 * (h41 + h183) - 0.0000000000000000029920347837 * (h42 + h182) - 0.0002936898920988913674542942 * (h43 + h181) - 0.0005712689305005380505445012 * (h44 + h180) - 0.0007680759573169227902300626 * (h45 + h179) - 0.0008272135371227355401038683 * (h46 + h178) - 0.0007136696604607006702916672 * (h47 + h177) - 0.0004256352483052204603401758 * (h48 + h176) + 0.0000000000000000011607911284 * (h49 + h175) + 0.0004900966398705362001356201 * (h50 + h174) + 0.0009462690062738290204188973 * (h51 + h173) + 0.0012631838352285132756613883 * (h52 + h172) + 0.0013510528475350871892984861 * (h53 + h171) + 0.0011578315711606287832097228 * (h54 + h170) + 0.0006860848810972315246423103 * (h55 + h169) - 0.0000000000000000016528385620 * (h56 + h168) - 0.0007803579819763274780936024 * (h57 + h167) - 0.0014979701011105211582580266 * (h58 + h166) - 0.0019884895270683468349037781 * (h59 + h165) - 0.0021153789039776993430308494 * (h60 + h164) - 0.0018034764393366578029420655 * (h61 + h163) - 0.0010633640942445924011672265 * (h62 + h162) + 0.0000000000000000114761887554 * (h63 + h161) + 0.0011982436734402183986514245 * (h64 + h160) + 0.0022901459526252104272059373 * (h65 + h159) + 0.0030274929251044471571752137 * (h66 + h158) + 0.0032080415540193178529360107 * (h67 + h157) + 0.0027248832800737489076570164 * (h68 + h156) + 0.0016010335807077485676536144 * (h69 + h155) - 0.0000000000000000028696019605 * (h70 + h154) - 0.0017927564657956164377583530 * (h71 + h153) - 0.0034168166415133641687640331 * (h72 + h152) - 0.0045053751276789384336285416 * (h73 + h151) - 0.0047630834256236339804835289 * (h74 + h150) - 0.0040374977682065471204508889 * (h75 + h149) - 0.0023681119238136930787996803 * (h76 + h148) + 0.0000000000000000137779340416 * (h77 + h147) + 0.0026447638629933270353056241 * (h78 + h146) + 0.0050364975077381779131058259 * (h79 + h145) + 0.0066378972017938041305651353 * (h80 + h144) + 0.0070168447237937215180125783 * (h81 + h143) + 0.0059496745483291358508326496 * (h82 + h142) + 0.0034921809684760308188644640 * (h83 + h141) - 0.0000000000000000041716370752 * (h84 + h140) - 0.0039113827965556041688088840 * (h85 + h139) - 0.0074652516214652716100563801 * (h86 + h138) - 0.0098668871393735712443939789 * (h87 + h137) - 0.0104667799331977975224594601 * (h88 + h136) - 0.0089125999900665549974254631 * (h89 + h135) - 0.0052577752274794416556535914 * (h90 + h134) + 0.0000000000000000047387421986 * (h91 + h133) + 0.0059656942323318851856273071 * (h92 + h132) + 0.0114792754733474382244917678 * (h93 + h131) + 0.0153166468500505557198687612 * (h94 + h130) + 0.0164274034804239160711958334 * (h95 + h129) + 0.0141675364477254431966324333 * (h96 + h128) + 0.0084823175454419585950205374 * (h97 + h127) - 0.0000000000000000051850510913 * (h98 + h126) - 0.0099897750993028482796587397 * (h99 + h125) - 0.0196798459780563698984234833 * (h100 + h124) - 0.0269968600415785263402224103 * (h101 + h123) - 0.0299247119219566287684486383 * (h102 + h122) - 0.0268493210130021989212600886 * (h103 + h121) - 0.0168668147466190382344208842 * (h104 + h120) + 0.0000000000000000054705623693 * (h105 + h119) + 0.0227192372722485741443065876 * (h106 + h118) + 0.0493231366585765024224130570 * (h107 + h117) + 0.0771329265309410178064197794 * (h108 + h116) + 0.1031056515787995148114575272 * (h109 + h115) + 0.1242518090095610094891753761 * (h110 + h114) + 0.1380593641728841691751483722 * (h111 + h113) + 0.1428571428571428492126926812 * (h112) + ); + + +function upSample7() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, h194, h195, h196, h197, h198, h199, h200, h201, h202, h203, h204, h205, h206, h207, h208, h209, h210, h211, h212, h213, h214, h215, h216, h217, h218, h219, h220, h221, h222, h223, h224, idx ) + global() + local() + ( + idx += 1; + ( idx == 0 ) ? ( + - 0.0000000000000000000028337632 * (h0 + h32) + 0.0000000000000000000540060788 * (h1 + h31) - 0.0000000000000000002928362962 * (h2 + h30) + 0.0000000000000000004312472883 * (h3 + h29) - 0.0000000000000000002656731776 * (h4 + h28) + 0.0000000000000000017157228399 * (h5 + h27) - 0.0000000000000000029920347837 * (h6 + h26) + 0.0000000000000000011607911284 * (h7 + h25) - 0.0000000000000000016528385620 * (h8 + h24) + 0.0000000000000000114761887554 * (h9 + h23) - 0.0000000000000000028696019605 * (h10 + h22) + 0.0000000000000000137779340416 * (h11 + h21) - 0.0000000000000000041716370752 * (h12 + h20) + 0.0000000000000000047387421986 * (h13 + h19) - 0.0000000000000000051850510913 * (h14 + h18) + 0.0000000000000000054705623693 * (h15 + h17) + 0.1428571428571428492126926812 * (h16) + ) : ( idx == 1 ) ? ( + - 0.0000009216163905494045722593 * (h0) - 0.0000035291979415113102401481 * (h31) + 0.0000052919032927216100019199 * (h1) + 0.0000123958706921492685588179 * (h30) - 0.0000166540129366328577462629 * (h2) - 0.0000322235527615813324275179 * (h29) + 0.0000409201899831446077584682 * (h3) + 0.0000708053129213741803179433 * (h28) - 0.0000867068814117001569015050 * (h4) - 0.0001389836178512661554913799 * (h27) + 0.0001658122848563750508388975 * (h5) + 0.0002511144059100562536158974 * (h26) - 0.0002936898920988913674542942 * (h6) - 0.0004256352483052204603401758 * (h25) + 0.0004900966398705362001356201 * (h7) + 0.0006860848810972315246423103 * (h24) - 0.0007803579819763274780936024 * (h8) - 0.0010633640942445924011672265 * (h23) + 0.0011982436734402183986514245 * (h9) + 0.0016010335807077485676536144 * (h22) - 0.0017927564657956164377583530 * (h10) - 0.0023681119238136930787996803 * (h21) + 0.0026447638629933270353056241 * (h11) + 0.0034921809684760308188644640 * (h20) - 0.0039113827965556041688088840 * (h12) - 0.0052577752274794416556535914 * (h19) + 0.0059656942323318851856273071 * (h13) + 0.0084823175454419585950205374 * (h18) - 0.0099897750993028482796587397 * (h14) - 0.0168668147466190382344208842 * (h17) + 0.0227192372722485741443065876 * (h15) + 0.1380593641728841691751483722 * (h16) + ) : ( idx == 2 ) ? ( + - 0.0000023056658627698541076635 * (h0) - 0.0000050891494452033029534778 * (h31) + 0.0000114877644211315289136206 * (h1) + 0.0000191104631386301232010092 * (h30) - 0.0000345272925086780559035711 * (h2) - 0.0000512749277693074691111645 * (h29) + 0.0000827178714405936102048097 * (h3) + 0.0001149102035842205631359023 * (h28) - 0.0001723539708339743366412311 * (h4) - 0.0002287177507233066251456088 * (h27) + 0.0003255815601830407135519607 * (h5) + 0.0004176077282406142027020024 * (h26) - 0.0005712689305005380505445012 * (h6) - 0.0007136696604607006702916672 * (h25) + 0.0009462690062738290204188973 * (h7) + 0.0011578315711606287832097228 * (h24) - 0.0014979701011105211582580266 * (h8) - 0.0018034764393366578029420655 * (h23) + 0.0022901459526252104272059373 * (h9) + 0.0027248832800737489076570164 * (h22) - 0.0034168166415133641687640331 * (h10) - 0.0040374977682065471204508889 * (h21) + 0.0050364975077381779131058259 * (h11) + 0.0059496745483291358508326496 * (h20) - 0.0074652516214652716100563801 * (h12) - 0.0089125999900665549974254631 * (h19) + 0.0114792754733474382244917678 * (h13) + 0.0141675364477254431966324333 * (h18) - 0.0196798459780563698984234833 * (h14) - 0.0268493210130021989212600886 * (h17) + 0.0493231366585765024224130570 * (h15) + 0.1242518090095610094891753761 * (h16) + ) : ( idx == 3 ) ? ( + - 0.0000038417389529282175070538 * (h0) - 0.0000049913017360818245649881 * (h31) + 0.0000171034027145189642846960 * (h1) + 0.0000202598378664954129600197 * (h30) - 0.0000493180721931350330485694 * (h2) - 0.0000562616150274062706208682 * (h29) + 0.0001153907318793145767368835 * (h3) + 0.0001287472023828216752261433 * (h28) - 0.0002366195985770357893690496 * (h4) - 0.0002600153729756948675980177 * (h27) + 0.0004417469989478828773163399 * (h5) + 0.0004799571766397800996750700 * (h26) - 0.0007680759573169227902300626 * (h6) - 0.0008272135371227355401038683 * (h25) + 0.0012631838352285132756613883 * (h7) + 0.0013510528475350871892984861 * (h24) - 0.0019884895270683468349037781 * (h8) - 0.0021153789039776993430308494 * (h23) + 0.0030274929251044471571752137 * (h9) + 0.0032080415540193178529360107 * (h22) - 0.0045053751276789384336285416 * (h10) - 0.0047630834256236339804835289 * (h21) + 0.0066378972017938041305651353 * (h11) + 0.0070168447237937215180125783 * (h20) - 0.0098668871393735712443939789 * (h12) - 0.0104667799331977975224594601 * (h19) + 0.0153166468500505557198687612 * (h13) + 0.0164274034804239160711958334 * (h18) - 0.0269968600415785263402224103 * (h14) - 0.0299247119219566287684486383 * (h17) + 0.0771329265309410178064197794 * (h15) + 0.1031056515787995148114575272 * (h16) + ) : ( idx == 4 ) ? ( + - 0.0000038417389529282175070538 * (h31) - 0.0000049913017360818245649881 * (h0) + 0.0000171034027145189642846960 * (h30) + 0.0000202598378664954129600197 * (h1) - 0.0000493180721931350330485694 * (h29) - 0.0000562616150274062706208682 * (h2) + 0.0001153907318793145767368835 * (h28) + 0.0001287472023828216752261433 * (h3) - 0.0002366195985770357893690496 * (h27) - 0.0002600153729756948675980177 * (h4) + 0.0004417469989478828773163399 * (h26) + 0.0004799571766397800996750700 * (h5) - 0.0007680759573169227902300626 * (h25) - 0.0008272135371227355401038683 * (h6) + 0.0012631838352285132756613883 * (h24) + 0.0013510528475350871892984861 * (h7) - 0.0019884895270683468349037781 * (h23) - 0.0021153789039776993430308494 * (h8) + 0.0030274929251044471571752137 * (h22) + 0.0032080415540193178529360107 * (h9) - 0.0045053751276789384336285416 * (h21) - 0.0047630834256236339804835289 * (h10) + 0.0066378972017938041305651353 * (h20) + 0.0070168447237937215180125783 * (h11) - 0.0098668871393735712443939789 * (h19) - 0.0104667799331977975224594601 * (h12) + 0.0153166468500505557198687612 * (h18) + 0.0164274034804239160711958334 * (h13) - 0.0269968600415785263402224103 * (h17) - 0.0299247119219566287684486383 * (h14) + 0.0771329265309410178064197794 * (h16) + 0.1031056515787995148114575272 * (h15) + ) : ( idx == 5 ) ? ( + - 0.0000023056658627698541076635 * (h31) - 0.0000050891494452033029534778 * (h0) + 0.0000114877644211315289136206 * (h30) + 0.0000191104631386301232010092 * (h1) - 0.0000345272925086780559035711 * (h29) - 0.0000512749277693074691111645 * (h2) + 0.0000827178714405936102048097 * (h28) + 0.0001149102035842205631359023 * (h3) - 0.0001723539708339743366412311 * (h27) - 0.0002287177507233066251456088 * (h4) + 0.0003255815601830407135519607 * (h26) + 0.0004176077282406142027020024 * (h5) - 0.0005712689305005380505445012 * (h25) - 0.0007136696604607006702916672 * (h6) + 0.0009462690062738290204188973 * (h24) + 0.0011578315711606287832097228 * (h7) - 0.0014979701011105211582580266 * (h23) - 0.0018034764393366578029420655 * (h8) + 0.0022901459526252104272059373 * (h22) + 0.0027248832800737489076570164 * (h9) - 0.0034168166415133641687640331 * (h21) - 0.0040374977682065471204508889 * (h10) + 0.0050364975077381779131058259 * (h20) + 0.0059496745483291358508326496 * (h11) - 0.0074652516214652716100563801 * (h19) - 0.0089125999900665549974254631 * (h12) + 0.0114792754733474382244917678 * (h18) + 0.0141675364477254431966324333 * (h13) - 0.0196798459780563698984234833 * (h17) - 0.0268493210130021989212600886 * (h14) + 0.0493231366585765024224130570 * (h16) + 0.1242518090095610094891753761 * (h15) + ) : ( idx == 6 ) ? ( + - 0.0000009216163905494045722593 * (h31) - 0.0000035291979415113102401481 * (h0) + 0.0000052919032927216100019199 * (h30) + 0.0000123958706921492685588179 * (h1) - 0.0000166540129366328577462629 * (h29) - 0.0000322235527615813324275179 * (h2) + 0.0000409201899831446077584682 * (h28) + 0.0000708053129213741803179433 * (h3) - 0.0000867068814117001569015050 * (h27) - 0.0001389836178512661554913799 * (h4) + 0.0001658122848563750508388975 * (h26) + 0.0002511144059100562536158974 * (h5) - 0.0002936898920988913674542942 * (h25) - 0.0004256352483052204603401758 * (h6) + 0.0004900966398705362001356201 * (h24) + 0.0006860848810972315246423103 * (h7) - 0.0007803579819763274780936024 * (h23) - 0.0010633640942445924011672265 * (h8) + 0.0011982436734402183986514245 * (h22) + 0.0016010335807077485676536144 * (h9) - 0.0017927564657956164377583530 * (h21) - 0.0023681119238136930787996803 * (h10) + 0.0026447638629933270353056241 * (h20) + 0.0034921809684760308188644640 * (h11) - 0.0039113827965556041688088840 * (h19) - 0.0052577752274794416556535914 * (h12) + 0.0059656942323318851856273071 * (h18) + 0.0084823175454419585950205374 * (h13) - 0.0099897750993028482796587397 * (h17) - 0.0168668147466190382344208842 * (h14) + 0.0227192372722485741443065876 * (h16) + 0.1380593641728841691751483722 * (h15) + ) + ); + +function init_upSampler8() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, h194, h195, h196, h197, h198, h199, h200, h201, h202, h203, h204, h205, h206, h207, h208, h209, h210, h211, h212, h213, h214, h215, h216, h217, h218, h219, h220, h221, h222, h223, h224, h225, h226, h227, h228, h229, h230, h231, h232, h233, h234, h235, h236, h237, h238, h239, h240, h241, h242, h243, h244, h245, h246, h247, h248, h249, h250, h251, h252, h253, h254, h255, h256) + global() + local() + ( + h0 = h1 = h2 = h3 = h4 = h5 = h6 = h7 = h8 = h9 = h10 = h11 = h12 = h13 = h14 = h15 = h16 = h17 = h18 = h19 = h20 = h21 = h22 = h23 = h24 = h25 = h26 = h27 = h28 = h29 = h30 = h31 = h32 = h33 = h34 = h35 = h36 = h37 = h38 = h39 = h40 = h41 = h42 = h43 = h44 = h45 = h46 = h47 = h48 = h49 = h50 = h51 = h52 = h53 = h54 = h55 = h56 = h57 = h58 = h59 = h60 = h61 = h62 = h63 = h64 = h65 = h66 = h67 = h68 = h69 = h70 = h71 = h72 = h73 = h74 = h75 = h76 = h77 = h78 = h79 = h80 = h81 = h82 = h83 = h84 = h85 = h86 = h87 = h88 = h89 = h90 = h91 = h92 = h93 = h94 = h95 = h96 = h97 = h98 = h99 = h100 = h101 = h102 = h103 = h104 = h105 = h106 = h107 = h108 = h109 = h110 = h111 = h112 = h113 = h114 = h115 = h116 = h117 = h118 = h119 = h120 = h121 = h122 = h123 = h124 = h125 = h126 = h127 = h128 = h129 = h130 = h131 = h132 = h133 = h134 = h135 = h136 = h137 = h138 = h139 = h140 = h141 = h142 = h143 = h144 = h145 = h146 = h147 = h148 = h149 = h150 = h151 = h152 = h153 = h154 = h155 = h156 = h157 = h158 = h159 = h160 = h161 = h162 = h163 = h164 = h165 = h166 = h167 = h168 = h169 = h170 = h171 = h172 = h173 = h174 = h175 = h176 = h177 = h178 = h179 = h180 = h181 = h182 = h183 = h184 = h185 = h186 = h187 = h188 = h189 = h190 = h191 = h192 = h193 = h194 = h195 = h196 = h197 = h198 = h199 = h200 = h201 = h202 = h203 = h204 = h205 = h206 = h207 = h208 = h209 = h210 = h211 = h212 = h213 = h214 = h215 = h216 = h217 = h218 = h219 = h220 = h221 = h222 = h223 = h224 = h225 = h226 = h227 = h228 = h229 = h230 = h231 = h232 = h233 = h234 = h235 = h236 = h237 = h238 = h239 = h240 = h241 = h242 = h243 = h244 = h245 = h246 = h247 = h248 = h249 = h250 = h251 = h252 = h253 = h254 = h255 = h256 = 0 + ); + +function update_upHist8(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, idx) + global() + local() + ( + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function update_downHist8(x) + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, h194, h195, h196, h197, h198, h199, h200, h201, h202, h203, h204, h205, h206, h207, h208, h209, h210, h211, h212, h213, h214, h215, h216, h217, h218, h219, h220, h221, h222, h223, h224, h225, h226, h227, h228, h229, h230, h231, h232, h233, h234, h235, h236, h237, h238, h239, h240, h241, h242, h243, h244, h245, h246, h247, h248, h249, h250, h251, h252, h253, h254, h255, h256, h257, idx) + global() + local() + ( + h257 = h256; + h256 = h255; + h255 = h254; + h254 = h253; + h253 = h252; + h252 = h251; + h251 = h250; + h250 = h249; + h249 = h248; + h248 = h247; + h247 = h246; + h246 = h245; + h245 = h244; + h244 = h243; + h243 = h242; + h242 = h241; + h241 = h240; + h240 = h239; + h239 = h238; + h238 = h237; + h237 = h236; + h236 = h235; + h235 = h234; + h234 = h233; + h233 = h232; + h232 = h231; + h231 = h230; + h230 = h229; + h229 = h228; + h228 = h227; + h227 = h226; + h226 = h225; + h225 = h224; + h224 = h223; + h223 = h222; + h222 = h221; + h221 = h220; + h220 = h219; + h219 = h218; + h218 = h217; + h217 = h216; + h216 = h215; + h215 = h214; + h214 = h213; + h213 = h212; + h212 = h211; + h211 = h210; + h210 = h209; + h209 = h208; + h208 = h207; + h207 = h206; + h206 = h205; + h205 = h204; + h204 = h203; + h203 = h202; + h202 = h201; + h201 = h200; + h200 = h199; + h199 = h198; + h198 = h197; + h197 = h196; + h196 = h195; + h195 = h194; + h194 = h193; + h193 = h192; + h192 = h191; + h191 = h190; + h190 = h189; + h189 = h188; + h188 = h187; + h187 = h186; + h186 = h185; + h185 = h184; + h184 = h183; + h183 = h182; + h182 = h181; + h181 = h180; + h180 = h179; + h179 = h178; + h178 = h177; + h177 = h176; + h176 = h175; + h175 = h174; + h174 = h173; + h173 = h172; + h172 = h171; + h171 = h170; + h170 = h169; + h169 = h168; + h168 = h167; + h167 = h166; + h166 = h165; + h165 = h164; + h164 = h163; + h163 = h162; + h162 = h161; + h161 = h160; + h160 = h159; + h159 = h158; + h158 = h157; + h157 = h156; + h156 = h155; + h155 = h154; + h154 = h153; + h153 = h152; + h152 = h151; + h151 = h150; + h150 = h149; + h149 = h148; + h148 = h147; + h147 = h146; + h146 = h145; + h145 = h144; + h144 = h143; + h143 = h142; + h142 = h141; + h141 = h140; + h140 = h139; + h139 = h138; + h138 = h137; + h137 = h136; + h136 = h135; + h135 = h134; + h134 = h133; + h133 = h132; + h132 = h131; + h131 = h130; + h130 = h129; + h129 = h128; + h128 = h127; + h127 = h126; + h126 = h125; + h125 = h124; + h124 = h123; + h123 = h122; + h122 = h121; + h121 = h120; + h120 = h119; + h119 = h118; + h118 = h117; + h117 = h116; + h116 = h115; + h115 = h114; + h114 = h113; + h113 = h112; + h112 = h111; + h111 = h110; + h110 = h109; + h109 = h108; + h108 = h107; + h107 = h106; + h106 = h105; + h105 = h104; + h104 = h103; + h103 = h102; + h102 = h101; + h101 = h100; + h100 = h99; + h99 = h98; + h98 = h97; + h97 = h96; + h96 = h95; + h95 = h94; + h94 = h93; + h93 = h92; + h92 = h91; + h91 = h90; + h90 = h89; + h89 = h88; + h88 = h87; + h87 = h86; + h86 = h85; + h85 = h84; + h84 = h83; + h83 = h82; + h82 = h81; + h81 = h80; + h80 = h79; + h79 = h78; + h78 = h77; + h77 = h76; + h76 = h75; + h75 = h74; + h74 = h73; + h73 = h72; + h72 = h71; + h71 = h70; + h70 = h69; + h69 = h68; + h68 = h67; + h67 = h66; + h66 = h65; + h65 = h64; + h64 = h63; + h63 = h62; + h62 = h61; + h61 = h60; + h60 = h59; + h59 = h58; + h58 = h57; + h57 = h56; + h56 = h55; + h55 = h54; + h54 = h53; + h53 = h52; + h52 = h51; + h51 = h50; + h50 = h49; + h49 = h48; + h48 = h47; + h47 = h46; + h46 = h45; + h45 = h44; + h44 = h43; + h43 = h42; + h42 = h41; + h41 = h40; + h40 = h39; + h39 = h38; + h38 = h37; + h37 = h36; + h36 = h35; + h35 = h34; + h34 = h33; + h33 = h32; + h32 = h31; + h31 = h30; + h30 = h29; + h29 = h28; + h28 = h27; + h27 = h26; + h26 = h25; + h25 = h24; + h24 = h23; + h23 = h22; + h22 = h21; + h21 = h20; + h20 = h19; + h19 = h18; + h18 = h17; + h17 = h16; + h16 = h15; + h15 = h14; + h14 = h13; + h13 = h12; + h12 = h11; + h11 = h10; + h10 = h9; + h9 = h8; + h8 = h7; + h7 = h6; + h6 = h5; + h5 = h4; + h4 = h3; + h3 = h2; + h2 = h1; + h1 = h0; + + h0 = x; + idx = -1; + ); + +function downSample8() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, h194, h195, h196, h197, h198, h199, h200, h201, h202, h203, h204, h205, h206, h207, h208, h209, h210, h211, h212, h213, h214, h215, h216, h217, h218, h219, h220, h221, h222, h223, h224, h225, h226, h227, h228, h229, h230, h231, h232, h233, h234, h235, h236, h237, h238, h239, h240, h241, h242, h243, h244, h245, h246, h247, h248, h249, h250, h251, h252, h253, h254, h255, h256) + global() + local() + ( + - 0.0000000000000000000024795428 * (h0 + h256) - 0.0000006803148294403403240085 * (h1 + h255) - 0.0000016878615713457110004741 * (h2 + h254) - 0.0000028681134349177630976982 * (h3 + h253) - 0.0000039421004769007114912761 * (h4 + h252) - 0.0000045389867265569728643987 * (h5 + h251) - 0.0000042644547466971042550508 * (h6 + h250) - 0.0000027976177647387653767326 * (h7 + h249) + 0.0000000000000000000472553190 * (h8 + h248) + 0.0000039872596009206984652437 * (h9 + h247) + 0.0000086852048459848934646322 * (h10 + h246) + 0.0000132827546779635278568392 * (h11 + h245) + 0.0000167224097929462299538025 * (h12 + h244) + 0.0000178674632702761483995547 * (h13 + h243) + 0.0000157338256917918116364451 * (h14 + h242) + 0.0000097507875923091769565423 * (h15 + h241) - 0.0000000000000000000498088559 * (h16 + h240) - 0.0000126251762581024824187020 * (h17 + h239) - 0.0000263938281141404454236982 * (h18 + h238) - 0.0000388824361638155527407662 * (h19 + h237) - 0.0000472997476595074615047382 * (h20 + h236) - 0.0000489646661868617930806272 * (h21 + h235) - 0.0000418723889793229557608305 * (h22 + h234) - 0.0000252519656178402472754187 * (h23 + h233) - 0.0000000000000000001438053045 * (h24 + h232) + 0.0000311231272746631258446955 * (h25 + h231) + 0.0000636231004463845648683185 * (h26 + h230) + 0.0000917682144134630920764492 * (h27 + h229) + 0.0001094282094774080588573534 * (h28 + h228) + 0.0001111586126348065953770364 * (h29 + h227) + 0.0000933673674062485749744825 * (h30 + h226) + 0.0000553542435157647824141812 * (h31 + h225) - 0.0000000000000000002324640304 * (h32 + h224) - 0.0000660902200866433941518763 * (h33 + h223) - 0.0001331147269754704765866438 * (h34 + h222) - 0.0001892936360503736574305289 * (h35 + h221) - 0.0002226696266284176580277365 * (h36 + h220) - 0.0002232547031576829999963141 * (h37 + h219) - 0.0001851826981371344370188442 * (h38 + h218) - 0.0001084705085018196140615038 * (h39 + h217) + 0.0000000000000000015012574849 * (h40 + h216) + 0.0001265847230504769471790688 * (h41 + h215) + 0.0002522177457438689479087002 * (h42 + h214) + 0.0003549389116972150189609214 * (h43 + h213) + 0.0004133332925039939482851625 * (h44 + h212) + 0.0004104001176654410308793086 * (h45 + h211) + 0.0003372197178938211967365313 * (h46 + h210) + 0.0001957317937978928824600128 * (h47 + h209) - 0.0000000000000000006711159034 * (h48 + h208) - 0.0002244787857641317000995801 * (h49 + h207) - 0.0004435737224490943122340303 * (h50 + h206) - 0.0006192262890162011186243052 * (h51 + h205) - 0.0007154952680716239465930073 * (h52 + h204) - 0.0007050588799140777417767678 * (h53 + h203) - 0.0005750949855954497159579719 * (h54 + h202) - 0.0003314289517209756679057275 * (h55 + h201) + 0.0000000000000000010156922373 * (h56 + h200) + 0.0003749540685660616165866821 * (h57 + h199) + 0.0007360957813070443224792716 * (h58 + h198) + 0.0010210953324857666418140623 * (h59 + h197) + 0.0011726070564972029559164257 * (h60 + h196) + 0.0011486254180071819430003499 * (h61 + h195) + 0.0009314865780958819611867749 * (h62 + h194) + 0.0005338098045430211780956742 * (h63 + h193) - 0.0000000000000000014462337417 * (h64 + h192) - 0.0005974646196974044186703279 * (h65 + h191) - 0.0011669308174394052782241182 * (h66 + h190) - 0.0016107356205013140335730037 * (h67 + h189) - 0.0018408885034394330965090703 * (h68 + h188) - 0.0017948976374194869267547636 * (h69 + h187) - 0.0014490822452257363928129763 * (h70 + h186) - 0.0008268502619856007073914639 * (h71 + h185) + 0.0000000000000000019519978868 * (h72 + h184) + 0.0009179229478490426872086538 * (h73 + h183) + 0.0017859505793010185207420060 * (h74 + h182) + 0.0024561134720910799897342081 * (h75 + h181) + 0.0027971883044523668943037720 * (h76 + h180) + 0.0027181601816018427855703443 * (h77 + h179) + 0.0021874679775906471189406144 * (h78 + h178) + 0.0012444064867506224314475105 * (h79 + h177) - 0.0000000000000000025109017154 * (h80 + h176) - 0.0013738582340210904204208520 * (h81 + h175) - 0.0026663826946624288351250787 * (h82 + h174) - 0.0036584740147181330632841778 * (h83 + h173) - 0.0041577229836155266823327636 * (h84 + h172) - 0.0040325334106176800863519105 * (h85 + h171) - 0.0032396929722074605494108734 * (h86 + h170) - 0.0018402530380006477950249888 * (h87 + h169) + 0.0000000000000000030904021244 * (h88 + h168) + 0.0020270410001706328645409982 * (h89 + h167) + 0.0039310202882702543689119601 * (h90 + h166) + 0.0053908712726001449186408188 * (h91 + h165) + 0.0061250733382556855899370163 * (h92 + h164) + 0.0059409842974412338176271042 * (h93 + h163) + 0.0047746895751997310911041161 * (h94 + h162) + 0.0027140953073984757336345464 * (h95 + h161) - 0.0000000000000000036501824408 * (h96 + h160) - 0.0029971025945027254464014810 * (h97 + h159) - 0.0058231027226569032073655308 * (h98 + h158) - 0.0080041219695127872185702600 * (h99 + h157) - 0.0091197713239062373757892743 * (h100 + h156) - 0.0088752483712328505277566748 * (h101 + h155) - 0.0071609418487707261063990316 * (h102 + h154) - 0.0040891358023439072777449610 * (h103 + h153) + 0.0000000000000000041463994238 * (h104 + h152) + 0.0045669535926136251707818658 * (h105 + h151) + 0.0089348810419893238965460824 * (h106 + h150) + 0.0123789089831678692649186146 * (h107 + h149) + 0.0142319802426614707563379270 * (h108 + h148) + 0.0139931707668577622744043865 * (h109 + h147) + 0.0114229127110041708131893401 * (h110 + h146) + 0.0066102333763929837021078306 * (h111 + h145) - 0.0000000000000000045369197049 * (h112 + h144) - 0.0076270396172587791999708529 * (h113 + h143) - 0.0152224937813932176267073260 * (h114 + h142) - 0.0215812481641791537034791304 * (h115 + h141) - 0.0254832086874689986433217825 * (h116 + h140) - 0.0258490393089624570510665080 * (h117 + h139) - 0.0218901744962703079244725757 * (h118 + h138) - 0.0132330629227923185498028147 * (h119 + h137) + 0.0000000000000000047867420732 * (h120 + h136) + 0.0171661936069081241806877358 * (h121 + h135) + 0.0371395779530556482961323184 * (h122 + h134) + 0.0584086617290817261549662476 * (h123 + h133) + 0.0792243581838370930503501199 * (h124 + h132) + 0.0977817739001537733489755055 * (h125 + h131) + 0.1124145083693663671464690879 * (h126 + h130) + 0.1217780739691688707271310932 * (h127 + h129) + 0.1250000000000000000000000000 * (h128) + ); + + +function upSample8() + instance(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, h25, h26, h27, h28, h29, h30, h31, h32, h33, h34, h35, h36, h37, h38, h39, h40, h41, h42, h43, h44, h45, h46, h47, h48, h49, h50, h51, h52, h53, h54, h55, h56, h57, h58, h59, h60, h61, h62, h63, h64, h65, h66, h67, h68, h69, h70, h71, h72, h73, h74, h75, h76, h77, h78, h79, h80, h81, h82, h83, h84, h85, h86, h87, h88, h89, h90, h91, h92, h93, h94, h95, h96, h97, h98, h99, h100, h101, h102, h103, h104, h105, h106, h107, h108, h109, h110, h111, h112, h113, h114, h115, h116, h117, h118, h119, h120, h121, h122, h123, h124, h125, h126, h127, h128, h129, h130, h131, h132, h133, h134, h135, h136, h137, h138, h139, h140, h141, h142, h143, h144, h145, h146, h147, h148, h149, h150, h151, h152, h153, h154, h155, h156, h157, h158, h159, h160, h161, h162, h163, h164, h165, h166, h167, h168, h169, h170, h171, h172, h173, h174, h175, h176, h177, h178, h179, h180, h181, h182, h183, h184, h185, h186, h187, h188, h189, h190, h191, h192, h193, h194, h195, h196, h197, h198, h199, h200, h201, h202, h203, h204, h205, h206, h207, h208, h209, h210, h211, h212, h213, h214, h215, h216, h217, h218, h219, h220, h221, h222, h223, h224, h225, h226, h227, h228, h229, h230, h231, h232, h233, h234, h235, h236, h237, h238, h239, h240, h241, h242, h243, h244, h245, h246, h247, h248, h249, h250, h251, h252, h253, h254, h255, h256, idx ) + global() + local() + ( + idx += 1; + ( idx == 0 ) ? ( + - 0.0000000000000000000024795428 * (h0 + h32) + 0.0000000000000000000472553190 * (h1 + h31) - 0.0000000000000000000498088559 * (h2 + h30) - 0.0000000000000000001438053045 * (h3 + h29) - 0.0000000000000000002324640304 * (h4 + h28) + 0.0000000000000000015012574849 * (h5 + h27) - 0.0000000000000000006711159034 * (h6 + h26) + 0.0000000000000000010156922373 * (h7 + h25) - 0.0000000000000000014462337417 * (h8 + h24) + 0.0000000000000000019519978868 * (h9 + h23) - 0.0000000000000000025109017154 * (h10 + h22) + 0.0000000000000000030904021244 * (h11 + h21) - 0.0000000000000000036501824408 * (h12 + h20) + 0.0000000000000000041463994238 * (h13 + h19) - 0.0000000000000000045369197049 * (h14 + h18) + 0.0000000000000000047867420732 * (h15 + h17) + 0.1250000000000000000000000000 * (h16) + ) : ( idx == 1 ) ? ( + - 0.0000006803148294403403240085 * (h0) - 0.0000027976177647387653767326 * (h31) + 0.0000039872596009206984652437 * (h1) + 0.0000097507875923091769565423 * (h30) - 0.0000126251762581024824187020 * (h2) - 0.0000252519656178402472754187 * (h29) + 0.0000311231272746631258446955 * (h3) + 0.0000553542435157647824141812 * (h28) - 0.0000660902200866433941518763 * (h4) - 0.0001084705085018196140615038 * (h27) + 0.0001265847230504769471790688 * (h5) + 0.0001957317937978928824600128 * (h26) - 0.0002244787857641317000995801 * (h6) - 0.0003314289517209756679057275 * (h25) + 0.0003749540685660616165866821 * (h7) + 0.0005338098045430211780956742 * (h24) - 0.0005974646196974044186703279 * (h8) - 0.0008268502619856007073914639 * (h23) + 0.0009179229478490426872086538 * (h9) + 0.0012444064867506224314475105 * (h22) - 0.0013738582340210904204208520 * (h10) - 0.0018402530380006477950249888 * (h21) + 0.0020270410001706328645409982 * (h11) + 0.0027140953073984757336345464 * (h20) - 0.0029971025945027254464014810 * (h12) - 0.0040891358023439072777449610 * (h19) + 0.0045669535926136251707818658 * (h13) + 0.0066102333763929837021078306 * (h18) - 0.0076270396172587791999708529 * (h14) - 0.0132330629227923185498028147 * (h17) + 0.0171661936069081241806877358 * (h15) + 0.1217780739691688707271310932 * (h16) + ) : ( idx == 2 ) ? ( + - 0.0000016878615713457110004741 * (h0) - 0.0000042644547466971042550508 * (h31) + 0.0000086852048459848934646322 * (h1) + 0.0000157338256917918116364451 * (h30) - 0.0000263938281141404454236982 * (h2) - 0.0000418723889793229557608305 * (h29) + 0.0000636231004463845648683185 * (h3) + 0.0000933673674062485749744825 * (h28) - 0.0001331147269754704765866438 * (h4) - 0.0001851826981371344370188442 * (h27) + 0.0002522177457438689479087002 * (h5) + 0.0003372197178938211967365313 * (h26) - 0.0004435737224490943122340303 * (h6) - 0.0005750949855954497159579719 * (h25) + 0.0007360957813070443224792716 * (h7) + 0.0009314865780958819611867749 * (h24) - 0.0011669308174394052782241182 * (h8) - 0.0014490822452257363928129763 * (h23) + 0.0017859505793010185207420060 * (h9) + 0.0021874679775906471189406144 * (h22) - 0.0026663826946624288351250787 * (h10) - 0.0032396929722074605494108734 * (h21) + 0.0039310202882702543689119601 * (h11) + 0.0047746895751997310911041161 * (h20) - 0.0058231027226569032073655308 * (h12) - 0.0071609418487707261063990316 * (h19) + 0.0089348810419893238965460824 * (h13) + 0.0114229127110041708131893401 * (h18) - 0.0152224937813932176267073260 * (h14) - 0.0218901744962703079244725757 * (h17) + 0.0371395779530556482961323184 * (h15) + 0.1124145083693663671464690879 * (h16) + ) : ( idx == 3 ) ? ( + - 0.0000028681134349177630976982 * (h0) - 0.0000045389867265569728643987 * (h31) + 0.0000132827546779635278568392 * (h1) + 0.0000178674632702761483995547 * (h30) - 0.0000388824361638155527407662 * (h2) - 0.0000489646661868617930806272 * (h29) + 0.0000917682144134630920764492 * (h3) + 0.0001111586126348065953770364 * (h28) - 0.0001892936360503736574305289 * (h4) - 0.0002232547031576829999963141 * (h27) + 0.0003549389116972150189609214 * (h5) + 0.0004104001176654410308793086 * (h26) - 0.0006192262890162011186243052 * (h6) - 0.0007050588799140777417767678 * (h25) + 0.0010210953324857666418140623 * (h7) + 0.0011486254180071819430003499 * (h24) - 0.0016107356205013140335730037 * (h8) - 0.0017948976374194869267547636 * (h23) + 0.0024561134720910799897342081 * (h9) + 0.0027181601816018427855703443 * (h22) - 0.0036584740147181330632841778 * (h10) - 0.0040325334106176800863519105 * (h21) + 0.0053908712726001449186408188 * (h11) + 0.0059409842974412338176271042 * (h20) - 0.0080041219695127872185702600 * (h12) - 0.0088752483712328505277566748 * (h19) + 0.0123789089831678692649186146 * (h13) + 0.0139931707668577622744043865 * (h18) - 0.0215812481641791537034791304 * (h14) - 0.0258490393089624570510665080 * (h17) + 0.0584086617290817261549662476 * (h15) + 0.0977817739001537733489755055 * (h16) + ) : ( idx == 4 ) ? ( + - 0.0000039421004769007114912761 * (h0 + h31) + 0.0000167224097929462299538025 * (h1 + h30) - 0.0000472997476595074615047382 * (h2 + h29) + 0.0001094282094774080588573534 * (h3 + h28) - 0.0002226696266284176580277365 * (h4 + h27) + 0.0004133332925039939482851625 * (h5 + h26) - 0.0007154952680716239465930073 * (h6 + h25) + 0.0011726070564972029559164257 * (h7 + h24) - 0.0018408885034394330965090703 * (h8 + h23) + 0.0027971883044523668943037720 * (h9 + h22) - 0.0041577229836155266823327636 * (h10 + h21) + 0.0061250733382556855899370163 * (h11 + h20) - 0.0091197713239062373757892743 * (h12 + h19) + 0.0142319802426614707563379270 * (h13 + h18) - 0.0254832086874689986433217825 * (h14 + h17) + 0.0792243581838370930503501199 * (h15 + h16) + ) : ( idx == 5 ) ? ( + - 0.0000028681134349177630976982 * (h31) - 0.0000045389867265569728643987 * (h0) + 0.0000132827546779635278568392 * (h30) + 0.0000178674632702761483995547 * (h1) - 0.0000388824361638155527407662 * (h29) - 0.0000489646661868617930806272 * (h2) + 0.0000917682144134630920764492 * (h28) + 0.0001111586126348065953770364 * (h3) - 0.0001892936360503736574305289 * (h27) - 0.0002232547031576829999963141 * (h4) + 0.0003549389116972150189609214 * (h26) + 0.0004104001176654410308793086 * (h5) - 0.0006192262890162011186243052 * (h25) - 0.0007050588799140777417767678 * (h6) + 0.0010210953324857666418140623 * (h24) + 0.0011486254180071819430003499 * (h7) - 0.0016107356205013140335730037 * (h23) - 0.0017948976374194869267547636 * (h8) + 0.0024561134720910799897342081 * (h22) + 0.0027181601816018427855703443 * (h9) - 0.0036584740147181330632841778 * (h21) - 0.0040325334106176800863519105 * (h10) + 0.0053908712726001449186408188 * (h20) + 0.0059409842974412338176271042 * (h11) - 0.0080041219695127872185702600 * (h19) - 0.0088752483712328505277566748 * (h12) + 0.0123789089831678692649186146 * (h18) + 0.0139931707668577622744043865 * (h13) - 0.0215812481641791537034791304 * (h17) - 0.0258490393089624570510665080 * (h14) + 0.0584086617290817261549662476 * (h16) + 0.0977817739001537733489755055 * (h15) + ) : ( idx == 6 ) ? ( + - 0.0000016878615713457110004741 * (h31) - 0.0000042644547466971042550508 * (h0) + 0.0000086852048459848934646322 * (h30) + 0.0000157338256917918116364451 * (h1) - 0.0000263938281141404454236982 * (h29) - 0.0000418723889793229557608305 * (h2) + 0.0000636231004463845648683185 * (h28) + 0.0000933673674062485749744825 * (h3) - 0.0001331147269754704765866438 * (h27) - 0.0001851826981371344370188442 * (h4) + 0.0002522177457438689479087002 * (h26) + 0.0003372197178938211967365313 * (h5) - 0.0004435737224490943122340303 * (h25) - 0.0005750949855954497159579719 * (h6) + 0.0007360957813070443224792716 * (h24) + 0.0009314865780958819611867749 * (h7) - 0.0011669308174394052782241182 * (h23) - 0.0014490822452257363928129763 * (h8) + 0.0017859505793010185207420060 * (h22) + 0.0021874679775906471189406144 * (h9) - 0.0026663826946624288351250787 * (h21) - 0.0032396929722074605494108734 * (h10) + 0.0039310202882702543689119601 * (h20) + 0.0047746895751997310911041161 * (h11) - 0.0058231027226569032073655308 * (h19) - 0.0071609418487707261063990316 * (h12) + 0.0089348810419893238965460824 * (h18) + 0.0114229127110041708131893401 * (h13) - 0.0152224937813932176267073260 * (h17) - 0.0218901744962703079244725757 * (h14) + 0.0371395779530556482961323184 * (h16) + 0.1124145083693663671464690879 * (h15) + ) : ( idx == 7 ) ? ( + - 0.0000006803148294403403240085 * (h31) - 0.0000027976177647387653767326 * (h0) + 0.0000039872596009206984652437 * (h30) + 0.0000097507875923091769565423 * (h1) - 0.0000126251762581024824187020 * (h29) - 0.0000252519656178402472754187 * (h2) + 0.0000311231272746631258446955 * (h28) + 0.0000553542435157647824141812 * (h3) - 0.0000660902200866433941518763 * (h27) - 0.0001084705085018196140615038 * (h4) + 0.0001265847230504769471790688 * (h26) + 0.0001957317937978928824600128 * (h5) - 0.0002244787857641317000995801 * (h25) - 0.0003314289517209756679057275 * (h6) + 0.0003749540685660616165866821 * (h24) + 0.0005338098045430211780956742 * (h7) - 0.0005974646196974044186703279 * (h23) - 0.0008268502619856007073914639 * (h8) + 0.0009179229478490426872086538 * (h22) + 0.0012444064867506224314475105 * (h9) - 0.0013738582340210904204208520 * (h21) - 0.0018402530380006477950249888 * (h10) + 0.0020270410001706328645409982 * (h20) + 0.0027140953073984757336345464 * (h11) - 0.0029971025945027254464014810 * (h19) - 0.0040891358023439072777449610 * (h12) + 0.0045669535926136251707818658 * (h18) + 0.0066102333763929837021078306 * (h13) - 0.0076270396172587791999708529 * (h17) - 0.0132330629227923185498028147 * (h14) + 0.0171661936069081241806877358 * (h16) + 0.1217780739691688707271310932 * (h15) + ) + ); + +function upSample(N) + instance() + global() + local() +( (N==2) ? this.upSample2() + : (N==3) ? this.upSample3() + : (N==4) ? this.upSample4() + : (N==5) ? this.upSample5() + : (N==6) ? this.upSample6() + : (N==7) ? this.upSample7() + : (N==8) ? this.upSample8() +); + +function downSample(N) + instance() + global() + local() +( + (N==2) ? this.downSample2() + : (N==3) ? this.downSample3() + : (N==4) ? this.downSample4() + : (N==5) ? this.downSample5() + : (N==6) ? this.downSample6() + : (N==7) ? this.downSample7() + : (N==8) ? this.downSample8() +); + +function updateDownHist(N, x) + instance() + global() + local() +( + (N==2) ? this.update_downHist2(x) + : (N==3) ? this.update_downHist3(x) + : (N==4) ? this.update_downHist4(x) + : (N==5) ? this.update_downHist5(x) + : (N==6) ? this.update_downHist6(x) + : (N==7) ? this.update_downHist7(x) + : (N==8) ? this.update_downHist8(x) +); + +function updateUpHist(N, x) + instance() + global() + local() +( + (N==2) ? this.update_upHist2(x) + : (N==3) ? this.update_upHist3(x) + : (N==4) ? this.update_upHist4(x) + : (N==5) ? this.update_upHist5(x) + : (N==6) ? this.update_upHist6(x) + : (N==7) ? this.update_upHist7(x) + : (N==8) ? this.update_upHist8(x) +); + +function getFIRdelay(N) + instance() + global() + local() +( + (N==1) ? 0 + : (N==2) ? 32 + : (N==3) ? 32 + : (N==4) ? 32 + : (N==5) ? 32 + : (N==6) ? 32 + : (N==7) ? 32 + : (N==8) ? 32 +); +