mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-06 07:12:07 +01:00
mark correlation peak if possible
This commit is contained in:
parent
8a1d7ca7ba
commit
d207823011
|
|
@ -18,6 +18,10 @@ public class Demodulator {
|
||||||
private final Phasor baseBandOscillator;
|
private final Phasor baseBandOscillator;
|
||||||
private final Delay syncPulseDelay;
|
private final Delay syncPulseDelay;
|
||||||
private final Delay scanLineDelay;
|
private final Delay scanLineDelay;
|
||||||
|
private final int syncPulseSamples;
|
||||||
|
private float syncPulseMaxLevel;
|
||||||
|
private int syncPulseMaxPosition;
|
||||||
|
private int syncPulseCounter;
|
||||||
private Complex baseBand;
|
private Complex baseBand;
|
||||||
private Complex syncPulse;
|
private Complex syncPulse;
|
||||||
private Complex scanLine;
|
private Complex scanLine;
|
||||||
|
|
@ -34,8 +38,8 @@ public class Demodulator {
|
||||||
int scanLineFilterSamples = (int) Math.round(0.443 * sampleRate / scanLineCutoff) | 1;
|
int scanLineFilterSamples = (int) Math.round(0.443 * sampleRate / scanLineCutoff) | 1;
|
||||||
scanLineFilter = new ComplexMovingAverage(scanLineFilterSamples);
|
scanLineFilter = new ComplexMovingAverage(scanLineFilterSamples);
|
||||||
double syncPulseSeconds = 0.009;
|
double syncPulseSeconds = 0.009;
|
||||||
int syncPulseFilterSamples = (int) Math.round(syncPulseSeconds * sampleRate) | 1;
|
syncPulseSamples = (int) Math.round(syncPulseSeconds * sampleRate) | 1;
|
||||||
syncPulseFilter = new ComplexMovingAverage(syncPulseFilterSamples);
|
syncPulseFilter = new ComplexMovingAverage(syncPulseSamples);
|
||||||
float lowestFrequency = 1100;
|
float lowestFrequency = 1100;
|
||||||
float highestFrequency = 2300;
|
float highestFrequency = 2300;
|
||||||
float cutoffFrequency = (highestFrequency - lowestFrequency) / 2;
|
float cutoffFrequency = (highestFrequency - lowestFrequency) / 2;
|
||||||
|
|
@ -49,7 +53,7 @@ public class Demodulator {
|
||||||
scanLineOscillator = new Phasor(-(grayFrequency - centerFrequency), sampleRate);
|
scanLineOscillator = new Phasor(-(grayFrequency - centerFrequency), sampleRate);
|
||||||
int syncPulseDelaySamples = (powerWindowSamples - 1) / 2;
|
int syncPulseDelaySamples = (powerWindowSamples - 1) / 2;
|
||||||
syncPulseDelay = new Delay(syncPulseDelaySamples);
|
syncPulseDelay = new Delay(syncPulseDelaySamples);
|
||||||
int scanLineDelaySamples = (powerWindowSamples - 1) / 2 + (syncPulseFilterSamples - 1) / 2 - (scanLineFilterSamples - 1) / 2;
|
int scanLineDelaySamples = (powerWindowSamples - 1) / 2 + (syncPulseSamples - 1) / 2 - (scanLineFilterSamples - 1) / 2;
|
||||||
scanLineDelay = new Delay(scanLineDelaySamples);
|
scanLineDelay = new Delay(scanLineDelaySamples);
|
||||||
syncPulseTrigger = new SchmittTrigger(0.17f, 0.19f);
|
syncPulseTrigger = new SchmittTrigger(0.17f, 0.19f);
|
||||||
baseBand = new Complex();
|
baseBand = new Complex();
|
||||||
|
|
@ -66,10 +70,25 @@ public class Demodulator {
|
||||||
float scanLineValue = scanLineDelay.push(scanLineDemod.demod(scanLine));
|
float scanLineValue = scanLineDelay.push(scanLineDemod.demod(scanLine));
|
||||||
float syncPulseLevel = Math.min(Math.max(syncPulseValue, 0), 1);
|
float syncPulseLevel = Math.min(Math.max(syncPulseValue, 0), 1);
|
||||||
float scanLineLevel = Math.min(Math.max(0.5f * (scanLineValue + 1), 0), 1);
|
float scanLineLevel = Math.min(Math.max(0.5f * (scanLineValue + 1), 0), 1);
|
||||||
if (syncPulseTrigger.latch(syncPulseLevel))
|
if (syncPulseTrigger.latch(syncPulseLevel)) {
|
||||||
buffer[i] = -syncPulseLevel;
|
if (syncPulseMaxLevel < syncPulseLevel) {
|
||||||
else
|
syncPulseMaxLevel = syncPulseLevel;
|
||||||
|
syncPulseMaxPosition = syncPulseCounter;
|
||||||
|
}
|
||||||
|
++syncPulseCounter;
|
||||||
|
buffer[i] = syncPulseLevel;
|
||||||
|
} else if (syncPulseCounter > 0 && syncPulseCounter < syncPulseSamples) {
|
||||||
|
int offset = syncPulseCounter - syncPulseMaxPosition;
|
||||||
|
if (offset <= i)
|
||||||
|
buffer[i - offset] = -1;
|
||||||
|
syncPulseCounter = 0;
|
||||||
|
syncPulseMaxLevel = 0;
|
||||||
buffer[i] = scanLineLevel;
|
buffer[i] = scanLineLevel;
|
||||||
|
} else {
|
||||||
|
syncPulseCounter = 0;
|
||||||
|
syncPulseMaxLevel = 0;
|
||||||
|
buffer[i] = scanLineLevel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,15 +62,11 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private void visualizeSignal() {
|
private void visualizeSignal() {
|
||||||
for (float v : recordBuffer) {
|
for (float v : recordBuffer) {
|
||||||
int pixelColor = 0x00010101;
|
int pixelColor = 0xff00ff00;
|
||||||
float level = v;
|
if (v >= 0) {
|
||||||
if (v < 0) {
|
int intensity = (int) Math.round(255 * Math.sqrt(v));
|
||||||
level = -v;
|
pixelColor = 0xff000000 | 0x00010101 * intensity;
|
||||||
pixelColor = 0x00000100;
|
|
||||||
}
|
}
|
||||||
int intensity = (int) Math.round(255 * Math.sqrt(level));
|
|
||||||
pixelColor *= intensity;
|
|
||||||
pixelColor |= 0xff000000;
|
|
||||||
scopePixels[scopeWidth * curLine + curColumn] = pixelColor;
|
scopePixels[scopeWidth * curLine + curColumn] = pixelColor;
|
||||||
if (++curColumn >= scopeWidth) {
|
if (++curColumn >= scopeWidth) {
|
||||||
curColumn = 0;
|
curColumn = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue