mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 16:42:27 +00:00
Better SUD timing
Using latest microsecond time extraction from SUD unpack
This commit is contained in:
parent
ee24c0ab6b
commit
068a8b1a27
@ -48,7 +48,7 @@ public class SUDFileTime {
|
|||||||
if (sudMap == null) {
|
if (sudMap == null) {
|
||||||
return Long.MIN_VALUE;
|
return Long.MIN_VALUE;
|
||||||
}
|
}
|
||||||
long t = sudMap.getFirstChunkTime();
|
long t = sudMap.getFirstChunkTimeMillis();
|
||||||
if (t != 0) {
|
if (t != 0) {
|
||||||
sudTime = t;
|
sudTime = t;
|
||||||
}
|
}
|
||||||
|
@ -1096,7 +1096,7 @@ public class ClickDetector extends PamProcess {
|
|||||||
* @return true if the tasks complete successfully and the click is to be kept.
|
* @return true if the tasks complete successfully and the click is to be kept.
|
||||||
* false otherwise.
|
* false otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean completeClick(ClickDetection newClick) {
|
public boolean completeClick(ClickDetection newClick) {
|
||||||
|
|
||||||
if (newClick.dataType == ClickDetection.CLICK_CLICK) {
|
if (newClick.dataType == ClickDetection.CLICK_CLICK) {
|
||||||
int nChannels = PamUtils.getNumChannels(newClick.getChannelBitmap());
|
int nChannels = PamUtils.getNumChannels(newClick.getChannelBitmap());
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
package soundtrap;
|
package soundtrap;
|
||||||
|
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
@ -33,7 +34,10 @@ import Acquisition.AcquisitionControl;
|
|||||||
import Acquisition.sud.SUDNotificationManager;
|
import Acquisition.sud.SUDNotificationManager;
|
||||||
import PamController.PamController;
|
import PamController.PamController;
|
||||||
import PamguardMVC.PamRawDataBlock;
|
import PamguardMVC.PamRawDataBlock;
|
||||||
|
import clickDetector.ClickBTDisplay;
|
||||||
import clickDetector.ClickControl;
|
import clickDetector.ClickControl;
|
||||||
|
import clickDetector.ClickDisplay;
|
||||||
|
import clickDetector.ClickDisplayManager;
|
||||||
import soundtrap.sud.SudFileDWVHandler;
|
import soundtrap.sud.SudFileDWVHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,5 +140,19 @@ public class STClickControl extends ClickControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when running SUD file data to find and scroll the BT Display's
|
||||||
|
* @param timeMillis
|
||||||
|
*/
|
||||||
|
public void updateDisplayScrollers(long timeMillis) {
|
||||||
|
ClickDisplayManager dispManager = getDisplayManager();
|
||||||
|
ArrayList<ClickDisplay> dispList = dispManager.getWindowList();
|
||||||
|
for (ClickDisplay display : dispList) {
|
||||||
|
if (display instanceof ClickBTDisplay) {
|
||||||
|
((ClickBTDisplay) display).newScrollTimingData(timeMillis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class SudFileDWVHandler implements SUDNotificationHandler {
|
|||||||
private List<BCLDetectionChunk> bclChunks = new LinkedList();
|
private List<BCLDetectionChunk> bclChunks = new LinkedList();
|
||||||
|
|
||||||
int bclDetCount, bclNoiseCount, dwvCount, processedChunks;
|
int bclDetCount, bclNoiseCount, dwvCount, processedChunks;
|
||||||
private long effortStart;
|
private long effortStart, fileStartMicros;
|
||||||
private double sampleRate;
|
private double sampleRate;
|
||||||
private ByteConverter byteConverter;
|
private ByteConverter byteConverter;
|
||||||
private ClickDetector clickDetector;
|
private ClickDetector clickDetector;
|
||||||
@ -73,6 +73,7 @@ public class SudFileDWVHandler implements SUDNotificationHandler {
|
|||||||
// sampleRate = sudAudioInputStream.getFormat().getFrameRate();
|
// sampleRate = sudAudioInputStream.getFormat().getFrameRate();
|
||||||
// this is the right one
|
// this is the right one
|
||||||
sampleRate = sudAudioInputStream.getSudMap().clickDetSampleRate;
|
sampleRate = sudAudioInputStream.getSudMap().clickDetSampleRate;
|
||||||
|
fileStartMicros = sudAudioInputStream.getSudMap().getFirstChunkTimeMicros();
|
||||||
stClickControl.findRawDataBlock().setChannelMap(1);
|
stClickControl.findRawDataBlock().setChannelMap(1);
|
||||||
stClickControl.findRawDataBlock().setSampleRate((float) sampleRate, true);
|
stClickControl.findRawDataBlock().setSampleRate((float) sampleRate, true);
|
||||||
stClickControl.getSTAcquisition().acquisitionParameters.sampleRate = (float) sampleRate;
|
stClickControl.getSTAcquisition().acquisitionParameters.sampleRate = (float) sampleRate;
|
||||||
@ -100,8 +101,12 @@ public class SudFileDWVHandler implements SUDNotificationHandler {
|
|||||||
String chunkName = "Unknown";
|
String chunkName = "Unknown";
|
||||||
int chunkSize = sudChunk.buffer.length;
|
int chunkSize = sudChunk.buffer.length;
|
||||||
if (sudAudioInputStream.getChunkIDString(chunkID).equals("wav")) {
|
if (sudAudioInputStream.getChunkIDString(chunkID).equals("wav")) {
|
||||||
|
|
||||||
|
long millis = sudChunk.getChunkHeader().getMillisTime();
|
||||||
|
stClickControl.updateDisplayScrollers(millis);
|
||||||
|
|
||||||
if (sudAudioInputStream.isChunkIDWav(chunkID)) {
|
if (sudAudioInputStream.isChunkIDWav(chunkID)) {
|
||||||
chunkName = "RECORDINGS";
|
// chunkName = "RECORDINGS";
|
||||||
// System.out.printf("Chunk ID %d, size %d, type %s\n", chunkID, chunkSize,
|
// System.out.printf("Chunk ID %d, size %d, type %s\n", chunkID, chunkSize,
|
||||||
// chunkName);
|
// chunkName);
|
||||||
// System.out.println("ID: " + chunkID + " This is raw data from detected
|
// System.out.println("ID: " + chunkID + " This is raw data from detected
|
||||||
@ -201,8 +206,8 @@ public class SudFileDWVHandler implements SUDNotificationHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void makeClick(BCLDetectionChunk bclChunk, Chunk dwvChunk) {
|
private void makeClick(BCLDetectionChunk bclChunk, Chunk dwvChunk) {
|
||||||
long elapsedSamples = (long) ((bclChunk.getJavaMicros() - effortStart) * (sampleRate / 1e6));
|
long elapsedSamples = (long) ((bclChunk.getJavaMicros() - fileStartMicros) * (sampleRate / 1e6));
|
||||||
|
long millis = bclChunk.getJavaMillis();
|
||||||
byte[] rawData = dwvChunk.getBuffer();
|
byte[] rawData = dwvChunk.getBuffer();
|
||||||
int nBytes = rawData.length;
|
int nBytes = rawData.length;
|
||||||
int nSamples = nBytes / Short.BYTES;
|
int nSamples = nBytes / Short.BYTES;
|
||||||
@ -213,8 +218,13 @@ public class SudFileDWVHandler implements SUDNotificationHandler {
|
|||||||
ClickDetection click = new ClickDetection(1, elapsedSamples, nSamples, clickDetector, channelGroupDetector, 1);
|
ClickDetection click = new ClickDetection(1, elapsedSamples, nSamples, clickDetector, channelGroupDetector, 1);
|
||||||
click.setWaveData(wavData);
|
click.setWaveData(wavData);
|
||||||
|
|
||||||
|
// if (groupDetector != null) {
|
||||||
|
// groupDetector.
|
||||||
|
// }
|
||||||
|
if (clickDetector.completeClick(click)) {
|
||||||
clickDetector.getClickDataBlock().addPamData(click);
|
clickDetector.getClickDataBlock().addPamData(click);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void dwvEffort(long javaMillis, boolean isStart) {
|
private void dwvEffort(long javaMillis, boolean isStart) {
|
||||||
System.out.printf("DWV Effort %s at %s\n", isStart ? "Start" : "End", PamCalendar.formatDBDateTime(javaMillis));
|
System.out.printf("DWV Effort %s at %s\n", isStart ? "Start" : "End", PamCalendar.formatDBDateTime(javaMillis));
|
||||||
|
Loading…
Reference in New Issue
Block a user