package y0;

import b1.AbstractC0401a;
import c1.C0406c;
import com.jsyn.unitgen.j;
import com.jsyn.unitgen.k;
import com.jsyn.unitgen.l;
import com.jsyn.unitgen.n;
import com.jsyn.unitgen.q;
import com.jsyn.unitgen.u;
import com.jsyn.unitgen.v;
import com.jsyn.unitgen.y;
import q0.InterfaceC0696b;

/* JADX INFO: renamed from: y0.c, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C0746c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private InterfaceC0696b f7040a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private q f7041b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private a[] f7042c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private double f7043d;

    /* JADX INFO: renamed from: y0.c$a */
    private class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private v f7044a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private l f7045b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private com.jsyn.unitgen.h f7046c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private com.jsyn.unitgen.h f7047d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private com.jsyn.unitgen.d f7048e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private j f7049f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private k f7050g;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        private int f7053j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        private b f7054k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        private int f7055l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        private boolean f7056m;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        private double f7051h = 5.0d;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        private double f7052i = 0.16666666666666666d;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        h f7057n = new C0106a();

        /* JADX INFO: renamed from: y0.c$a$a, reason: collision with other inner class name */
        class C0106a implements h {
            C0106a() {
            }

            @Override // y0.h
            public void a(y yVar) {
                yVar.usePreset(a.this.f7053j);
                a.this.c(yVar);
            }
        }

        a(int i2) {
            this.f7055l = i2;
            if (i2 == 9) {
                this.f7056m = true;
                this.f7053j = 128;
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public void c(y yVar) {
            u unitGenerator = yVar.getUnitGenerator();
            x0.k kVar = (x0.k) unitGenerator.getPortByName(u.PORT_NAME_FREQUENCY_SCALER);
            if (kVar != null) {
                kVar.i();
                this.f7045b.f3275b.r(kVar);
            }
            x0.k kVar2 = (x0.k) unitGenerator.getPortByName(u.PORT_NAME_TIMBRE);
            if (kVar2 != null) {
                kVar2.i();
                this.f7046c.f3289b.r(kVar2);
                this.f7046c.f3288a.E(kVar2);
            }
            x0.k kVar3 = (x0.k) unitGenerator.getPortByName(u.PORT_NAME_PRESSURE);
            if (kVar3 != null) {
                kVar3.i();
                this.f7047d.f3289b.r(kVar3);
                this.f7047d.f3288a.E(kVar3);
            }
            yVar.getOutput().i();
            yVar.getOutput().r(this.f7049f.f3285a);
        }

        private int d(int i2) {
            return (this.f7055l << 8) + i2;
        }

        void e(int i2, double d2) {
            f(i2, d2, C0746c.this.f7040a.e());
        }

        void f(int i2, double d2, C0406c c0406c) {
            this.f7054k.f7062c.g(d(i2), c0406c);
        }

        void g(int i2, double d2) {
            h(i2, d2, C0746c.this.f7040a.e());
        }

        void h(int i2, double d2, C0406c c0406c) {
            this.f7054k.f7062c.h(d(i2), AbstractC0401a.b(i2), d2, this.f7057n, c0406c);
        }

        void i(int i2) {
            if (this.f7056m) {
                return;
            }
            int presetCount = i2 % this.f7054k.f7060a.getPresetCount();
            String str = this.f7054k.f7060a.getPresetNames()[presetCount];
            this.f7053j = presetCount;
        }

        public void j(double d2) {
            this.f7052i = d2 / 12.0d;
        }

        public void k(double d2) {
            this.f7050g.f3271b.v(d2);
        }

        public void l(double d2) {
            this.f7045b.f3274a.v(this.f7052i * d2);
        }

        public void m(double d2) {
            double dS = this.f7047d.f3288a.s();
            this.f7047d.f3288a.v(dS * Math.pow(this.f7047d.f3288a.r() / dS, d2));
        }

        public void n(double d2) {
            double dS = this.f7046c.f3288a.s();
            this.f7046c.f3288a.v(dS + (d2 * (this.f7046c.f3288a.r() - dS)));
        }

        public void o(double d2) {
            this.f7044a.f3293b.v(d2);
        }

        public void p(double d2) {
            this.f7048e.f3288a.v(Math.pow(63095.73444801944d, d2) * 1.5848931924611107E-5d);
        }

        void q(b bVar) {
            this.f7054k = bVar;
            InterfaceC0696b interfaceC0696b = C0746c.this.f7040a;
            l lVar = new l();
            this.f7045b = lVar;
            interfaceC0696b.a(lVar);
            InterfaceC0696b interfaceC0696b2 = C0746c.this.f7040a;
            n nVar = new n();
            this.f7044a = nVar;
            interfaceC0696b2.a(nVar);
            InterfaceC0696b interfaceC0696b3 = C0746c.this.f7040a;
            com.jsyn.unitgen.h hVar = new com.jsyn.unitgen.h();
            this.f7046c = hVar;
            interfaceC0696b3.a(hVar);
            this.f7046c.f3263c.v(0.02d);
            InterfaceC0696b interfaceC0696b4 = C0746c.this.f7040a;
            com.jsyn.unitgen.h hVar2 = new com.jsyn.unitgen.h();
            this.f7047d = hVar2;
            interfaceC0696b4.a(hVar2);
            this.f7047d.f3263c.v(0.02d);
            InterfaceC0696b interfaceC0696b5 = C0746c.this.f7040a;
            com.jsyn.unitgen.d dVar = new com.jsyn.unitgen.d();
            this.f7048e = dVar;
            interfaceC0696b5.a(dVar);
            this.f7048e.f3288a.v(1.0d);
            this.f7048e.f3240c.v(0.02d);
            InterfaceC0696b interfaceC0696b6 = C0746c.this.f7040a;
            j jVar = new j();
            this.f7049f = jVar;
            interfaceC0696b6.a(jVar);
            InterfaceC0696b interfaceC0696b7 = C0746c.this.f7040a;
            k kVar = new k();
            this.f7050g = kVar;
            interfaceC0696b7.a(kVar);
            this.f7045b.f3274a.C(true);
            this.f7044a.f3295d.r(this.f7045b.f3274a);
            this.f7044a.f3293b.v(u.FALSE);
            this.f7044a.f3292a.v(this.f7051h);
            this.f7048e.f3289b.r(this.f7049f.f3286b);
            this.f7049f.f3287c.r(this.f7050g.f3270a);
            this.f7050g.f3272c.q(0, C0746c.this.f7041b.f3282a, 0);
            this.f7050g.f3272c.q(1, C0746c.this.f7041b.f3283b, 0);
        }
    }

    /* JADX INFO: renamed from: y0.c$b */
    private class b {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private g f7060a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private y[] f7061b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private f f7062c;

        b(int i2, g gVar) {
            this.f7060a = gVar;
            this.f7061b = new y[i2];
            for (int i3 = 0; i3 < i2; i3++) {
                y yVarCreateUnitVoice = gVar.createUnitVoice();
                C0746c.this.f7040a.a(yVarCreateUnitVoice.getUnitGenerator());
                this.f7061b[i3] = yVarCreateUnitVoice;
            }
            this.f7062c = new f(this.f7061b);
        }
    }

    public C0746c() {
        this(16);
    }

    public x0.l c() {
        return this.f7041b.f3284c;
    }

    public void d(int i2, int i3, double d2) {
        this.f7042c[i2].e(i3, d2 * this.f7043d);
    }

    public void e(int i2, int i3, int i4) {
        d(i2, i3, ((double) i4) * 0.007874015748031496d);
    }

    public void f(int i2, int i3, double d2) {
        this.f7042c[i2].g(i3, d2 * this.f7043d);
    }

    public void g(int i2, int i3, int i4) {
        f(i2, i3, ((double) i4) * 0.007874015748031496d);
    }

    public void h(int i2, int i3) {
        this.f7042c[i2].i(i3);
    }

    public void i(int i2, double d2) {
        this.f7042c[i2].j(d2);
    }

    public void j(int i2, double d2) {
        this.f7042c[i2].k(d2);
    }

    public void k(int i2, double d2) {
        this.f7042c[i2].l(d2);
    }

    public void l(int i2, double d2) {
        this.f7042c[i2].m(d2);
    }

    public void m(int i2, double d2) {
        this.f7042c[i2].n(d2);
    }

    public void n(int i2, double d2) {
        this.f7042c[i2].o(d2);
    }

    public void o(int i2, double d2) {
        this.f7042c[i2].p(d2);
    }

    public void p(InterfaceC0696b interfaceC0696b, int i2, int i3, int i4, g gVar) {
        this.f7040a = interfaceC0696b;
        if (this.f7041b == null) {
            q qVar = new q();
            this.f7041b = qVar;
            interfaceC0696b.a(qVar);
        }
        b bVar = new b(i4 * i3, gVar);
        for (int i5 = 0; i5 < i3; i5++) {
            this.f7042c[i2 + i5].q(bVar);
        }
    }

    public C0746c(int i2) {
        this.f7043d = 0.25d;
        this.f7042c = new a[i2];
        int i3 = 0;
        while (true) {
            a[] aVarArr = this.f7042c;
            if (i3 >= aVarArr.length) {
                return;
            }
            aVarArr[i3] = new a(i3);
            i3++;
        }
    }
}
