mirror of
https://github.com/xdsopl/robot36.git
synced 2026-01-20 15:00:16 +01:00
align sync pulses with scan line
This commit is contained in:
parent
3ae7e18df3
commit
fee4012c6a
|
|
@ -37,7 +37,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
private float[] recordBuffer;
|
||||
private AudioRecord audioRecord;
|
||||
private TextView status;
|
||||
private Delay powerDelay;
|
||||
private Delay syncPulseDelay;
|
||||
private Delay scanLineDelay;
|
||||
private SimpleMovingAverage powerAvg;
|
||||
private ComplexMovingAverage syncPulseFilter;
|
||||
private ComplexMovingAverage scanLineFilter;
|
||||
|
|
@ -74,8 +75,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
baseBand = baseBandLowPass.avg(baseBand.set(v).mul(baseBandOscillator.rotate()));
|
||||
syncPulse = syncPulseFilter.avg(syncPulse.set(baseBand).mul(syncPulseOscillator.rotate()));
|
||||
scanLine = scanLineFilter.avg(scanLine.set(baseBand).mul(scanLineOscillator.rotate()));
|
||||
float syncPulseValue = powerDelay.push(syncPulse.norm()) / powerAvg.avg(baseBand.norm());
|
||||
float scanLineValue = scanLineDemod.demod(scanLine);
|
||||
float syncPulseValue = syncPulseDelay.push(syncPulse.norm()) / powerAvg.avg(baseBand.norm());
|
||||
float scanLineValue = scanLineDelay.push(scanLineDemod.demod(scanLine));
|
||||
float syncPulseLevel = Math.min(Math.max(syncPulseValue, 0), 1);
|
||||
float scanLineLevel = Math.min(Math.max(0.5f * (scanLineValue + 1), 0), 1);
|
||||
int syncPulseIntensity = (int) Math.round(255 * Math.sqrt(syncPulseLevel));
|
||||
|
|
@ -103,17 +104,16 @@ public class MainActivity extends AppCompatActivity {
|
|||
double powerWindowSeconds = 0.5;
|
||||
int powerWindowSamples = (int) Math.round(powerWindowSeconds * sampleRate) | 1;
|
||||
powerAvg = new SimpleMovingAverage(powerWindowSamples);
|
||||
powerDelay = new Delay((powerWindowSamples - 1) / 2);
|
||||
float blackFrequency = 1500;
|
||||
float whiteFrequency = 2300;
|
||||
float scanLineBandwidth = whiteFrequency - blackFrequency;
|
||||
scanLineDemod = new FrequencyModulation(scanLineBandwidth, sampleRate);
|
||||
float scanLineCutoff = scanLineBandwidth / 2;
|
||||
int scanLineSamples = (int) Math.round(0.443 * sampleRate / scanLineCutoff) | 1;
|
||||
scanLineFilter = new ComplexMovingAverage(scanLineSamples);
|
||||
int scanLineFilterSamples = (int) Math.round(0.443 * sampleRate / scanLineCutoff) | 1;
|
||||
scanLineFilter = new ComplexMovingAverage(scanLineFilterSamples);
|
||||
double syncPulseSeconds = 0.009;
|
||||
int syncPulseSamples = (int) Math.round(syncPulseSeconds * sampleRate);
|
||||
syncPulseFilter = new ComplexMovingAverage(syncPulseSamples);
|
||||
int syncPulseFilterSamples = (int) Math.round(syncPulseSeconds * sampleRate) | 1;
|
||||
syncPulseFilter = new ComplexMovingAverage(syncPulseFilterSamples);
|
||||
float lowestFrequency = 1100;
|
||||
float highestFrequency = 2300;
|
||||
float cutoffFrequency = (highestFrequency - lowestFrequency) / 2;
|
||||
|
|
@ -125,6 +125,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
syncPulseOscillator = new Phasor(-(syncPulseFrequency - centerFrequency), sampleRate);
|
||||
float grayFrequency = (blackFrequency + whiteFrequency) / 2;
|
||||
scanLineOscillator = new Phasor(-(grayFrequency - centerFrequency), sampleRate);
|
||||
int syncPulseDelaySamples = (powerWindowSamples - 1) / 2;
|
||||
syncPulseDelay = new Delay(syncPulseDelaySamples);
|
||||
int scanLineDelaySamples = (powerWindowSamples - 1) / 2 + (syncPulseFilterSamples - 1) / 2 - (scanLineFilterSamples - 1) / 2;
|
||||
scanLineDelay = new Delay(scanLineDelaySamples);
|
||||
baseBand = new Complex();
|
||||
syncPulse = new Complex();
|
||||
scanLine = new Complex();
|
||||
|
|
|
|||
Loading…
Reference in a new issue