Class Sample


  • public class Sample
    extends java.lang.Object
    A single short term sample containing Residual Excited Linear Predictive (RELP) frame and residual voice data.
    • Constructor Summary

      Constructors 
      Constructor Description
      Sample​(short[] frameData, byte[] residualData)
      Constructs a RELP Sample from its component parts
      Sample​(short[] frameData, byte[] residualData, int residualSize)
      Constructs a Sample from its component parts
      Sample​(java.io.BufferedReader reader, int numChannels)
      Reads a sample from the input reader.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean compare​(Sample other)
      Compares two samples.
      void dump()
      Dumps the sample:
      void dumpBinary​(java.io.DataOutputStream os)
      Dumps the samples to the given stream
      void dumpBinary​(java.nio.ByteBuffer bb)
      Dumps the samples to the given ByteBuffer
      short[] getFrameData()
      Gets the frame data associated with this sample
      int getFrameData​(int which)
      Returns the normalized frame data.
      byte[] getResidualData()
      Gets the residual data associated with this sample
      int getResidualData​(int which)
      Returns the normalized residual data.
      int getResidualSize()
      Returns the number of residuals in this Sample.
      static Sample loadBinary​(java.io.DataInputStream dis)
      Loads the samples from the given channel
      static Sample loadBinary​(java.nio.ByteBuffer bb)
      Loads the samples from the byte bufer
      • Methods inherited from class java.lang.Object

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

      • Sample

        public Sample​(short[] frameData,
                      byte[] residualData)
        Constructs a RELP Sample from its component parts
        Parameters:
        frameData - the framedata
        residualData - the residual data
      • Sample

        public Sample​(short[] frameData,
                      byte[] residualData,
                      int residualSize)
        Constructs a Sample from its component parts
        Parameters:
        frameData - the framedata
        residualData - the residual data
      • Sample

        public Sample​(java.io.BufferedReader reader,
                      int numChannels)
        Reads a sample from the input reader.
        Parameters:
        reader - the input reader to read the data from
        numChannels - the number of channels per frame
    • Method Detail

      • getFrameData

        public short[] getFrameData()
        Gets the frame data associated with this sample
        Returns:
        the frame data associated with this sample
      • getResidualData

        public byte[] getResidualData()
        Gets the residual data associated with this sample
        Returns:
        the residual data associated with this sample
      • getResidualSize

        public int getResidualSize()
        Returns the number of residuals in this Sample.
        Returns:
        the number of residuals in this sample
      • getResidualData

        public int getResidualData​(int which)
        Returns the normalized residual data. You may not want to call this function because of the overhead involved.
        Parameters:
        which - the index of the data of interest
        Returns:
        the normalized data.
      • getFrameData

        public int getFrameData​(int which)
        Returns the normalized frame data. You may not want to call this function because of the overhead involved.
        Parameters:
        which - the index of the data of interest
        Returns:
        the normalized data.
      • dump

        public void dump()
        Dumps the sample:
      • dumpBinary

        public void dumpBinary​(java.nio.ByteBuffer bb)
                        throws java.io.IOException
        Dumps the samples to the given ByteBuffer
        Parameters:
        bb - the ByteBuffer to write the data to.
        Throws:
        java.io.IOException - if IO error occurs
      • dumpBinary

        public void dumpBinary​(java.io.DataOutputStream os)
                        throws java.io.IOException
        Dumps the samples to the given stream
        Parameters:
        os - the DataOutputStream to write the data to.
        Throws:
        java.io.IOException - if IO error occurs
      • loadBinary

        public static Sample loadBinary​(java.nio.ByteBuffer bb)
                                 throws java.io.IOException
        Loads the samples from the byte bufer
        Parameters:
        bb - the byte buffer to read the data from.
        Throws:
        java.io.IOException - if IO error occurs
      • loadBinary

        public static Sample loadBinary​(java.io.DataInputStream dis)
                                 throws java.io.IOException
        Loads the samples from the given channel
        Parameters:
        dis - the DataInputStream to read the data from.
        Throws:
        java.io.IOException - if IO error occurs
      • compare

        public boolean compare​(Sample other)
        Compares two samples. Note that this is not the same as "equals"
        Parameters:
        other - the other sample to compare this one to
        Returns:
        true if they compare; otherwise false