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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intFields inherited from interface org.harctoolbox.harchardware.ir.IRawIrSender
repeatMax -
Constructor Summary
ConstructorsConstructorDescriptionConvenience 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 TypeMethodDescriptionvoidclose()intReturns a default Transmitter for the device.Returns the hardware version (not the version of the driver software).booleanisValid()Checks validity of an instance.voidopen()Opens the device with previously set parameters.booleansendIr(org.harctoolbox.ircore.IrSignal irSignal, int count, Transmitter transmitter) voidsetChannels(int channels) voidsetDebug(int debug) Sets a debug parameter.voidsetOmitTail(boolean omitTail) voidsetSampleFrequency(int sampleFrequency) voidsetSampleSize(int sampleSize) voidsetTimeout(int timeout) Set timeout in milliseconds.voidsetVerbose(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:
sendIrin interfaceIRawIrSender- Returns:
- if false, command failed.
- Throws:
org.harctoolbox.ircore.InvalidArgumentExceptionIOExceptionNoSuchTransmitterExceptionHarcHardwareException
-
getVersion
Description copied from interface:IHarcHardwareReturns the hardware version (not the version of the driver software). May be null if no relevant information available.- Specified by:
getVersionin interfaceIHarcHardware- Returns:
- Version string. Semantics can vary.
- Throws:
IOException
-
setVerbose
public void setVerbose(boolean verbose) Description copied from interface:IHarcHardwareSets 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:
setVerbosein interfaceIHarcHardware- Parameters:
verbose- on or off
-
setTimeout
public void setTimeout(int timeout) Description copied from interface:IHarcHardwareSet timeout in milliseconds. Exact semantics may be dependent on the hardware.- Specified by:
setTimeoutin interfaceIHarcHardware- Parameters:
timeout- Timeout in milliseconds.
-
isValid
public boolean isValid()Description copied from interface:IHarcHardwareChecks validity of an instance. Exact meaning can vary.- Specified by:
isValidin interfaceIHarcHardware- Returns:
- validity of the instance.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
open
Description copied from interface:IHarcHardwareOpens the device with previously set parameters.- Specified by:
openin interfaceIHarcHardware- Throws:
IOException
-
getTransmitter
Description copied from interface:IRawIrSenderReturns a default Transmitter for the device. May be null if the device ignores the Transmitter argument in sendIr.- Specified by:
getTransmitterin interfaceIRawIrSender- Returns:
-
setDebug
public void setDebug(int debug) Description copied from interface:IHarcHardwareSets a debug parameter. Exact semantic depends on the implementation.- Specified by:
setDebugin 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
-