Class AudioCueFunctions

java.lang.Object
com.adonax.audiocue.AudioCueFunctions

public class AudioCueFunctions extends Object
A class containing static functions and public enums used in the AudioCue package
Since:
2.1.0
Version:
2.1.0
Author:
Philip Freihofner
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The enum PanType is a repository of functions for volume-based panning for stereo media.Each function takes a linear pan setting as an input, ranging from -1 (100% left) to 1 (100% right) with 0 being the center pan setting.
    static enum 
    The enum VolumeType is a repository of functions used to convert an input in the linear range 0..1 to an attenuation factor, where the input 0 indicating silence and 1 indicating full volume, and the returned factor intended to be multiplied to the PCM values on a per-element basis.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    fromPcmToAudioBytes(byte[] audioBytes, float[] sourcePcm)
    Converts an array of signed, normalized float PCM values to a corresponding byte array using 16-bit, little-endian encoding.
    Obtains a SourceDataLine that is available for use from the specified javax.sound.sampled.Mixer and that matches the description in the specified Line.Info.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AudioCueFunctions

      public AudioCueFunctions()
  • Method Details

    • getSourceDataLine

      public static SourceDataLine getSourceDataLine(Mixer mixer, Line.Info info) throws LineUnavailableException
      Obtains a SourceDataLine that is available for use from the specified javax.sound.sampled.Mixer and that matches the description in the specified Line.Info.
      Parameters:
      mixer - - an javax.sound.sampled.Mixer
      info - - describes the desired line
      Returns:
      a a line that is available for use from the specified javax.sound.sampled.Mixer and that matches the description in the specified Line.Info object
      Throws:
      LineUnavailableException - if a matching line is not available
    • fromPcmToAudioBytes

      public static byte[] fromPcmToAudioBytes(byte[] audioBytes, float[] sourcePcm)
      Converts an array of signed, normalized float PCM values to a corresponding byte array using 16-bit, little-endian encoding. This is the sole audio format supported by this application, and is expected by the SourceDataLine configured for media play. Because each float value is converted into two bytes, the receiving array, audioBytes, must be twice the length of the array of data to be converted, sourcePcm. Failure to comply will throw an IllegalArgumentException.
      Parameters:
      audioBytes - - an byte array ready to receive the converted audio data. Should be twice the length of buffer.
      sourcePcm - - a float array with signed, normalized PCM data to be converted
      Returns:
      the byte array audioBytes after is has been populated with the converted data
      Throws:
      IllegalArgumentException - if destination array is not exactly twice the length of the source array