Package org.harctoolbox.harchardware.ir
Class Wave
java.lang.Object
org.harctoolbox.harchardware.ir.Wave
This class generates (or analyzes) a wave audio file that can be played
on standard audio equipment and fed to a pair of anti-parallel double IR sending diodes,
which can thus control IR equipment.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionWave(double freq, double[] data, int sampleFrequency, int sampleSize, int channels, boolean bigEndian, boolean omitTail, boolean square, boolean divide) Generates a wave audio file from its arguments.Reads a wave file into a Wave object.Wave(org.harctoolbox.ircore.ModulatedIrSequence irSequence, int sampleFrequency, int sampleSize, int channels, boolean bigEndian, boolean omitTail, boolean square, boolean divide) Generates a wave audio file from its arguments.Wave(org.harctoolbox.ircore.ModulatedIrSequence irSequence, AudioFormat audioFormat, boolean omitTail, boolean square, boolean divide) Generates a wave audio file from its arguments. -
Method Summary
Modifier and TypeMethodDescriptionorg.harctoolbox.ircore.ModulatedIrSequenceanalyze(PrintStream stream, boolean divide) Analyzes the data and computes a ModulatedIrSequence.voidPrint the channels to a tab separated text file, for example for debugging purposes.voidWrite the signal to the file given as argument.static SourceDataLinegetLine(AudioFormat audioFormat) Returns a line to the audio mixer on the local machine, suitable for sound with the parameter values given.static voidProvides a command line interface to the export/import functions.voidplay()Sends the generated wave to the local machine's audio system, if possible.voidplay(SourceDataLine line) Sends the generated wave to the line in argument, if possible.
-
Constructor Details
-
Wave
Reads a wave file into a Wave object.- Parameters:
file- Wave file as input.- Throws:
UnsupportedAudioFileExceptionIOException
-
Wave
public Wave(double freq, double[] data, int sampleFrequency, int sampleSize, int channels, boolean bigEndian, boolean omitTail, boolean square, boolean divide) throws org.harctoolbox.ircore.InvalidArgumentException Generates a wave audio file from its arguments.- Parameters:
freq- Carrier frequency in Hz.data- double array of durations in micro seconds.sampleFrequency- Sample frequency of the generated wave file.sampleSize- Sample size (8 or 16) in bits of the samples.channels- If == 2, generates two channels in perfect anti-phase.bigEndian- if true, use bigendian byte order for 16 bit samples.omitTail- If true, the last trailing gap will be omitted.square- if true, use a square wave for modulation, otherwise a sine.divide- If true, divides the carrier frequency by 2, to be used with full-wave rectifiers, e.g. a pair of IR LEDs in anti-parallel.- Throws:
org.harctoolbox.ircore.InvalidArgumentException
-
Wave
public Wave(org.harctoolbox.ircore.ModulatedIrSequence irSequence, int sampleFrequency, int sampleSize, int channels, boolean bigEndian, boolean omitTail, boolean square, boolean divide) throws org.harctoolbox.ircore.InvalidArgumentException Generates a wave audio file from its arguments.- Parameters:
irSequence- ModulatedIrSequence to be used.sampleFrequency- Sample frequency of the generated wave file.sampleSize- Sample size (8 or 16) in bits of the samples.channels- If == 2, generates two channels in perfect anti-phase.bigEndian- if true, use bigendian byte order for 16 bit samples.omitTail- If true, the last trailing gap will be omitted.square- if true, use a square wave for modulation, otherwise a sine.divide- If true, divides the carrier frequency by 2, to be used with full-wave rectifiers, e.g. a pair of IR LEDs in anti-parallel.- Throws:
org.harctoolbox.ircore.InvalidArgumentException
-
Wave
public Wave(org.harctoolbox.ircore.ModulatedIrSequence irSequence, AudioFormat audioFormat, boolean omitTail, boolean square, boolean divide) throws org.harctoolbox.ircore.InvalidArgumentException Generates a wave audio file from its arguments.- Parameters:
irSequence- ModulatedIrSequence to be used.audioFormat- AudioFormat bundling sampleFrequency, sample size, channels, and bigEndian together.omitTail- If true, the last trailing gap will be omitted.square- if true, use a square wave for modulation, otherwise a sine.divide- If true, divides the carrier frequency by 2, to be used with full-wave rectifiers, e.g. a pair of IR LEDs in anti-parallel.- Throws:
org.harctoolbox.ircore.InvalidArgumentException
-
-
Method Details
-
getLine
Returns a line to the audio mixer on the local machine, suitable for sound with the parameter values given. When not needed, the user should close the line with its close()-function.- Parameters:
audioFormat-- Returns:
- open audio line
- Throws:
LineUnavailableException
-
main
Provides a command line interface to the export/import functions.- Parameters:
args-
-
analyze
Analyzes the data and computes a ModulatedIrSequence. Generates some messages on stderr.- Parameters:
stream-divide- consider the carrier as having its frequency halved or not?- Returns:
- ModulatedIrSequence computed from the data.
-
dump
Print the channels to a tab separated text file, for example for debugging purposes. This file can be imported in a spreadsheet.- Parameters:
dumpfile- Output file.- Throws:
FileNotFoundException
-
export
Write the signal to the file given as argument.- Parameters:
file- Output File.
-
play
Sends the generated wave to the line in argument, if possible.- Parameters:
line- Line to used. Should be open, and remains open. User must make sure AudioFormat is compatible.- Throws:
LineUnavailableExceptionIOException
-
play
Sends the generated wave to the local machine's audio system, if possible.- Throws:
LineUnavailableExceptionIOException
-