Class AudioFormat

  • @NonNullByDefault
    public class AudioFormat
    extends Object
    An audio format definition
    Harald Kuhn - Initial contribution, Kelly Davis - Modified to match discussion in #584, Kai Kreuzer - Moved class, included constants, added toString
    • Constructor Detail

      • AudioFormat

        public AudioFormat​(@Nullable String container,
                           @Nullable String codec,
                           @Nullable Boolean bigEndian,
                           @Nullable Integer bitDepth,
                           @Nullable Integer bitRate,
                           @Nullable Long frequency)
        Constructs an instance with the specified properties. Note that any properties that are null indicate that the corresponding AudioFormat allows any value for the property. Concretely this implies that if, for example, one passed null for the value of frequency, this would mean the created AudioFormat allowed for any valid frequency.
        container - The container for the audio
        codec - The audio codec
        bigEndian - If the audo data is big endian
        bitDepth - The bit depth of the audo data
        bitRate - The bit rate of the audio
        frequency - The frequency at which the audio was sampled
    • Method Detail

      • getCodec

        public @Nullable String getCodec()
        Gets codec
        The codec
      • getContainer

        public @Nullable String getContainer()
        Gets container
        The container
      • isBigEndian

        public @Nullable Boolean isBigEndian()
        Is big endian?
        If format is big endian
      • getBitDepth

        public @Nullable Integer getBitDepth()
        Gets bit depth
        Bit depth
        See Also:
        Bit Depth
      • getBitRate

        public @Nullable Integer getBitRate()
        Gets bit rate
        Bit rate
        See Also:
        Bit Rate
      • getFrequency

        public @Nullable Long getFrequency()
        Gets frequency
        The frequency
      • isCompatible

        public boolean isCompatible​(@Nullable AudioFormat audioFormat)
        Determines if the passed AudioFormat is compatible with this AudioFormat. This AudioFormat is compatible with the passed AudioFormat if both have the same value for all non-null members of this instance.
      • getBestMatch

        public static @Nullable AudioFormat getBestMatch​(Set<AudioFormat> inputs,
                                                         Set<AudioFormat> outputs)
        Determines the best match between a list of audio formats supported by a source and a sink.
        inputs - the supported audio formats of an audio source
        outputs - the supported audio formats of an audio sink
        the best matching format or null, if source and sink are incompatible
      • getPreferredFormat

        public static @Nullable AudioFormat getPreferredFormat​(Set<AudioFormat> audioFormats)
        Gets the first concrete AudioFormat in the passed set or a preferred one based on 16bit, 16KHz, big endian default
        audioFormats - The AudioFormats from which to choose
        The preferred AudioFormat or null if none could be determined. A passed concrete format is preferred adding default values to an abstract AudioFormat in the passed set.
      • equals

        public boolean equals​(@Nullable Object obj)
        equals in class Object
      • hashCode

        public int hashCode()
        hashCode in class Object