For IntelliJ IDEA,

Android Studio or Eclipse

public static void main(String[] args) throws Exception { PrintfFormat format = new PrintfFormat("%.4f"); for (int file = 0; file < args.length; file++) { AudioInputStream ais = AudioSystem.getAudioInputStream(new File(args[file])); if (!ais.getFormat().getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { ais = AudioSystem.getAudioInputStream(AudioFormat.Encoding.PCM_SIGNED, ais); } float samplingRate = ais.getFormat().getSampleRate(); double[] signal = new AudioDoubleDataSource(ais).getAllData(); float duration = signal.length / samplingRate; System.out.println(args[file] + ": " + format.sprintf(duration) + " s"); } } }

protected String getLabel(double x, double y) { int precisionX = -(int) (Math.log(getXRange()) / Math.log(10)) + 2; if (precisionX < 0) precisionX = 0; int indexX = X2indexX(x); double[] spectrum = (double[]) cepstra.get(indexX); int precisionY = -(int) (Math.log(getYRange()) / Math.log(10)) + 2; if (precisionY < 0) precisionY = 0; double E = spectrum[Y2indexY(y)]; int precisionE = 1; return "E(" + new PrintfFormat("%." + precisionX + "f").sprintf(x) + "," + new PrintfFormat("%." + precisionY + "f").sprintf(y) + ")=" + new PrintfFormat("%." + precisionE + "f").sprintf(E); }

protected String getLabel(double x, double y) { // be about one order of magnitude less precise than there are pixels int pixelPrecisionX = 2; if (graphImage != null) { pixelPrecisionX = (int) (Math.log(graphImage.getWidth() / getXRange()) / Math.log(10)); } int precisionX = -(int) (Math.log(getXRange()) / Math.log(10)) + pixelPrecisionX; if (precisionX < 0) precisionX = 0; // ignore imageY int precisionY = -(int) (Math.log(getYRange()) / Math.log(10)) + 2; if (precisionY < 0) precisionY = 0; int indexX = X2indexX(x); double[] data = dataseries.get(0); return "f(" + new PrintfFormat("%." + precisionX + "f").sprintf(x) + ")=" + new PrintfFormat("%." + precisionY + "f").sprintf(data[indexX]); }

public void update(double x) { if (Double.isNaN(x)) return; int centerIndex = (int) (x * samplingRate); assert centerIndex >= 0 && centerIndex < signal.length; int windowLength = 1024; int leftIndex = centerIndex - windowLength / 2; if (leftIndex < 0) leftIndex = 0; double[] signalExcerpt = new HammingWindow(windowLength).apply(signal, leftIndex); double[] spectrum = FFT.computeLogPowerSpectrum(signalExcerpt); if (graph == null) { graph = new FunctionGraph(300, 200, 0, samplingRate / windowLength, spectrum); } else { graph.updateData(0, samplingRate / windowLength, spectrum); } super.updateGraph(graph, "Spectrum at " + new PrintfFormat("%.3f").sprintf(x) + " s"); }

((Phasogram) graph).update(); super.updateGraph(graph, "Phasogram at " + new PrintfFormat("%.3f").sprintf(x) + " s");

graph.updateData(0, samplingRate, realCepstrum); super.updateGraph(graph, "Cepstrum at " + new PrintfFormat("%.3f").sprintf(x) + " s"); + new PrintfFormat("%.3f").sprintf(x) + " s");

labelFormat = new PrintfFormat("%.0f"); } else { labelFormat = new PrintfFormat("%." + (-unitOrder) + "f"); g.drawString(labelFormat.sprintf(i), startX + (int) xunit - 10, image_y_origin + 20);

labelFormat = new PrintfFormat("%.0f"); } else { labelFormat = new PrintfFormat("%." + (-unitOrder) + "f"); g.drawLine(image_x_origin + 5, startY - (int) yunit, image_x_origin - 5, startY - (int) yunit); g.drawString(labelFormat.sprintf(i), image_x_origin - 30, startY - (int) yunit + 5);

protected String getLabel(double x, double y) { int precisionX = -(int) (Math.log(getXRange()) / Math.log(10)) + 2; if (precisionX < 0) precisionX = 0; int indexX = X2indexX(x); double[] spectrum = (double[]) spectra.get(indexX); int precisionY = -(int) (Math.log(getYRange()) / Math.log(10)) + 2; if (precisionY < 0) precisionY = 0; double E = spectrum[Y2indexY(y)]; int precisionE = 1; return "E(" + new PrintfFormat("%." + precisionX + "f").sprintf(x) + "," + new PrintfFormat("%." + precisionY + "f").sprintf(y) + ")=" + new PrintfFormat("%." + precisionE + "f").sprintf(E); }

public static void main(String[] args) throws Exception { PrintfFormat format = new PrintfFormat("%.4f"); for (int file = 0; file < args.length; file++) { AudioInputStream ais = AudioSystem.getAudioInputStream(new File(args[file])); if (!ais.getFormat().getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) { ais = AudioSystem.getAudioInputStream(AudioFormat.Encoding.PCM_SIGNED, ais); } float samplingRate = ais.getFormat().getSampleRate(); double[] signal = new AudioDoubleDataSource(ais).getAllData(); float duration = signal.length / samplingRate; System.out.println(args[file] + ": " + format.sprintf(duration) + " s"); } } }

protected String getLabel(double x, double y) { // be about one order of magnitude less precise than there are pixels int pixelPrecisionX = 2; if (graphImage != null) { pixelPrecisionX = (int) (Math.log(graphImage.getWidth() / getXRange()) / Math.log(10)); } int precisionX = -(int) (Math.log(getXRange()) / Math.log(10)) + pixelPrecisionX; if (precisionX < 0) precisionX = 0; // ignore imageY int precisionY = -(int) (Math.log(getYRange()) / Math.log(10)) + 2; if (precisionY < 0) precisionY = 0; int indexX = X2indexX(x); double[] data = dataseries.get(0); return "f(" + new PrintfFormat("%." + precisionX + "f").sprintf(x) + ")=" + new PrintfFormat("%." + precisionY + "f").sprintf(data[indexX]); }

public void update(double x) { if (Double.isNaN(x)) return; int centerIndex = (int) (x * samplingRate); assert centerIndex >= 0 && centerIndex < signal.length; int windowLength = 1024; int leftIndex = centerIndex - windowLength / 2; if (leftIndex < 0) leftIndex = 0; double[] signalExcerpt = new HammingWindow(windowLength).apply(signal, leftIndex); double[] spectrum = FFT.computeLogPowerSpectrum(signalExcerpt); if (graph == null) { graph = new FunctionGraph(300, 200, 0, samplingRate / windowLength, spectrum); } else { graph.updateData(0, samplingRate / windowLength, spectrum); } super.updateGraph(graph, "Spectrum at " + new PrintfFormat("%.3f").sprintf(x) + " s"); }

graph.updateData(0, samplingRate, realCepstrum); super.updateGraph(graph, "Cepstrum at " + new PrintfFormat("%.3f").sprintf(x) + " s"); + new PrintfFormat("%.3f").sprintf(x) + " s");

((Phasogram) graph).update(); super.updateGraph(graph, "Phasogram at " + new PrintfFormat("%.3f").sprintf(x) + " s");

labelFormat = new PrintfFormat("%.0f"); } else { labelFormat = new PrintfFormat("%." + (-unitOrder) + "f"); g.drawLine(image_x_origin + 5, startY - (int) yunit, image_x_origin - 5, startY - (int) yunit); g.drawString(labelFormat.sprintf(i), image_x_origin - 30, startY - (int) yunit + 5);