From 9f998165ee95dbb16acaf420876f3aeab75c2158 Mon Sep 17 00:00:00 2001
From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com>
Date: Mon, 2 May 2022 19:40:24 +0100
Subject: [PATCH] Updates to support ContactCollator plugin (#33)
* Change synchronization on RawDataTransforms soit uses the owner data
holder, not itself for synchronization. Otherwise you get thread locks.
* fix problem in SummaryComand
* Update command line options
* Change synchronization on RawDataTransforms soit uses the owner data
holder, not itself for synchronization. Otherwise you get thread locks.
* Update command line options
* Update DecimatorParams.java
* couple of updates to support new contact collator plugin
* Sorting out sample rate info in clip display to support Contact Collator
plugin
* FLAC Speed
Improve flac speed
* Update .gitignore
* Update .gitignore
* Updates to support new features in Contact Collator
* Small update to RawDatautils to handle null data
---
.classpath | 2 +-
.gitignore | 2 ++
.settings/org.eclipse.jdt.core.prefs | 6 +++---
src/PamUtils/PamUtils.java | 2 +-
src/PamguardMVC/RawDataUtils.java | 29 +++++++++++++++++++++++-----
5 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/.classpath b/.classpath
index 507f6d76..188c7291 100644
--- a/.classpath
+++ b/.classpath
@@ -6,7 +6,7 @@
-
+
diff --git a/.gitignore b/.gitignore
index 28c40451..e875dc34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,5 @@ target/WMM.COF
settings.xml
.classpath
+.classpath
+.classpath
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 41b74bc8..e8c450c0 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=16
-org.eclipse.jdt.core.compiler.compliance=16
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
-org.eclipse.jdt.core.compiler.source=16
+org.eclipse.jdt.core.compiler.source=11
diff --git a/src/PamUtils/PamUtils.java b/src/PamUtils/PamUtils.java
index 2886e527..85ce33ba 100644
--- a/src/PamUtils/PamUtils.java
+++ b/src/PamUtils/PamUtils.java
@@ -397,7 +397,7 @@ public class PamUtils {
/**
* Force an angle to sit within some range.
* @param angle input angle (radians)
- * @param maxAngle maximum angle in degrees
+ * @param maxAngle maximum angle in radians
* @return output angle (radians)
*/
static public double constrainedAngleR(double angle, double maxAngle) {
diff --git a/src/PamguardMVC/RawDataUtils.java b/src/PamguardMVC/RawDataUtils.java
index b11d55cb..3bdf954d 100644
--- a/src/PamguardMVC/RawDataUtils.java
+++ b/src/PamguardMVC/RawDataUtils.java
@@ -19,14 +19,23 @@ import java.io.IOException;
public class RawDataUtils {
/**
- * Write the wave clip in scaled int8 format into a data output stream.
+ * Write the wave clip in scaled int8 format into a data output stream. If rawData is null
+ * or empty, it will still write the header consisting of nChan, nSamp and a scale, but no
+ * data.
* @param dos Data output stream
* @param rawData raw data
* @throws IOException
*/
public void writeWaveClipInt8(DataOutputStream dos, double[][] rawData) throws IOException {
- int nChan = rawData.length;
- int nSamps = rawData[0].length;
+ int nChan, nSamps;
+ if (rawData == null || rawData.length == 0 || rawData[0] == null) {
+ nChan = 0;
+ nSamps = 0;
+ }
+ else {
+ nChan = rawData.length;
+ nSamps = rawData[0].length;
+ }
double minVal = 0, maxVal = 0;
for (int iC = 0; iC < nChan; iC++) {
double[] chanData = rawData[iC];
@@ -36,7 +45,13 @@ public class RawDataUtils {
}
}
maxVal = Math.max(maxVal, -minVal);
- float scale = (float) (127./maxVal);
+ float scale;
+ if (maxVal == 0) {
+ scale = 1.f;
+ }
+ else {
+ scale = (float) (127./maxVal);
+ }
dos.writeShort(nChan);
dos.writeInt(nSamps);
dos.writeFloat(scale);
@@ -51,13 +66,17 @@ public class RawDataUtils {
/**
* Read a waveform clip in scaled int8 format from a data input stream
* @param dis data input stream
- * @return waveform double array
+ * @return waveform double array or null if nChan or nSamps was zero (implying an empty array
+ * was written in the fist place)
* @throws IOException
*/
public double[][] readWavClipInt8(DataInputStream dis) throws IOException {
int nChan = dis.readShort();
int nSamps = dis.readInt();
double scale = 1./dis.readFloat();
+ if (nChan == 0 || nSamps == 0) {
+ return null;
+ }
double[][] rawData = new double[nChan][nSamps];
for (int iC = 0; iC < nChan; iC++) {
double[] chanData = rawData[iC];