jm.audio.io

## Class AudioFileIn

- java.lang.Object
- - jm.audio.io.AudioFileIn

-     public class AudioFileIn
      extends java.lang.Object

  Audio file reading class for jMusic. The class utilises the JavaSound file reading classes. It works indepdently of the jMusic audio architecture used for rendering scores, and is intended for use by simple file manipulation utility programs operating asychronously (non real time). This class deals with some the current (at time of writing) incompletness in the javaSound package, including converting bytes from a file into floats for both big and little endian formats, and support for 24 bit files.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AudioFileIn(java.lang.String fileName)` This constructor opens a file and prepares it to be read.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getBitResolution()` Provide the bit size of the current audio file.
    `int` | `getChannels()` Supplies the number of channels in the audio file/data.
    `int` | `getDuration()` Access the number of samples in the file.
    `java.lang.String` | `getEncoding()` Indicates the type of encoding used by the file.
    `java.lang.String` | `getFileType()` Return the type of file, wav, aif, au etc.
    `int` | `getSampleBitDepth()` Access the sample size as a number of bits per sample.
    `float[]` | `getSampleData()` Provides a single array with the raw sample data in the format of the source file.
    `int` | `getSampleRate()` Access the sample rate.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AudioFileIn

          public AudioFileIn(java.lang.String fileName)

      This constructor opens a file and prepares it to be read.
      Parameters:
        `fileName` - The name of the file to read, e.g., filename.aif

  - ### Method Detail

    - #### getBitResolution

          public int getBitResolution()

      Provide the bit size of the current audio file.
      Returns:
        The bit depth, 8, 16, 24, or 32.

    - #### getSampleData

          public float[] getSampleData()

      Provides a single array with the raw sample data in the format of the source file. Check the number of channels and file type if required.
      Returns:
        sampleData the audio data as an array of floating point values.

    - #### getChannels

          public int getChannels()

      Supplies the number of channels in the audio file/data.
      Returns:
        channels The number of audio channels, 1 = mono, 2 = stereo etc.

    - #### getFileType

          public java.lang.String getFileType()

      Return the type of file, wav, aif, au etc.
      Returns:
        fileType The type of file as a string.

    - #### getSampleRate

          public int getSampleRate()

      Access the sample rate.
      Returns:
        sampleRate The number of samples per second.

    - #### getSampleBitDepth

          public int getSampleBitDepth()

      Access the sample size as a number of bits per sample.
      Returns:
        bitDepth The number of bits per sample, 8, 16, 24, 32 etc.

    - #### getEncoding

          public java.lang.String getEncoding()

      Indicates the type of encoding used by the file.
      Returns:
        encodingInfo A string containing the encoding type.

    - #### getDuration

          public int getDuration()

      Access the number of samples in the file.
      Returns:
        duration - The total number of samples.