help confused Scottie with finding the scratch buffer

pull/11/head
Ahmet Inan 2024-04-25 06:50:15 +02:00
rodzic 558120116d
commit 527a4e3818
2 zmienionych plików z 12 dodań i 8 usunięć

Wyświetl plik

@ -52,7 +52,9 @@ public class Decoder {
double scanLineMaxSeconds = 7;
int scanLineMaxSamples = (int) Math.round(scanLineMaxSeconds * sampleRate);
scanLineBuffer = new float[scanLineMaxSamples];
scratchBuffer = new float[sampleRate];
double scratchBufferSeconds = 1.1;
int scratchBufferSamples = (int) Math.round(scratchBufferSeconds * sampleRate);
scratchBuffer = new float[scratchBufferSamples];
int scanLineCount = 4;
last5msScanLines = new int[scanLineCount];
last9msScanLines = new int[scanLineCount];
@ -160,10 +162,12 @@ public class Decoder {
if (lines[0] == 0)
return false;
double mean = scanLineMean(lines);
int scanLineSamples = (int) Math.round(mean);
if (scanLineSamples > scratchBuffer.length)
return false;
if (scanLineStdDev(lines, mean) > scanLineToleranceSamples)
return false;
float frequencyOffset = (float) frequencyOffsetMean(freqOffs);
int scanLineSamples = (int) Math.round(mean);
Mode mode = detectMode(modes, scanLineSamples);
boolean pictureChanged = lastMode != mode
|| Math.abs(lastScanLineSamples - scanLineSamples) > scanLineToleranceSamples

Wyświetl plik

@ -23,11 +23,11 @@ public class RGBDecoder implements Mode {
this.name = name;
scanLineSamples = (int) Math.round(scanLineSeconds * sampleRate);
beginSamples = (int) Math.round(beginSeconds * sampleRate);
redBeginSamples = (int) Math.round(redBeginSeconds * sampleRate);
redBeginSamples = (int) Math.round(redBeginSeconds * sampleRate) - beginSamples;
redSamples = (int) Math.round((redEndSeconds - redBeginSeconds) * sampleRate);
greenBeginSamples = (int) Math.round(greenBeginSeconds * sampleRate);
greenBeginSamples = (int) Math.round(greenBeginSeconds * sampleRate) - beginSamples;
greenSamples = (int) Math.round((greenEndSeconds - greenBeginSeconds) * sampleRate);
blueBeginSamples = (int) Math.round(blueBeginSeconds * sampleRate);
blueBeginSamples = (int) Math.round(blueBeginSeconds * sampleRate) - beginSamples;
blueSamples = (int) Math.round((blueEndSeconds - blueBeginSeconds) * sampleRate);
endSamples = (int) Math.round(endSeconds * sampleRate);
lowPassFilter = new ExponentialMovingAverage();
@ -53,10 +53,10 @@ public class RGBDecoder implements Mode {
return 0;
lowPassFilter.cutoff(evenBuffer.length, 2 * greenSamples, 2);
lowPassFilter.reset();
for (int i = beginSamples; i < endSamples; ++i)
scratchBuffer[i] = lowPassFilter.avg(scanLineBuffer[syncPulseIndex + i]);
for (int i = 0; i < endSamples - beginSamples; ++i)
scratchBuffer[i] = lowPassFilter.avg(scanLineBuffer[syncPulseIndex + beginSamples + i]);
lowPassFilter.reset();
for (int i = endSamples - 1; i >= beginSamples; --i)
for (int i = endSamples - beginSamples - 1; i >= 0; --i)
scratchBuffer[i] = freqToLevel(lowPassFilter.avg(scratchBuffer[i]), frequencyOffset);
for (int i = 0; i < evenBuffer.length; ++i) {
int redPos = redBeginSamples + (i * redSamples) / evenBuffer.length;