Package samer.audio

Class LineSink

  • All Implemented Interfaces:
    AudioSink


    public class LineSink
    extends VLine
    implements AudioSink
    An AudioSink that sends samples to a Java Sound SourceDataLine. Audio format can be determined in several ways (see below).

    Object is a Viewable, and is called "lineout". Reads property "scale" from current environment, but scale can be adjusted afterwards.

    See Also:
    AudioSink
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      protected class  LineSink.Writer 
    • Constructor Summary

      Constructors 
      Constructor and Description
      LineSink(javax.sound.sampled.SourceDataLine l, javax.sound.sampled.AudioFormat f)
      Create LineSink reading from given TargetDataLine
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void closeImpl() 
      void dispose() 
      void execute(java.lang.String cmd, Environment env) 
      void getCommands(Registry r)
      Commands are :"set scale".
      javax.sound.sampled.DataLine getLine() 
      VDouble getScale()
      Returns the object used to store the scale factor for conversion from doubles/floats to shorts/bytes.
      boolean isOpen() 
      static javax.sound.sampled.DataLine.Info lineInfo(javax.sound.sampled.AudioFormat fmt) 
      static javax.sound.sampled.DataLine.Info lineInfo(javax.sound.sampled.AudioFormat fmt, int bufsize) 
      void openImpl()
      Open the line using either the current format or the line's default format if none has been set.
      void setBufferSize(int b) 
      Task writer(double[] dbuf, int off, int len)
      Return a task which takes samples from the given buffer The idea is that the audio sink can choose the right kind of writer depending on the format of the audio stream, and then handle any conversions automatically.
      Task writer(float[] dbuf, int off, int len) 
      • Methods inherited from class java.lang.Object

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

      • LineSink

        public LineSink(javax.sound.sampled.SourceDataLine l,
                        javax.sound.sampled.AudioFormat f)
                 throws java.lang.Exception
        Create LineSink reading from given TargetDataLine
        Throws:
        java.lang.Exception
    • Method Detail

      • getLine

        public javax.sound.sampled.DataLine getLine()
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface AudioSink
      • setBufferSize

        public void setBufferSize(int b)
      • getScale

        public VDouble getScale()
        Returns the object used to store the scale factor for conversion from doubles/floats to shorts/bytes. This is multiplied by 128 for conversion to 8 bit audio, or 32768 for conversion to 16 bit audio.
      • openImpl

        public void openImpl()
                      throws java.lang.Exception
        Open the line using either the current format or the line's default format if none has been set.
        Throws:
        java.lang.Exception
      • closeImpl

        public void closeImpl()
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getCommands

        public void getCommands(Registry r)
        Commands are :"set scale".
        Overrides:
        getCommands in class VLine
      • execute

        public void execute(java.lang.String cmd,
                            Environment env)
                     throws java.lang.Exception
        Overrides:
        execute in class VLine
        Throws:
        java.lang.Exception
      • writer

        public Task writer(double[] dbuf,
                           int off,
                           int len)
        Description copied from interface: AudioSink
        Return a task which takes samples from the given buffer The idea is that the audio sink can choose the right kind of writer depending on the format of the audio stream, and then handle any conversions automatically.
        Specified by:
        writer in interface AudioSink
      • writer

        public Task writer(float[] dbuf,
                           int off,
                           int len)
        Specified by:
        writer in interface AudioSink
      • lineInfo

        public static javax.sound.sampled.DataLine.Info lineInfo(javax.sound.sampled.AudioFormat fmt)
      • lineInfo

        public static javax.sound.sampled.DataLine.Info lineInfo(javax.sound.sampled.AudioFormat fmt,
                                                                 int bufsize)