|
@@ -1,11 +1,8 @@
|
|
|
package QuickVerifyCrap;
|
|
|
|
|
|
-import java.io.FileNotFoundException;
|
|
|
import java.io.RandomAccessFile;
|
|
|
-import java.math.BigInteger;
|
|
|
import java.nio.ByteBuffer;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -14,12 +11,13 @@ public class Logic2PWMMassageliege
|
|
|
static final int REFRATE = 500_000_000;
|
|
|
static final int SAMPLELENGTH=REFRATE/32_000;//500MS samplerate/32KHz
|
|
|
static final int SAMPLELENGTH_BUFFERED= (int) (REFRATE/2);//1/2 second of no jiggly edges mark a "file" end
|
|
|
+ static final int GLITCH_IN_TICKS=30;
|
|
|
public static void main(String[] args) throws Exception
|
|
|
{
|
|
|
List<Long> edges_ch1 = new ArrayList<>();
|
|
|
List<Long> edges_ch2 = new ArrayList<>();
|
|
|
//String basepath = "/home/tgoerner/loa/000034/export/";
|
|
|
- String basepath = "/mnt/d/LOA/000034/export/";
|
|
|
+ String basepath = "/mnt/d/LOA/000034/mtexport/";
|
|
|
RandomAccessFile ch1 = new RandomAccessFile(basepath+"digital_0.bin","r");
|
|
|
RandomAccessFile ch2 = new RandomAccessFile(basepath+"digital_1.bin","r");
|
|
|
ch1.readLong(); //magic LMAA
|
|
@@ -49,16 +47,43 @@ public class Logic2PWMMassageliege
|
|
|
buffer.putLong(temp);
|
|
|
buffer.rewind();
|
|
|
Long massaged = (long)(buffer.getDouble()*REFRATE);
|
|
|
- edges_ch1.add(massaged);
|
|
|
- writeptr++;
|
|
|
+ boolean glitch=false;
|
|
|
if(risingEdge)
|
|
|
{
|
|
|
- //synthetic zero-length sample for the other side
|
|
|
- edges_ch2.add(massaged);
|
|
|
- edges_ch2.add(massaged);
|
|
|
+ long notaglitch = ch1.getFilePointer();
|
|
|
+
|
|
|
+ temp = Long.reverseBytes(ch1.readLong());
|
|
|
+ buffer = ByteBuffer.allocate(Long.BYTES);
|
|
|
+ buffer.putLong(temp);
|
|
|
+ buffer.rewind();
|
|
|
+ Long glitchcheck = (long)(buffer.getDouble()*REFRATE);
|
|
|
+ glitch = (glitchcheck-massaged)<GLITCH_IN_TICKS;
|
|
|
+ if(!glitch)
|
|
|
+ {
|
|
|
+ ch1.seek(notaglitch);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ writeptr+=2; //skipping the glitch, that requires 2 countups
|
|
|
+ System.out.println("Glitch suppressed at"+((double)massaged/(double)REFRATE));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- risingEdge = !risingEdge;
|
|
|
+
|
|
|
+ if(!glitch)
|
|
|
+ {
|
|
|
+ edges_ch1.add(massaged);
|
|
|
+ writeptr++;
|
|
|
+
|
|
|
+ if(risingEdge)
|
|
|
+ {
|
|
|
+ //synthetic zero-length sample for the other side
|
|
|
+ edges_ch2.add(massaged);
|
|
|
+ edges_ch2.add(massaged);
|
|
|
+ }
|
|
|
+
|
|
|
+ risingEdge = !risingEdge;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -81,6 +106,8 @@ public class Logic2PWMMassageliege
|
|
|
// writeptr++;
|
|
|
//}
|
|
|
|
|
|
+ //deltaTi
|
|
|
+
|
|
|
risingEdge = true;
|
|
|
while(writeptr<countEdges2)
|
|
|
{
|
|
@@ -89,16 +116,41 @@ public class Logic2PWMMassageliege
|
|
|
buffer.putLong(temp);
|
|
|
buffer.rewind();
|
|
|
Long massaged = (long)(buffer.getDouble()*REFRATE);
|
|
|
- edges_ch2.add(massaged);
|
|
|
- writeptr++;
|
|
|
+
|
|
|
+ boolean glitch=false;
|
|
|
if(risingEdge)
|
|
|
{
|
|
|
- //synthetic zero-length sample for the other side
|
|
|
- edges_ch1.add(massaged);
|
|
|
- edges_ch1.add(massaged);
|
|
|
+ long notaglitch = ch2.getFilePointer();
|
|
|
+
|
|
|
+ temp = Long.reverseBytes(ch2.readLong());
|
|
|
+ buffer = ByteBuffer.allocate(Long.BYTES);
|
|
|
+ buffer.putLong(temp);
|
|
|
+ buffer.rewind();
|
|
|
+ Long glitchcheck = (long)(buffer.getDouble()*REFRATE);
|
|
|
+ glitch = (glitchcheck-massaged)<GLITCH_IN_TICKS;
|
|
|
+ if(!glitch)
|
|
|
+ {
|
|
|
+ ch2.seek(notaglitch);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ writeptr+=2; //skipping the glitch, that requires 2 countups
|
|
|
+ System.out.println("Glitch suppressed at"+((double)massaged/(double)REFRATE));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!glitch)
|
|
|
+ {
|
|
|
+ edges_ch2.add(massaged);
|
|
|
+ writeptr++;
|
|
|
+ if(risingEdge)
|
|
|
+ {
|
|
|
+ //synthetic zero-length sample for the other side
|
|
|
+ edges_ch1.add(massaged);
|
|
|
+ edges_ch1.add(massaged);
|
|
|
+ }
|
|
|
+ risingEdge = !risingEdge;
|
|
|
}
|
|
|
- writeptr++;
|
|
|
- risingEdge = !risingEdge;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -140,6 +192,12 @@ public class Logic2PWMMassageliege
|
|
|
deltaLow=SAMPLELENGTH; //syntethisieren falls keine nächste steigende flanke für echten wert
|
|
|
cutoff=true;
|
|
|
}
|
|
|
+ if(deltaLow==0)
|
|
|
+ {
|
|
|
+ System.out.println("BADDATA!!!!!");
|
|
|
+ System.out.println(((double)edges_ch1.get(c1)/(double)REFRATE));
|
|
|
+ }
|
|
|
+
|
|
|
int sample = (int)((deltaHigh*32768)/deltaLow);
|
|
|
|
|
|
deltaHigh =edges_ch2.get(c1+1)-edges_ch2.get(c1);
|
|
@@ -168,6 +226,12 @@ public class Logic2PWMMassageliege
|
|
|
shortGap = (int)Math.round(gap);
|
|
|
}
|
|
|
|
|
|
+ if(deltaLow==0)
|
|
|
+ {
|
|
|
+ System.out.println("BADDATA!!!!!");
|
|
|
+ System.out.println(((double)edges_ch1.get(c1)/(double)REFRATE));
|
|
|
+ }
|
|
|
+
|
|
|
sample -= (int)((deltaHigh*32768)/deltaLow);
|
|
|
if(sample>32767)
|
|
|
{
|