Package com.adonax.audiocue
Class AudioCueFunctions
java.lang.Object
com.adonax.audiocue.AudioCueFunctions
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 ClassesModifier and TypeClassDescriptionstatic enum
Theenum 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
Theenum 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static SourceDataLine
getSourceDataLine
(Mixer mixer, Line.Info info) Obtains aSourceDataLine
that is available for use from the specifiedjavax.sound.sampled.Mixer
and that matches the description in the specifiedLine.Info
.
-
Constructor Details
-
AudioCueFunctions
public AudioCueFunctions()
-
-
Method Details
-
getSourceDataLine
public static SourceDataLine getSourceDataLine(Mixer mixer, Line.Info info) throws LineUnavailableException Obtains aSourceDataLine
that is available for use from the specifiedjavax.sound.sampled.Mixer
and that matches the description in the specifiedLine.Info
.- Parameters:
mixer
- - anjavax.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 specifiedLine.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 theSourceDataLine
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 anIllegalArgumentException
.- Parameters:
audioBytes
- - an byte array ready to receive the converted audio data. Should be twice the length ofbuffer
.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
-