Package 

Class FileDataLoader

    • Method Summary

      Modifier and Type Method Description
      int read(Array<short> buffer, int offset, int length) Reads a number of samples into the provided short buffer.
      void close() Closes the loader.
      • Methods inherited from class java.lang.Object

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

      • FileDataLoader

        FileDataLoader(Context context, FileDataLoader.FileType fileType, CallConstants.AudioSampleRate sampleRate)
        Constructs the loader by reading the file asset into memory.
        Parameters:
        context - the Android context
        fileType - which file type to load
        sampleRate - the audio sample rate to choose the correct asset
    • Method Detail

      • read

         int read(Array<short> buffer, int offset, int length)

        Reads a number of samples into the provided short buffer.

        The audio file is treated as a circular buffer. When the end is reached, it wraps around.For sample rates 24000, 32000, and 48000, the 8000 Hz data is upscaled using linear interpolation.

        Parameters:
        buffer - the destination array of shorts
        offset - the start offset in the destination array
        length - the number of shorts to read
      • close

         void close()

        Closes the loader.

        In this implementation the file data is held in memory so there is no stream to close.This method is provided for API symmetry.