protected internal virtual void computeSpectrogram() { try { AudioDataInputStream audioDataInputStream = new AudioDataInputStream(this.audio); this.dataSource.setInputStream(audioDataInputStream); ArrayList arrayList = new ArrayList(); double num = double.Epsilon; Data data = this.frontEnd.getData(); int i; while (!(data is DataEndSignal)) { if (data is DoubleData) { double[] values = ((DoubleData)data).getValues(); double[] array = new double[values.Length]; for (i = 0; i < array.Length; i++) { array[i] = Math.max(Math.log(values[i]), (double)0f); if (array[i] > num) { num = array[i]; } } arrayList.add(array); } data = this.frontEnd.getData(); } audioDataInputStream.close(); int num2 = arrayList.size(); int num3 = ((double[])arrayList.get(0)).Length; i = num3 - 1; Dimension dimension = new Dimension(num2, num3); this.setMinimumSize(dimension); this.setMaximumSize(dimension); this.setPreferredSize(dimension); this.spectrogram = new BufferedImage(num2, num3, 1); double num4 = (255.0 + this.offsetFactor) / num; for (int j = 0; j < num2; j++) { double[] array2 = (double[])arrayList.get(j); for (int k = i; k >= 0; k--) { int num5 = ByteCodeHelper.d2i(array2[k] * num4 - this.offsetFactor); num5 = Math.max(num5, 0); num5 = 255 - num5; int num6 = (num5 << 16 & 16711680) | (num5 << 8 & 65280) | (num5 & 255); this.spectrogram.setRGB(j, i - k, num6); } } ReplicateScaleFilter replicateScaleFilter = new ReplicateScaleFilter(ByteCodeHelper.f2i(this.zoom * (float)num2), num3); this.scaledSpectrogram = this.createImage(new FilteredImageSource(this.spectrogram.getSource(), replicateScaleFilter)); Dimension size = this.getSize(); this.repaint(0L, 0, 0, size.width - 1, size.height - 1); } catch (System.Exception ex) { Throwable.instancehelper_printStackTrace(ex); } }
protected internal virtual void zoomSet(float zoom) { this.zoom = zoom; if (this.spectrogram != null) { int width = this.spectrogram.getWidth(); int height = this.spectrogram.getHeight(); ReplicateScaleFilter replicateScaleFilter = new ReplicateScaleFilter(ByteCodeHelper.f2i(zoom * (float)width), height); this.scaledSpectrogram = this.createImage(new FilteredImageSource(this.spectrogram.getSource(), replicateScaleFilter)); Dimension dimension = new Dimension(ByteCodeHelper.f2i((float)width * zoom), height); this.setMinimumSize(dimension); this.setMaximumSize(dimension); this.setPreferredSize(dimension); this.repaint(); } }
/// <summary> /// Creates a scaled version of this image. /// A new <code>Image</code> object is returned which will render /// the image at the specified <code>width</code> and /// <code>height</code> by default. The new <code>Image</code> object /// may be loaded asynchronously even if the original source image /// has already been loaded completely. /// /// <para> /// /// If either <code>width</code> /// or <code>height</code> is a negative number then a value is /// substituted to maintain the aspect ratio of the original image /// dimensions. If both <code>width</code> and <code>height</code> /// are negative, then the original image dimensions are used. /// /// </para> /// </summary> /// <param name="width"> the width to which to scale the image. </param> /// <param name="height"> the height to which to scale the image. </param> /// <param name="hints"> flags to indicate the type of algorithm to use /// for image resampling. </param> /// <returns> a scaled version of the image. </returns> /// <exception cref="IllegalArgumentException"> if <code>width</code> /// or <code>height</code> is zero. </exception> /// <seealso cref= java.awt.Image#SCALE_DEFAULT </seealso> /// <seealso cref= java.awt.Image#SCALE_FAST </seealso> /// <seealso cref= java.awt.Image#SCALE_SMOOTH </seealso> /// <seealso cref= java.awt.Image#SCALE_REPLICATE </seealso> /// <seealso cref= java.awt.Image#SCALE_AREA_AVERAGING /// @since JDK1.1 </seealso> public virtual Image GetScaledInstance(int width, int height, int hints) { ImageFilter filter; if ((hints & (SCALE_SMOOTH | SCALE_AREA_AVERAGING)) != 0) { filter = new AreaAveragingScaleFilter(width, height); } else { filter = new ReplicateScaleFilter(width, height); } ImageProducer prod; prod = new FilteredImageSource(Source, filter); return(Toolkit.DefaultToolkit.CreateImage(prod)); }
protected internal virtual void computeCepstrum() { try { AudioDataInputStream audioDataInputStream = new AudioDataInputStream(this.audio); this.dataSource.setInputStream(audioDataInputStream); ArrayList arrayList = new ArrayList(); float[] array = new float[100]; Arrays.fill(array, float.Epsilon); Data data = this.frontEnd.getData(); int i; while (!(data is DataEndSignal)) { if (data is FloatData) { float[] values = ((FloatData)data).getValues(); float[] array2 = new float[values.Length]; for (i = 0; i < array2.Length; i++) { array2[i] = values[i]; if (Math.abs(array2[i]) > array[i]) { array[i] = Math.abs(array2[i]); } } arrayList.add(array2); } if (data is DoubleData) { double[] values2 = ((DoubleData)data).getValues(); float[] array2 = new float[values2.Length]; for (i = 0; i < array2.Length; i++) { array2[i] = (float)values2[i]; if (Math.abs(array2[i]) > array[i]) { array[i] = Math.abs(array2[i]); } } arrayList.add(array2); } data = this.frontEnd.getData(); } audioDataInputStream.close(); int num = arrayList.size(); int num2 = ((float[])arrayList.get(0)).Length; i = num2 * 10; Dimension dimension = new Dimension(num, i); this.setMinimumSize(dimension); this.setMaximumSize(dimension); this.setPreferredSize(dimension); this.spectrogram = new BufferedImage(num, i, 1); for (int j = 0; j < num; j++) { float[] array3 = (float[])arrayList.get(j); for (int k = num2 - 1; k >= 0; k--) { int num3 = 127 - ByteCodeHelper.f2i(array3[k] / array[k] * 127f); int num4 = (num3 << 16 & 16711680) | (num3 << 8 & 65280) | (num3 & 255); for (int l = 0; l < 10; l++) { this.spectrogram.setRGB(j, i - 1 - k * 10 - l, num4); } } } ReplicateScaleFilter replicateScaleFilter = new ReplicateScaleFilter(ByteCodeHelper.f2i(this.zoom * (float)num), i); this.scaledSpectrogram = this.createImage(new FilteredImageSource(this.spectrogram.getSource(), replicateScaleFilter)); Dimension size = this.getSize(); this.repaint(0L, 0, 0, size.width - 1, size.height - 1); } catch (System.Exception ex) { Throwable.instancehelper_printStackTrace(ex); } }