void fitAU( byte [] sample, Graph in) { double avg = in.avg(); double tmp = 0.0; double ratio =0.0; int count=0; double factor1 =1.0; double factor2 = 0.0; double yminimum=Double.POSITIVE_INFINITY; double ymaximum=Double.NEGATIVE_INFINITY; if (in.ymin() < 0.0) factor2 = Math.abs(in.ymin()); // fix the samples to valid samples // if (in.ymax()+factor2 > 60.0 ) { //System.out.println("Sound is over saturated"); factor1 = 60.0/(in.ymax()+factor2); } int j=0; int once = 1; double max = in.numPoints(); // System.out.println("in.avg="+avg+"Max="+(in.ymax()+factor2)+ // "Min="+(in.ymin()+tmp)); for( int i=0; i < 400; i++) { sample[i] = (byte)( (in.Y(i)+ factor2)*factor1 ); if ( sample[i] < 0) { System.out.println("AU is below zero"); sample[i]=(byte)0; } // if Undefined value found, ignore them // else if (sample[i] >= Double.POSITIVE_INFINITY) sample[i] = (byte)0; else if (sample[i] <= Double.NEGATIVE_INFINITY) sample[i] = (byte)0; } }