Menu

how can we enhance audio quality by adding pitch and pause factor with intensity in spectrogram

anil
2014-11-11
2014-11-12
  • anil

    anil - 2014-11-11

    protected void computeSpectrogram() {
    try {
    AudioDataInputStream is = new AudioDataInputStream(audio);
    dataSource.setInputStream(is, "live audio");

            /* Run through all the spectra one at a time and convert
             * them to an log intensity value.
             */
            ArrayList<double[]> intensitiesList = new ArrayList<double[]>();  //intensity List
            double maxIntensity = Double.MIN_VALUE;
            Data spectrum = frontEnd.getData(); //get data
    
            while (!(spectrum instanceof DataEndSignal)) {
                if (spectrum instanceof DoubleData) {
                    double[] spectrumData = ((DoubleData) spectrum).getValues();
                 //   System.out.println("values................."+spectrumData);
                    double[] intensities = new double[spectrumData.length];
                    for (int i = 0; i < intensities.length; i++) {
                        /*
             * A very small intensity is, for all intents
                         * and purposes, the same as 0.
                         */
                        intensities[i] = Math.max(Math.log(spectrumData[i]),
                                0.0);
                        if (intensities[i] > maxIntensity) {
                            maxIntensity = intensities[i];
                        }
                    }
                    intensitiesList.add(intensities);
                }
                spectrum = frontEnd.getData();
            }
            is.close();
    
            int width = intensitiesList.size();
            int height = (intensitiesList.get(0)).length;
            int maxYIndex = height - 1;
            Dimension d = new Dimension(width, height);
    
            setMinimumSize(d);
            setMaximumSize(d);
            setPreferredSize(d);
    
            /* Create the image for displaying the data.
             */
            spectrogram = new BufferedImage(width,
                    height,
                    BufferedImage.TYPE_INT_RGB);
    
            /* Set scaleFactor so that the maximum value, after removing
            * the offset, will be 0xff.
            */
            double scaleFactor = ((0xff + offsetFactor) / maxIntensity);
    
            for (int i = 0; i < width; i++) {
                double[] intensities = intensitiesList.get(i);
                for (int j = maxYIndex; j >= 0; j--) {
    
                    /* Adjust the grey value to make a value of 0 to mean
                    * white and a value of 0xff to mean black.
                    */
                    int grey = (int) (intensities[j] * scaleFactor
                            - offsetFactor);
                    grey = Math.max(grey, 0);
                    grey = 0xff - grey;
    
                    /* Turn the grey into a pixel value.
                    */
                    int pixel = ((grey << 16) & 0xff0000)
                            | ((grey << 8) & 0xff00)
                            | (grey & 0xff);
    
                    spectrogram.setRGB(i, maxYIndex - j, pixel);
                }
            }
            ImageFilter scaleFilter =
                    new ReplicateScaleFilter((int) (zoom * width), height);
            scaledSpectrogram =
                    createImage(new FilteredImageSource(spectrogram.getSource(),
                            scaleFilter));
            Dimension sz = getSize();
            repaint(0, 0, 0, sz.width - 1, sz.height - 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
     
    • Nickolay V. Shmyrev

      What your question is about?

       
  • anil

    anil - 2014-11-12

    i mean if user speaks too low or too loud ...can the recognizer be able to recognize,....what are its parameters

     

Log in to post a comment.