mirror of
https://github.com/xdsopl/robot36.git
synced 2026-01-26 01:14:14 +01:00
Extracted Demodulator.normalizeFrequency()
This commit is contained in:
parent
8173f147d8
commit
4779d67180
|
|
@ -13,6 +13,8 @@ public class Demodulator {
|
|||
private final SchmittTrigger syncPulseTrigger;
|
||||
private final Phasor baseBandOscillator;
|
||||
private final Delay syncPulseValueDelay;
|
||||
private final double scanLineBandwidth;
|
||||
private final double centerFrequency;
|
||||
private final float syncPulseFrequencyValue;
|
||||
private final float syncPulseFrequencyTolerance;
|
||||
private final int syncPulse5msMinSamples;
|
||||
|
|
@ -38,7 +40,7 @@ public class Demodulator {
|
|||
public static final double whiteFrequency = 2300;
|
||||
|
||||
Demodulator(int sampleRate) {
|
||||
double scanLineBandwidth = whiteFrequency - blackFrequency;
|
||||
scanLineBandwidth = whiteFrequency - blackFrequency;
|
||||
frequencyModulation = new FrequencyModulation(scanLineBandwidth, sampleRate);
|
||||
double syncPulse5msSeconds = 0.005;
|
||||
double syncPulse9msSeconds = 0.009;
|
||||
|
|
@ -65,19 +67,23 @@ public class Demodulator {
|
|||
Kaiser kaiser = new Kaiser();
|
||||
for (int i = 0; i < baseBandLowPass.length; ++i)
|
||||
baseBandLowPass.taps[i] = (float) (kaiser.window(2.0, i, baseBandLowPass.length) * Filter.lowPass(cutoffFrequency, sampleRate, i, baseBandLowPass.length));
|
||||
double centerFrequency = (lowestFrequency + highestFrequency) / 2;
|
||||
centerFrequency = (lowestFrequency + highestFrequency) / 2;
|
||||
baseBandOscillator = new Phasor(-centerFrequency, sampleRate);
|
||||
syncPulseFrequencyValue = (float) ((syncPulseFrequency - centerFrequency) * 2 / scanLineBandwidth); //converts to range from -1 to 1
|
||||
syncPulseFrequencyValue = (float) normalizeFrequency(syncPulseFrequency);
|
||||
syncPulseFrequencyTolerance = (float) (50 * 2 / scanLineBandwidth);
|
||||
double syncPorchFrequency = 1500;
|
||||
double syncHighFrequency = (syncPulseFrequency + syncPorchFrequency) / 2;
|
||||
double syncLowFrequency = (syncPulseFrequency + syncHighFrequency) / 2;
|
||||
double syncLowValue = (syncLowFrequency - centerFrequency) * 2 / scanLineBandwidth;
|
||||
double syncHighValue = (syncHighFrequency - centerFrequency) * 2 / scanLineBandwidth;
|
||||
double syncLowValue = normalizeFrequency(syncLowFrequency);
|
||||
double syncHighValue = normalizeFrequency(syncHighFrequency);
|
||||
syncPulseTrigger = new SchmittTrigger((float) syncLowValue, (float) syncHighValue);
|
||||
baseBand = new Complex();
|
||||
}
|
||||
|
||||
private double normalizeFrequency(double frequency) {
|
||||
return (frequency - centerFrequency) * 2 / scanLineBandwidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if sync pulse detected
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue