Added some comments

This commit is contained in:
Marek Ossowski 2025-08-03 20:58:48 +02:00
parent e8be1f9600
commit f003ea4870
4 changed files with 47 additions and 1 deletions

View file

@ -405,6 +405,9 @@ public class Decoder {
return true;
}
/**
@return true if new lines present
*/
public boolean process(float[] recordBuffer, int channelSelect) {
boolean syncPulseDetected = demodulator.process(recordBuffer, channelSelect);
int syncPulseIndex = currentSample + demodulator.syncPulseOffset;

View file

@ -66,7 +66,7 @@ public class Demodulator {
double centerFrequency = (lowestFrequency + highestFrequency) / 2;
baseBandOscillator = new Phasor(-centerFrequency, sampleRate);
double syncPulseFrequency = 1200;
syncPulseFrequencyValue = (float) ((syncPulseFrequency - centerFrequency) * 2 / scanLineBandwidth);
syncPulseFrequencyValue = (float) ((syncPulseFrequency - centerFrequency) * 2 / scanLineBandwidth); //converts to range from -1 to 1
syncPulseFrequencyTolerance = (float) (50 * 2 / scanLineBandwidth);
double syncPorchFrequency = 1500;
double syncHighFrequency = (syncPulseFrequency + syncPorchFrequency) / 2;
@ -77,6 +77,9 @@ public class Demodulator {
baseBand = new Complex();
}
/**
* @return true if sync pulse detected
*/
public boolean process(float[] buffer, int channelSelect) {
boolean syncPulseDetected = false;
int channels = channelSelect > 0 ? 2 : 1;

View file

@ -7,21 +7,55 @@ Copyright 2024 Ahmet Inan <xdsopl@gmail.com>
package xdsopl.robot36;
public interface Mode {
/**
* @return mode name
*/
String getName();
/**
* @return VIS code
*/
int getCode();
/**
* @return image width
*/
int getWidth();
/**
* @return image height
*/
int getHeight();
/**
* @return number of samples from sync pulse to start of image data
*/
int getBegin();
/**
* @return number of samples from start of scanline to sync pulse??? nonzero for Scottie only?
*/
int getFirstSyncPulseIndex();
/**
* @return number of samples in a scanline
*/
int getScanLineSamples();
/**
* Reset internal state.
*/
void reset();
/**
* @param pixelBuffer buffer to store decoded pixels
* @param scratchBuffer buffer for temporary data
* @param scanLineBuffer raw samples to be decoded, can contain more than one scanline
* @param scopeBufferWidth ??? used in RawDecoder, initializes width?
* @param syncPulseIndex number of samples from array start to sync pulse
* @param scanLineSamples number of samples per scanline
* @param frequencyOffset correction of frequency of expected vs actual sync pulse (normalized to range (-1, 1))
* @return true if scanline was decoded
*/
boolean decodeScanLine(PixelBuffer pixelBuffer, float[] scratchBuffer, float[] scanLineBuffer, int scopeBufferWidth, int syncPulseIndex, int scanLineSamples, float frequencyOffset);
}

View file

@ -47,6 +47,12 @@ public class Robot_72_Color implements Mode {
lowPassFilter = new ExponentialMovingAverage();
}
/**
* FIXME same in other modes (copy&paste)
* @param frequency frequency, range (-1,1)
* @param offset correction, range (-1,1)
* @return pixel value, range (0,1)
*/
private float freqToLevel(float frequency, float offset) {
return 0.5f * (frequency - offset + 1.f);
}