Class SoundUtil


  • public class SoundUtil
    extends java.lang.Object
    Provide simple way to load and play Java 2 sounds in JMRI.

    This is placed in the jmri.jmrit.sound package by process of elimination. It doesn't belong in the base jmri package, as it's not a basic interface. Nor is it a specific implementation of a basic interface, which would put it in jmri.jmrix.

    • Constructor Summary

      Constructors 
      Constructor Description
      SoundUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] bufferFromFile​(java.lang.String filename, float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian)  
      static void playSoundBuffer​(byte[] wavData)
      Play a sound from a buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • playSoundBuffer

        public static void playSoundBuffer​(byte[] wavData)
        Play a sound from a buffer.
        Parameters:
        wavData - the .wav byte array.
      • bufferFromFile

        public static byte[] bufferFromFile​(java.lang.String filename,
                                            float sampleRate,
                                            int sampleSizeInBits,
                                            int channels,
                                            boolean signed,
                                            boolean bigEndian)
                                     throws java.io.IOException,
                                            javax.sound.sampled.UnsupportedAudioFileException
        Throws:
        java.io.IOException
        javax.sound.sampled.UnsupportedAudioFileException