Package org.harctoolbox.ircore
Class ModulatedIrSequence
java.lang.Object
org.harctoolbox.ircore.IrSequence
org.harctoolbox.ircore.ModulatedIrSequence
- All Implemented Interfaces:
Serializable
,Cloneable
A ModulatedIrSequence is an IrSequence with the additional properties of a modulation frequency and a duty cycle.
The name is slightly misleading since the modulation frequency can be 0; it just needs to be present.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
static final double
static final double
static final ModulatedIrSequence
Fields inherited from class org.harctoolbox.ircore.IrSequence
DUMMYGAPDURATION
-
Constructor Summary
ConstructorDescriptionModulatedIrSequence
(double[] durations, Double frequency) Constructs a ModulatedIrSequence from its arguments.ModulatedIrSequence
(double[] durations, Double frequency, Double dutyCycle) Constructs a ModulatedIrSequence from its arguments.ModulatedIrSequence
(int[] durations, Double frequency) Constructs a ModulatedIrSequence from its arguments.ModulatedIrSequence
(int[] durations, Double frequency, Double dutyCycle) Constructs a ModulatedIrSequence from its arguments.ModulatedIrSequence
(IrSequence irSequence, Double frequency) Constructs a ModulatedIrSequence from its arguments.ModulatedIrSequence
(IrSequence irSequence, Double frequency, Double dutyCycle) Constructs a ModulatedIrSequence from its arguments.ModulatedIrSequence
(ModulatedIrSequence src, int start, int length) -
Method Summary
Modifier and TypeMethodDescriptionaddNoise
(double max) Adds a random number in the interval [-max, max) to each flash, and subtract it from the next gap.append
(double delay) Appends a delay to the end of the ModulatedIrSequence.append
(ModulatedIrSequence tail) boolean
approximatelyEquals
(ModulatedIrSequence irSequence) Compares two ModulatedIrSequences for (approximate) equality.boolean
approximatelyEquals
(ModulatedIrSequence irSequence, double absoluteTolerance, double relativeTolerance) Compares two ModulatedIrSequences for (approximate) equality.boolean
approximatelyEquals
(ModulatedIrSequence irSequence, double absoluteTolerance, double relativeTolerance, double frequencyTolerance) Compares two ModulatedIrSequences for (approximate) equality.boolean
approximatelyEquals
(ModulatedIrSequence irSequence, double absoluteTolerance, double relativeTolerance, double frequencyTolerance, double dutyCycleTolerance) Compares two ModulatedIrSequences for (approximate) equality.chop
(double amount) Chops a IrSequence in parts.clone()
Creates and returns a copy of this object.static ModulatedIrSequence
concatenate
(Collection<IrSequence> sequences, double frequency, double dutyCycle) static ModulatedIrSequence
concatenate
(ModulatedIrSequence[] seqs) Concatenates the IrSequences in the argument to a new sequence.static ModulatedIrSequence
demodulate
(IrSequence irSequence) Equivalent to the two parameter version with a default threshold.static ModulatedIrSequence
demodulate
(IrSequence irSequence, double threshold) From a (non-modulated) IrSequence, consisting of on- and off-periods, remove the modulation and determine a modulation frequency and duty cycle, gathered from the statistics of the input IrSequence.static Double
double
double
static double
getFrequencyWithDefault
(Double frequency) static boolean
isValidDutyCycle
(Double dutyCycle) Checks the argument for null or validity of duty cycle (0, 1).boolean
modulate()
Generates a IrSequence, consisting of on- and off-periods, containing the modulation, as per the modulation frequency and duty cycle.setFrequency
(Double newFrequency) toStringFrequency
(boolean alternatingSigns) Methods inherited from class org.harctoolbox.ircore.IrSequence
addToFlashes, addToGaps, append, append, approximatelyEquals, approximatelyEquals, approximatelyEquals, approximatelyEquals, concatenate, concatenate, containsZeros, firstBigGap, flashExcess, get, getLastGap, getLength, getTotalDuration, getTotalDuration, initRandom, initRandom, isEmpty, normalize, replaceZeros, stripDecoratedString, subSequence, toDoubles, toDoublesPreservingSigns, toInterleavingList, toInts, toInts, toPulses, toString, toString, toString, toString, truncate
-
Field Details
-
DEFAULT_FREQUENCY
public static final double DEFAULT_FREQUENCY- See Also:
-
DEFAULT_DUTYCYCLE
public static final double DEFAULT_DUTYCYCLE- See Also:
-
DEFAULT_DEMODULATE_THRESHOLD
public static final double DEFAULT_DEMODULATE_THRESHOLD- See Also:
-
EMPTY
-
-
Constructor Details
-
ModulatedIrSequence
public ModulatedIrSequence() -
ModulatedIrSequence
Constructs a ModulatedIrSequence from its arguments.- Parameters:
irSequence
- irSequence to be copied fromfrequency
-dutyCycle
-
-
ModulatedIrSequence
Constructs a ModulatedIrSequence from its arguments.- Parameters:
irSequence
- irSequence to be copied fromfrequency
-
-
ModulatedIrSequence
public ModulatedIrSequence(ModulatedIrSequence src, int start, int length) throws InvalidArgumentException - Parameters:
src
-start
-length
-- Throws:
InvalidArgumentException
-
ModulatedIrSequence
public ModulatedIrSequence(double[] durations, Double frequency, Double dutyCycle) throws OddSequenceLengthException Constructs a ModulatedIrSequence from its arguments.- Parameters:
durations
-frequency
-dutyCycle
-- Throws:
OddSequenceLengthException
-
ModulatedIrSequence
Constructs a ModulatedIrSequence from its arguments.- Parameters:
durations
-frequency
-- Throws:
OddSequenceLengthException
- if duration has odd length.
-
ModulatedIrSequence
public ModulatedIrSequence(int[] durations, Double frequency, Double dutyCycle) throws OddSequenceLengthException Constructs a ModulatedIrSequence from its arguments.- Parameters:
durations
-frequency
-dutyCycle
-- Throws:
OddSequenceLengthException
- if duration has odd length.
-
ModulatedIrSequence
Constructs a ModulatedIrSequence from its arguments.- Parameters:
durations
-frequency
-- Throws:
OddSequenceLengthException
- if duration has odd length.
-
-
Method Details
-
concatenate
public static ModulatedIrSequence concatenate(Collection<IrSequence> sequences, double frequency, double dutyCycle) -
concatenate
Concatenates the IrSequences in the argument to a new sequence. Frequency and duty cycle are set to the average between minimum and maximum values by the components, if it makes sense.- Parameters:
seqs
- One or more ModulatedIrSequences- Returns:
-
getFrequencyWithDefault
-
isValidDutyCycle
Checks the argument for null or validity of duty cycle (0, 1).- Parameters:
dutyCycle
- number to be checked. null is allowed.- Returns:
-
demodulate
From a (non-modulated) IrSequence, consisting of on- and off-periods, remove the modulation and determine a modulation frequency and duty cycle, gathered from the statistics of the input IrSequence.- Parameters:
irSequence
- input signalthreshold
- Gaps less or equal to this quantity are squashed into a modulated flash.- Returns:
- ModulatedIrSequence
-
demodulate
Equivalent to the two parameter version with a default threshold.- Parameters:
irSequence
- input signal, modulated- Returns:
- ModulatedIrSignal
-
frequencyAverage
-
getFrequency
- Returns:
- modulation frequency in Hz.
-
getFrequencyWithDefault
public double getFrequencyWithDefault() -
getDutyCycle
- Returns:
- Duty cycle.
-
getDutyCycleWithDefault
public double getDutyCycleWithDefault() -
toStringFrequency
-
toStringFrequency
-
toIrSignal
-
setFrequency
-
approximatelyEquals
public boolean approximatelyEquals(ModulatedIrSequence irSequence, double absoluteTolerance, double relativeTolerance, double frequencyTolerance, double dutyCycleTolerance) Compares two ModulatedIrSequences for (approximate) equality.- Parameters:
irSequence
- to be compared against this.absoluteTolerance
- tolerance threshold in microseconds.relativeTolerance
- relative threshold, between 0 and 1.frequencyTolerance
- tolerance (absolute) for frequency in Hz.dutyCycleTolerance
- tolerance (absolute) for duty cycle (< 1).- Returns:
- equality within tolerance.
-
approximatelyEquals
public boolean approximatelyEquals(ModulatedIrSequence irSequence, double absoluteTolerance, double relativeTolerance, double frequencyTolerance) Compares two ModulatedIrSequences for (approximate) equality.- Parameters:
irSequence
- to be compared against this.absoluteTolerance
- tolerance threshold in microseconds.relativeTolerance
- relative threshold, between 0 and 1.frequencyTolerance
-- Returns:
- equality within tolerance.
-
approximatelyEquals
public boolean approximatelyEquals(ModulatedIrSequence irSequence, double absoluteTolerance, double relativeTolerance) Compares two ModulatedIrSequences for (approximate) equality.- Parameters:
irSequence
- to be compared against this.absoluteTolerance
- tolerance threshold in microseconds.relativeTolerance
- relative threshold, between 0 and 1.- Returns:
- equality within tolerance.
-
approximatelyEquals
Compares two ModulatedIrSequences for (approximate) equality.- Parameters:
irSequence
- to be compared against this.- Returns:
- equality within tolerance.
-
isZeroModulated
public boolean isZeroModulated()- Returns:
- true if and only iff the modulation frequency is zero (in numerical sense).
-
addNoise
Description copied from class:IrSequence
Adds a random number in the interval [-max, max) to each flash, and subtract it from the next gap. For generating test data for decoders etc. NOTE: initRandom must have been called before this call.- Overrides:
addNoise
in classIrSequence
- Parameters:
max
- max amount to add/subtract, in microseconds.- Returns:
- new instance
-
append
Appends a delay to the end of the ModulatedIrSequence. Original is left untouched.- Overrides:
append
in classIrSequence
- Parameters:
delay
- microseconds of silence to be appended to the IrSequence.- Returns:
- Copy of object with additional delay at end.
- Throws:
InvalidArgumentException
-
append
- Throws:
InvalidArgumentException
-
chop
Description copied from class:IrSequence
Chops a IrSequence in parts. Every gap of length ≥ threshold cause a cut.- Overrides:
chop
in classIrSequence
- Parameters:
amount
- minimal gap in microseconds to cause a cut.- Returns:
- List of IrSequences
-
clone
Description copied from class:IrSequence
Creates and returns a copy of this object.- Overrides:
clone
in classIrSequence
- Returns:
- A copy of this IrSequence.
-
modulate
Generates a IrSequence, consisting of on- and off-periods, containing the modulation, as per the modulation frequency and duty cycle. If the latter is not present in the calling object, a default (currently 0.4 = 40%) is used.- Returns:
- (non-modulated) IrSequence
-