Interface AudioFactory

  • All Known Implementing Classes:
    AbstractAudioFactory, JavaSoundAudioFactory, JoalAudioFactory, NullAudioFactory

    public interface AudioFactory
    An AudioFactory is responsible for the initialisation of specific audio system implementations, creation of audio system specific Audio objects and any necessary clean-up operations required by a specific audio system implementation.

    Each factory varies in its capabilities with regard the faithfulness of the audio rendering model (such as spatial positioning approximation), number of concurrent sounds (polyphony), hardware required, etc.

    Current implemented audio systems include:

    • JOAL
    • JavaSound
    • Null (a catch-all which doesn't actually play any sounds)

    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.

    • Method Detail

      • init

        boolean init()
        Perform any implementation specific initialisation routines.
        Returns:
        true, if initialisation successful
      • cleanup

        void cleanup()
        Perform any implementation specific clean-up operations.
      • isInitialised

        boolean isInitialised()
        Determine if this AudioFactory is initialised
        Returns:
        true if initialised
      • createNewBuffer

        AudioBuffer createNewBuffer​(java.lang.String systemName,
                                    java.lang.String userName)
        Provide a specific new AudioBuffer object.
        Parameters:
        systemName - for this object instance
        userName - for this object instance
        Returns:
        a new specific AudioBuffer
      • createNewListener

        AudioListener createNewListener​(java.lang.String systemName,
                                        java.lang.String userName)
        Provide a specific new AudioListener object.
        Parameters:
        systemName - for this object instance
        userName - for this object instance
        Returns:
        a new specific AudioListener
      • createNewSource

        AudioSource createNewSource​(java.lang.String systemName,
                                    java.lang.String userName)
        Provide a specific new AudioSource object.
        Parameters:
        systemName - for this object instance
        userName - for this object instance
        Returns:
        a new specific AudioSource
      • audioCommandQueue

        boolean audioCommandQueue​(AudioCommand newAudioCommand)
        Queues a new AudioCommand for subsequent execution.

        If newAudioCommand is null the current queue is executed and cleaned.

        Parameters:
        newAudioCommand - AudioCommand to queue or null to execute queue
        Returns:
        true, if further commands exist; false, if empty
      • getCommandThread

        java.lang.Thread getCommandThread()
        Get the currently active Command thread.
        Returns:
        active CommandThread
      • setDistanceAttenuated

        void setDistanceAttenuated​(boolean attenuated)
        Set if this AudioFactory should attenuate sources based on their distance from the listener.

        Default = true

        Parameters:
        attenuated - true if distance attenuation to be used
      • isDistanceAttenuated

        boolean isDistanceAttenuated()
        Determine if this AudioFactory attenuates sources based on their distance from the Listener.
        Returns:
        true if distance attenuation used