X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=Audio.pde;h=1b84957d77a1d95aeb735e410d448a1914cd871f;hb=e0b9d8726c661f54f47340449037ac7f6b410de6;hp=06390bc6f1ca874f45fc816e47e82b855e13ba49;hpb=d33c2d1d64234dd5f54942a9b76afaec3833c206;p=SugarCubes.git diff --git a/Audio.pde b/Audio.pde old mode 100755 new mode 100644 index 06390bc..1b84957 --- a/Audio.pde +++ b/Audio.pde @@ -4,7 +4,7 @@ */ public static class GraphicEQ { - private final HeronLX lx; + private final LX lx; public final BasicParameter level = new BasicParameter("LVL", 0.5); public final BasicParameter range = new BasicParameter("RNGE", 0.5); @@ -19,7 +19,7 @@ public static class GraphicEQ { public final static int DEFAULT_NUM_BANDS = 16; - public GraphicEQ(HeronLX lx) { + public GraphicEQ(LX lx) { this(lx, DEFAULT_NUM_BANDS); } @@ -27,7 +27,7 @@ public static class GraphicEQ { * Note that the number of bands is a suggestion. Due to the FFT implementation * the actual number may be slightly different. */ - public GraphicEQ(HeronLX lx, int num) { + public GraphicEQ(LX lx, int num) { this.lx = lx; fft = new FFT(lx.audioInput().bufferSize(), lx.audioInput().sampleRate()); fft.window(FFT.HAMMING); @@ -35,12 +35,12 @@ public static class GraphicEQ { numBands = this.fft.avgSize(); bandVals = new LinearEnvelope[numBands]; for (int i = 0; i < bandVals.length; ++i) { - bandVals[i] = new LinearEnvelope(0, 0, 500).trigger(); + (bandVals[i] = new LinearEnvelope(0, 0, 500)).trigger(); } } - final float logTen = log(10); - public float log10(float val) { + static final float logTen = log(10); + public static float log10(float val) { return log(val) / logTen; } @@ -57,7 +57,7 @@ public static class GraphicEQ { return avg; } - public void run(int deltaMs) { + public void run(double deltaMs) { fft.forward(lx.audioInput().mix); float zeroDBReference = pow(10, 100*(1-level.getValuef())/20.); float decibelRange = 12 + range.getValuef() * 60; @@ -70,13 +70,13 @@ public static class GraphicEQ { float value = constrain(positiveDecibels / decibelRange, 0, 1); if (value > bandVals[i].getValuef()) { - bandVals[i].setEndVal(value, attack.getValuef() * 20).trigger(); + bandVals[i].setRangeFromHereTo(value, attack.getValuef() * 20).trigger(); } } for (LinearEnvelope band : bandVals) { band.run(deltaMs); if (!band.isRunning() && band.getValuef() > 0) { - band.setEndVal(0, release.getValuef() * 1600).trigger(); + band.setRangeFromHereTo(0, release.getValuef() * 1600).trigger(); } } }