Interface AudioBuffer

  • All Superinterfaces:
    Audio, java.lang.Comparable<NamedBean>, NamedBean, PropertyChangeProvider
    All Known Implementing Classes:
    AbstractAudioBuffer, JavaSoundAudioBuffer, JoalAudioBuffer, NullAudioBuffer

    public interface AudioBuffer
    extends Audio
    Represent an AudioBuffer, a place to store or control sound information.

    The AbstractAudio class contains a basic implementation of the state and messaging code, and forms a useful start for a system-specific implementation. Specific implementations in the jmrix package, e.g. for LocoNet and NCE, will convert to and from the layout commands.

    The states and names are Java Bean parameters, so that listeners can be registered to be notified of any changes.

    Each AudioBuffer object has a two names. The "user" name is entirely free form, and can be used for any purpose. The "system" name is provided by the system-specific implementations, and provides a unique mapping to the layout control system (for example LocoNet or NCE) and address within that system.


    This file is part of JMRI.

    JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

    JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    • Field Detail

      • FORMAT_8BIT_QUAD

        static final int FORMAT_8BIT_QUAD
        Definition of 8-bit quad multi-channel audio format.

        These formats are only supported by certain OpenAL implementations and support is determined at runtime.

        JavaSound and Null implementations do not support these formats.

        See Also:
        Constant Field Values
      • FORMAT_16BIT_QUAD

        static final int FORMAT_16BIT_QUAD
        Definition of 16-bit quad multi-channel audio format.

        These formats are only supported by certain OpenAL implementations and support is determined at runtime.

        JavaSound and Null implementations do not support these formats.

        See Also:
        Constant Field Values
      • FORMAT_8BIT_5DOT1

        static final int FORMAT_8BIT_5DOT1
        Definition of 8-bit 5.1 multi-channel audio format.

        These formats are only supported by certain OpenAL implementations and support is determined at runtime.

        JavaSound and Null implementations do not support these formats.

        See Also:
        Constant Field Values
      • FORMAT_16BIT_5DOT1

        static final int FORMAT_16BIT_5DOT1
        Definition of 16-bit 5.1 multi-channel audio format.

        These formats are only supported by certain OpenAL implementations and support is determined at runtime.

        JavaSound and Null implementations do not support these formats.

        See Also:
        Constant Field Values
      • FORMAT_8BIT_6DOT1

        static final int FORMAT_8BIT_6DOT1
        Definition of 8-bit 6.1 multi-channel audio format.

        These formats are only supported by certain OpenAL implementations and support is determined at runtime.

        JavaSound and Null implementations do not support these formats.

        See Also:
        Constant Field Values
      • FORMAT_16BIT_6DOT1

        static final int FORMAT_16BIT_6DOT1
        Definition of 16-bit 6.1 multi-channel audio format.

        These formats are only supported by certain OpenAL implementations and support is determined at runtime.

        JavaSound and Null implementations do not support these formats.

        See Also:
        Constant Field Values
      • FORMAT_8BIT_7DOT1

        static final int FORMAT_8BIT_7DOT1
        Definition of 8-bit 7.1 multi-channel audio format.

        These formats are only supported by certain OpenAL implementations and support is determined at runtime.

        JavaSound and Null implementations do not support these formats.

        See Also:
        Constant Field Values
      • FORMAT_16BIT_7DOT1

        static final int FORMAT_16BIT_7DOT1
        Definition of 16-bit 7.1 multi-channel audio format.

        These formats are only supported by certain OpenAL implementations and support is determined at runtime.

        JavaSound and Null implementations do not support these formats.

        See Also:
        Constant Field Values
    • Method Detail

      • getURL

        java.lang.String getURL()
        Return the url of the sound sample

        Applies only to sub-types:

        • Buffer
        Returns:
        url
      • setURL

        void setURL​(java.lang.String pUrl)
        Sets the url of the sound sample

        Applies only to sub-types:

        • Buffer
        Parameters:
        pUrl - URL for location containing sound sample data
      • setInputStream

        void setInputStream​(java.io.InputStream stream)
        Sets the input stream of the sound sample

        Applies only to sub-types:

        • Buffer
        Parameters:
        stream - InputStream containing sound sample data
      • getFormat

        int getFormat()
        Retrieves the format of the sound sample stored in this buffer

        Applies only to sub-types:

        • Buffer
        Returns:
        constant representing format
      • getLength

        long getLength()
        Retrieves the length of the sound sample stored in this buffer

        Applies only to sub-types:

        • Buffer
        Returns:
        length of sound sample in frames
        See Also:
        getFrameSize()
      • getFrequency

        int getFrequency()
        Retrieves the frequency of the sound sample stored in this buffer

        Applies only to sub-types:

        • Buffer
        Returns:
        frequency of sound sample in Hz
      • getFrameSize

        int getFrameSize()
        Retrieves the length of a sound sample frame stored in this buffer

        Applies only to sub-types:

        • Buffer
        Returns:
        length of sound sample frame in bytes
      • setStartLoopPoint

        void setStartLoopPoint​(long startLoopPoint)
        Sets the start loop point of the sound sample stored in this buffer

        Applies only to sub-types:

        • Buffer
        Parameters:
        startLoopPoint - position of start loop point in samples
      • getStartLoopPoint

        long getStartLoopPoint()
        Retrieves the start loop point of the sound sample stored in this buffer

        Applies only to sub-types:

        • Buffer
        Returns:
        position of start loop point in samples
      • setEndLoopPoint

        void setEndLoopPoint​(long endLoopPoint)
        Sets the end loop point of the sound sample stored in this buffer

        Applies only to sub-types:

        • Buffer
        Parameters:
        endLoopPoint - position of end loop point in samples
      • getEndLoopPoint

        long getEndLoopPoint()
        Retrieves the end loop point of the sound sample stored in this buffer

        Applies only to sub-types:

        • Buffer
        Returns:
        position of end loop point in samples
      • setStreamed

        void setStreamed​(boolean streamed)
        Sets that this buffer is to be streamed as opposed to loaded in full. Can only be turned off when isStreamedForced is not set.

        Applies only to sub-types:

        • Buffer
        Parameters:
        streamed - buffer is streamed from file or loaded in full
        See Also:
        isStreamedForced()
      • isStreamed

        boolean isStreamed()
        Retrieves the current streaming setting of this buffer

        Applies only to sub-types:

        • Buffer
        Returns:
        current streaming setting
      • isStreamedForced

        boolean isStreamedForced()
        Determines if this buffer can be loaded in full or if it must be streamed from the file. Forced streaming is usually restricted to larger sound samples that are otherwise too large to fit directly into memory.

        Applies only to sub-types:

        • Buffer
        Returns:
        True if buffer must be streamed; False it can be loaded in full
      • loadBuffer

        boolean loadBuffer​(java.nio.ByteBuffer b,
                           int format,
                           int frequency)