Class AudioSampleProcessor

    • Constructor Summary

      Constructors 
      Constructor Description
      AudioSampleProcessor()
      Creates new audio sample processor.
      AudioSampleProcessor​(javax.sound.sampled.AudioFormat af)
      Creates new audio sample processor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double amplitudeToSoundPressure​(double ampl)  
      void encodeValue​(double f, byte[] buf, int offset)
      Encodes double values into byte array.
      int getChannels()  
      double getDoubleValue​(byte[] sample, int offset)
      Returns the double value (amplitude) of the given data.
      byte[] getEncodedValue​(double f)
      Encodes normalized double values to byte array.
      float getFloatValue​(byte[] sample)
      Returns the normalized float value (amplitude) of the given sample.
      float getFloatValue​(byte[] sample, int offset)
      Returns the normalized float value (amplitude) of the given data.
      int getFrameSize()  
      double getNormalizedValue​(byte[] sample)
      Returns the normalized double value (amplitude) of the given sample.
      double getNormalizedValue​(byte[] sample, int offset)
      Returns the float value (amplitude) of the given data.
      int getSampleSize()  
      void setAudioFormat​(javax.sound.sampled.AudioFormat af)
      Sets audio format of the samples to process.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_0DB_SOUND_PRESSURE

        public static final double DEFAULT_0DB_SOUND_PRESSURE
        See Also:
        Constant Field Values
      • af

        protected javax.sound.sampled.AudioFormat af
      • ae

        protected javax.sound.sampled.AudioFormat.Encoding ae
      • bigEndian

        protected boolean bigEndian
      • signed

        protected boolean signed
      • channels

        protected int channels
      • frameSize

        protected int frameSize
      • sampleSize

        protected int sampleSize
      • maxValue

        protected double maxValue
      • minValue

        protected double minValue
      • resolutionBits

        protected int resolutionBits
      • pp

        protected double pp
    • Constructor Detail

      • AudioSampleProcessor

        public AudioSampleProcessor()
        Creates new audio sample processor.
    • Method Detail

      • getNormalizedValue

        public double getNormalizedValue​(byte[] sample)
        Returns the normalized double value (amplitude) of the given sample.
        Parameters:
        sample -
        Returns:
        normalized value (-1.0 ... +1.0)
      • getFloatValue

        public float getFloatValue​(byte[] sample)
        Returns the normalized float value (amplitude) of the given sample.
        Parameters:
        sample - audio sample data buffer
        Returns:
        double value (-0.5 ... +0.5)
      • getDoubleValue

        public double getDoubleValue​(byte[] sample,
                                     int offset)
        Returns the double value (amplitude) of the given data.
        Parameters:
        sample - audio sample data buffer
        offset - offset in the buffer
        Returns:
        double value
      • getNormalizedValue

        public double getNormalizedValue​(byte[] sample,
                                         int offset)
        Returns the float value (amplitude) of the given data.
        Parameters:
        sample - audio sample data buffer
        offset - offset in the buffer
        Returns:
        normalized float value (-1.0 ... +1.0)
      • getFloatValue

        public float getFloatValue​(byte[] sample,
                                   int offset)
        Returns the normalized float value (amplitude) of the given data.
        Parameters:
        sample - audio sample data buffer
        offset - offset in the buffer
        Returns:
        normalized float value (-0.5 ... +0.5)
      • encodeValue

        public void encodeValue​(double f,
                                byte[] buf,
                                int offset)
        Encodes double values into byte array.
        Parameters:
        f - normalized amplitude value (-1.0 ... 1.0)
        buf - target data buffer
        offset - offset in the buffer
      • amplitudeToSoundPressure

        public double amplitudeToSoundPressure​(double ampl)
      • getEncodedValue

        public byte[] getEncodedValue​(double f)
        Encodes normalized double values to byte array.
        Parameters:
        f - normalized amplitude value (-1.0 ... 1.0)
        Returns:
        encoded buffer
      • getChannels

        public int getChannels()
      • getFrameSize

        public int getFrameSize()
      • getSampleSize

        public int getSampleSize()