Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 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);
     }
 }