Package org.harctoolbox.harchardware.ir
Class IrAudioDevice
java.lang.Object
org.harctoolbox.harchardware.ir.IrAudioDevice
- All Implemented Interfaces:
Closeable
,AutoCloseable
,IHarcHardware
,IRawIrSender
This class implements IR sending using the Java audio device.
It is essentially a wrapper around the
Wave
class.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
Fields inherited from interface org.harctoolbox.harchardware.ir.IRawIrSender
repeatMax
-
Constructor Summary
ConstructorDescriptionConvenience constructor, defaulting all parameters.IrAudioDevice
(boolean verbose, Integer timeout) Constructor for usage in HarcHardware.Main.IrAudioDevice
(int sampleFrequency, int sampleSize, int channels, boolean omitTail, boolean verbose) Convenience constructor, defaulting some parameters.IrAudioDevice
(int sampleFrequency, int sampleSize, int channels, boolean bigEndian, boolean omitTail, boolean square, boolean divide, boolean verbose) Generic constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
int
Returns a default Transmitter for the device.Returns the hardware version (not the version of the driver software).boolean
isValid()
Checks validity of an instance.void
open()
Opens the device with previously set parameters.boolean
sendIr
(org.harctoolbox.ircore.IrSignal irSignal, int count, Transmitter transmitter) void
setChannels
(int channels) void
setDebug
(int debug) Sets a debug parameter.void
setOmitTail
(boolean omitTail) void
setSampleFrequency
(int sampleFrequency) void
setSampleSize
(int sampleSize) void
setTimeout
(int timeout) Set timeout in milliseconds.void
setVerbose
(boolean verbose) Sets a verbosity flag, causing commands to be executed verbosely.
-
Field Details
-
DEFAULT_SAMPLE_FREQUENCY
public static final int DEFAULT_SAMPLE_FREQUENCY- See Also:
-
DEFAULT_SAMPLE_SIZE
public static final int DEFAULT_SAMPLE_SIZE- See Also:
-
DEFAULT_CHANNELS
public static final int DEFAULT_CHANNELS- See Also:
-
-
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
Constructor for usage in HarcHardware.Main.- Parameters:
timeout
- ignoredverbose
- 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 interfaceIRawIrSender
- Returns:
- if false, command failed.
- Throws:
org.harctoolbox.ircore.InvalidArgumentException
IOException
NoSuchTransmitterException
HarcHardwareException
-
getVersion
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 interfaceIHarcHardware
- 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 interfaceIHarcHardware
- 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 interfaceIHarcHardware
- 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 interfaceIHarcHardware
- Returns:
- validity of the instance.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
open
Description copied from interface:IHarcHardware
Opens the device with previously set parameters.- Specified by:
open
in interfaceIHarcHardware
- Throws:
IOException
-
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 interfaceIRawIrSender
- 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 interfaceIHarcHardware
-
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
-