// (c) Alex McLean 2005 // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. class Envelope { private float[] values; private int count, step; Envelope (float[] values) { this.values = values; count = values.length - 1; step = 1 / count; } float value (float percentage) { float result, diff, point; point = count * percentage; int a, b; a = int(point); b = int(point + 1); if (a < 0) { a = 0; } if (b > (count - 1)) { b = count - 1; } diff = values[b] - values[a]; result = values[a] + (diff * (point - a)); return(result); } }