[marf-cvs] marf/src/marf/gui Spectrogram.java, 1.30, 1.31 WaveGrapher.java, 1.15, 1.16
Brought to you by:
mokhov
From: Serguei A. M. <mo...@us...> - 2007-12-18 03:45:46
|
Update of /cvsroot/marf/marf/src/marf/gui In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1905/gui Modified Files: Spectrogram.java WaveGrapher.java Log Message: With Eclipse Europa review primarily spelling in comments. Massage a few other places WRT comments and coding convention. There is a lot more work to do in this area, but this can be done as a gap filler. Index: WaveGrapher.java =================================================================== RCS file: /cvsroot/marf/marf/src/marf/gui/WaveGrapher.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** WaveGrapher.java 21 Jan 2006 02:35:32 -0000 1.15 --- WaveGrapher.java 18 Dec 2007 03:45:42 -0000 1.16 *************** *** 13,19 **** /** ! * Class WaveGrapher. * ! * <p>$Id$</p> * * @author Stephen Sinclair --- 13,19 ---- /** ! * <p>Class WaveGrapher.</p> * ! * $Id$ * * @author Stephen Sinclair *************** *** 116,120 **** * Returns source code revision information. * @return revision string ! * @since 0.3.0 */ public static String getMARFSourceCodeRevision() --- 116,120 ---- * Returns source code revision information. * @return revision string ! * @since 0.3.0.2 */ public static String getMARFSourceCodeRevision() Index: Spectrogram.java =================================================================== RCS file: /cvsroot/marf/marf/src/marf/gui/Spectrogram.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Spectrogram.java 13 Aug 2005 23:09:38 -0000 1.30 --- Spectrogram.java 18 Dec 2007 03:45:42 -0000 1.31 *************** *** 15,19 **** * <p>Class Spectrogram dumps a spectrogram to a PPM file.</p> * ! * <p>$Id$</p> * * @author Ian Clement --- 15,19 ---- * <p>Class Spectrogram dumps a spectrogram to a PPM file.</p> * ! * $Id$ * * @author Ian Clement *************** *** 25,29 **** extends StorageManager { ! /** * For serialization versioning. * When adding new members or make other structural --- 25,29 ---- extends StorageManager { ! /** * For serialization versioning. * When adding new members or make other structural *************** *** 33,50 **** */ private static final long serialVersionUID = -8219029755014757254L; /** * The data vector. */ ! protected Vector data = null; /** * Current minimum. */ ! protected double min = 0.0; /** * Current maximum. */ ! protected double max = 0.0; /** --- 33,51 ---- */ private static final long serialVersionUID = -8219029755014757254L; + /** * The data vector. */ ! protected Vector oData = null; /** * Current minimum. */ ! protected double dMin = 0.0; /** * Current maximum. */ ! protected double dMax = 0.0; /** *************** *** 58,62 **** public Spectrogram() { ! this.data = new Vector(); } --- 59,63 ---- public Spectrogram() { ! this.oData = new Vector(); } *************** *** 73,93 **** /** * Adds LPC spectrum to the data to dump. ! * @param lpc_coeffs LPC coefficiencies to dump ! * @param num_coeffs number of LPC coefficiencies to dump ! * @param size size of the spectrogram (width) */ ! public final void addLPC(final double[] lpc_coeffs, final int num_coeffs, final int size) { ! double[] to_insert = new double[size]; ! for(int i = 0; i < size; i++) { double Ar = 1.0; double Ai = 0.0; ! for(int k = 0; k < num_coeffs; k++) { ! Ar -= lpc_coeffs[k] * Math.cos(2 * Math.PI * i * -k / 128); ! Ai -= lpc_coeffs[k] * Math.sin(2 * Math.PI * i * -k / 128); } --- 74,94 ---- /** * Adds LPC spectrum to the data to dump. ! * @param padLPCCoeffs LPC coefficiencies to dump ! * @param piNumCoeffs number of LPC coefficiencies to dump ! * @param piSize size of the spectrogram (width) */ ! public final void addLPC(final double[] padLPCCoeffs, final int piNumCoeffs, final int piSize) { ! double[] adToInsert = new double[piSize]; ! for(int i = 0; i < piSize; i++) { double Ar = 1.0; double Ai = 0.0; ! for(int k = 0; k < piNumCoeffs; k++) { ! Ar -= padLPCCoeffs[k] * Math.cos(2 * Math.PI * i * -k / 128); ! Ai -= padLPCCoeffs[k] * Math.sin(2 * Math.PI * i * -k / 128); } *************** *** 95,133 **** double H = 1.0 / A; ! if(H > this.max) ! this.max = H; else ! if(H < this.min) ! this.min = H; ! to_insert[i] = H; } ! this.data.add(to_insert); } /** * Adds FFT spectrum to the data to dump. ! * @param values array of doubles (FFT coefficiencies) */ ! public final void addFFT(final double[] values) { ! double[] to_insert = new double[values.length / 2]; ! if(this.data.size() == 0) ! this.min = this.max = values[0]; ! for(int k = 0; k < to_insert.length; k++) { ! if(values[k] > max) ! this.max = values[k]; ! if(values[k] < min) ! this.min = values[k]; ! to_insert[k] = values[k]; } ! this.data.add(to_insert); } --- 96,146 ---- double H = 1.0 / A; ! if(H > this.dMax) ! { ! this.dMax = H; ! } else ! { ! if(H < this.dMin) ! { ! this.dMin = H; ! } ! } ! adToInsert[i] = H; } ! this.oData.add(adToInsert); } /** * Adds FFT spectrum to the data to dump. ! * @param padValues array of doubles (FFT coefficiencies) */ ! public final void addFFT(final double[] padValues) { ! double[] adToInsert = new double[padValues.length / 2]; ! if(this.oData.size() == 0) ! { ! this.dMin = this.dMax = padValues[0]; ! } ! for(int k = 0; k < adToInsert.length; k++) { ! if(padValues[k] > dMax) ! { ! this.dMax = padValues[k]; ! } ! if(padValues[k] < dMin) ! { ! this.dMin = padValues[k]; ! } ! adToInsert[k] = padValues[k]; } ! this.oData.add(adToInsert); } *************** *** 142,154 **** { Debug.debug("Dumping spectrogram " + MARF.getSampleFile() + "." + this.strMethod + ".ppm"); ! Debug.debug("Spectrogram.dump() - data size in vectors: " + data.size()); ! FileOutputStream fos = null; ! DataOutputStream outfile = null; ! fos = new FileOutputStream(MARF.getSampleFile() + "." + this.strMethod + ".ppm"); ! outfile = new DataOutputStream(fos); ! // Ouput PPM header /* man ppm: --- 155,167 ---- { Debug.debug("Dumping spectrogram " + MARF.getSampleFile() + "." + this.strMethod + ".ppm"); ! Debug.debug("Spectrogram.dump() - data size in vectors: " + oData.size()); ! FileOutputStream oFOS = null; ! DataOutputStream oOutFile = null; ! oFOS = new FileOutputStream(MARF.getSampleFile() + "." + this.strMethod + ".ppm"); ! oOutFile = new DataOutputStream(oFOS); ! // Output PPM header /* man ppm: *************** *** 177,204 **** // Make max be at 75% ! this.max *= 0.75; ! int length = ((double[])this.data.elementAt(0)).length; ! outfile.writeBytes("P6\n" + this.data.size() + "\n" + length + "\n255\n"); ! for(int j = length - 1; j >= 0; j--) { ! for(int i = 0; i < this.data.size(); i++) { ! double[] adData = (double[])this.data.elementAt(i); for(int m = 0; m < 3; m++) { ! double val; ! if(adData[j] > this.max) ! val = this.max; ! else if(adData[j] < this.min) ! val = this.min; else ! val = adData[j]; ! outfile.writeByte((int)(((this.max - val) / this.max) * 256)); } } --- 190,223 ---- // Make max be at 75% ! this.dMax *= 0.75; ! int iLength = ((double[])this.oData.elementAt(0)).length; ! oOutFile.writeBytes("P6\n" + this.oData.size() + "\n" + iLength + "\n255\n"); ! for(int j = iLength - 1; j >= 0; j--) { ! for(int i = 0; i < this.oData.size(); i++) { ! double[] adData = (double[])this.oData.elementAt(i); for(int m = 0; m < 3; m++) { ! double dVal; ! if(adData[j] > this.dMax) ! { ! dVal = this.dMax; ! } ! else if(adData[j] < this.dMin) ! { ! dVal = this.dMin; ! } else ! { ! dVal = adData[j]; ! } ! oOutFile.writeByte((int)(((this.dMax - dVal) / this.dMax) * 256)); } } *************** *** 209,213 **** "Done dumping spectrogram " + MARF.getSampleFile() + "." + this.strMethod + ! ".ppm [" + (this.data.size() * length * 3) + " bytes]" ); } --- 228,232 ---- "Done dumping spectrogram " + MARF.getSampleFile() + "." + this.strMethod + ! ".ppm [" + (this.oData.size() * iLength * 3) + " bytes]" ); } |