Class IrAudioDevice

java.lang.Object
org.harctoolbox.harchardware.ir.IrAudioDevice
All Implemented Interfaces:
Closeable, AutoCloseable, IHarcHardware, IRawIrSender

public class IrAudioDevice extends Object implements IHarcHardware, IRawIrSender
This class implements IR sending using the Java audio device. It is essentially a wrapper around the Wave class.
  • Field Details

  • Constructor Details

    • IrAudioDevice

      public IrAudioDevice(int sampleFrequency, int sampleSize, int channels, boolean bigEndian, boolean omitTail, boolean square, boolean divide, boolean verbose)
      Generic constructor.
      Parameters:
      sampleFrequency - Frequency for the audio device, do not confuse with the IR modulation frequency.
      sampleSize - Size in bits of generated samples. Normally 8.
      channels - 1 for mono (normal case), 2 for "stereo" (left and right in anti-phase).
      bigEndian - For sampleSize > 8, generate samples in big endian format.
      omitTail - Omit the final silence.
      square - Generate square vave on output, otherwise sine.
      divide - Normally true, assuming the frequency will be effectively doubled by the use of anti-parallel LEDs on the output.
      verbose - Verbose operation.
    • IrAudioDevice

      public IrAudioDevice(int sampleFrequency, int sampleSize, int channels, boolean omitTail, boolean verbose)
      Convenience constructor, defaulting some parameters.
      Parameters:
      sampleFrequency - Frequency for the audio device, do not confuse with the IR modulation frequency.
      sampleSize - Size in bits of generated samples. Normally 8.
      channels - 1 for mono (normal case), 2 for "stereo" (left and right in anti-phase).
      omitTail - Omit the final silence.
      verbose - Verbose operation.
    • IrAudioDevice

      public IrAudioDevice(boolean verbose, Integer timeout)
      Constructor for usage in HarcHardware.Main.
      Parameters:
      timeout - ignored
      verbose - Verbose operation.
    • IrAudioDevice

      public IrAudioDevice()
      Convenience constructor, defaulting all parameters.
  • Method Details

    • sendIr

      public boolean sendIr(org.harctoolbox.ircore.IrSignal irSignal, int count, Transmitter transmitter) throws org.harctoolbox.ircore.InvalidArgumentException, IOException, HarcHardwareException
      Specified by:
      sendIr in interface IRawIrSender
      Returns:
      if false, command failed.
      Throws:
      org.harctoolbox.ircore.InvalidArgumentException
      IOException
      NoSuchTransmitterException
      HarcHardwareException
    • getVersion

      public String getVersion() throws IOException
      Description copied from interface: IHarcHardware
      Returns the hardware version (not the version of the driver software). May be null if no relevant information available.
      Specified by:
      getVersion in interface IHarcHardware
      Returns:
      Version string. Semantics can vary.
      Throws:
      IOException
    • setVerbose

      public void setVerbose(boolean verbose)
      Description copied from interface: IHarcHardware
      Sets a verbosity flag, causing commands to be executed verbosely. Exact semantic depends on the implementation. Typically, all communication with the device is echoed to stderr.
      Specified by:
      setVerbose in interface IHarcHardware
      Parameters:
      verbose - on or off
    • setTimeout

      public void setTimeout(int timeout)
      Description copied from interface: IHarcHardware
      Set timeout in milliseconds. Exact semantics may be dependent on the hardware.
      Specified by:
      setTimeout in interface IHarcHardware
      Parameters:
      timeout - Timeout in milliseconds.
    • isValid

      public boolean isValid()
      Description copied from interface: IHarcHardware
      Checks validity of an instance. Exact meaning can vary.
      Specified by:
      isValid in interface IHarcHardware
      Returns:
      validity of the instance.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • open

      public void open() throws IOException
      Description copied from interface: IHarcHardware
      Opens the device with previously set parameters.
      Specified by:
      open in interface IHarcHardware
      Throws:
      IOException
    • getTransmitter

      public Transmitter getTransmitter()
      Description copied from interface: IRawIrSender
      Returns a default Transmitter for the device. May be null if the device ignores the Transmitter argument in sendIr.
      Specified by:
      getTransmitter in interface IRawIrSender
      Returns:
    • setDebug

      public void setDebug(int debug)
      Description copied from interface: IHarcHardware
      Sets a debug parameter. Exact semantic depends on the implementation.
      Specified by:
      setDebug in interface IHarcHardware
    • getSampleFrequency

      public int getSampleFrequency()
      Returns:
      the sampleFrequency
    • setSampleFrequency

      public void setSampleFrequency(int sampleFrequency)
      Parameters:
      sampleFrequency - the sampleFrequency to set
    • setSampleSize

      public void setSampleSize(int sampleSize)
      Parameters:
      sampleSize - the sampleSize to set
    • setChannels

      public void setChannels(int channels)
      Parameters:
      channels - the channels to set
    • setOmitTail

      public void setOmitTail(boolean omitTail)
      Parameters:
      omitTail - the omitTail to set