package nxm.audio.lib;

/** A class that handles audio formatting
 *  @author Jay Hallam
 *  @since  NeXtMidas 2.1.0
 */
public class AudioFormat {

  /** The frame rate            */ float   frameRate;
  /** The sample rate           */ float   sampleRate;
  /** The sample size in bits   */ int     sampleSizeInBits;
  /** The number of channels    */ int     channels;
  /** The frame size            */ int     frameSize;
  /** Using signed audio format */ boolean signed;
  /** Using big endian format   */ boolean bigEndian;

  /** AudioFormat Constructor
   *  @param sampleRate       the sample rate
   *  @param sampleSizeInBits the sample size in bits
   *  @param channels         the number of channels
   *  @param signed           using signed audio format
   *  @param bigEndian        using big endian format
   */
  public AudioFormat(float sampleRate, int sampleSizeInBits,
                     int channels, boolean signed, boolean bigEndian) {

    this.sampleRate = sampleRate;
    this.sampleSizeInBits = sampleSizeInBits;
    this.channels = channels;
    this.signed = signed;
    this.bigEndian = bigEndian;
    this.frameSize = sampleSizeInBits * channels / 8;
    this.frameRate = sampleRate;
  }

  /** Get the number of channels
   *  @return the number of channels
   */
  public int getChannels() {
    return channels;
  }

  /** Get the frame size
   *  @return the frame size
   */
  public int getFrameSize() {
    return frameSize;
  }

  /** Get the frame rate
   *  @return the frame rate
   */
  public float getFrameRate() {
    return frameRate;
  }

  /** Get the sample rate
   *  @return the sample rate
   */
  public float getSampleRate() {
    return sampleRate;
  }

  /** Get the sample size in bits
   *  @return the sample size in bits
   */
  public int getSampleSizeInBits() {
    return sampleSizeInBits;
  }

  /** Return whether or not big endian format is being used
   *  @return the state of using big endian format
   */
  public boolean isBigEndian() {
    return bigEndian;
  }

}
