mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
commit
481315187f
@ -16,5 +16,6 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/X3/src/org"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
@ -45,6 +45,14 @@ public class PamAudioSystem {
|
||||
|
||||
}
|
||||
}
|
||||
else if (file != null && isSudFile(file)) {
|
||||
try {
|
||||
return new SudAudioFileReader().getAudioInputStream(file);
|
||||
}
|
||||
catch (UnsupportedAudioFileException e) {
|
||||
|
||||
}
|
||||
}
|
||||
try {
|
||||
return AudioSystem.getAudioInputStream(file);
|
||||
}
|
||||
@ -77,4 +85,20 @@ public class PamAudioSystem {
|
||||
return (end.equals(".flac"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a file is a .sud file. This is the file format used
|
||||
* by SoundTraps which contains X3 compressed data.
|
||||
* @param file - the file to check.
|
||||
* @return true if a .sud file.
|
||||
*/
|
||||
private static boolean isSudFile(File file) {
|
||||
String name = file.getName();
|
||||
if (name.length() < 5) {
|
||||
return false;
|
||||
}
|
||||
String end = name.substring(name.length()-5).toLowerCase();
|
||||
return (end.equals(".sud"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
23
src/Acquisition/pamAudio/SudAudioFileReader.java
Normal file
23
src/Acquisition/pamAudio/SudAudioFileReader.java
Normal file
@ -0,0 +1,23 @@
|
||||
package Acquisition.pamAudio;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||
|
||||
/**
|
||||
* Audio file reader for a .sud file. .sud files are a file format used by SoundTraps which contain
|
||||
* blocks of X3 compressed data.
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class SudAudioFileReader {
|
||||
|
||||
|
||||
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -79,6 +79,8 @@ public class WavFileInputStream extends AudioInputStream {
|
||||
|
||||
return new WavFileInputStream(wavHeader, inputStream, audioFormat, nFrames);
|
||||
}
|
||||
|
||||
|
||||
static AudioFormat.Encoding getEncoding(int formatCode) {
|
||||
switch (formatCode) {
|
||||
case 1:
|
||||
|
@ -15,6 +15,7 @@ public class PamAudioFileFilter extends PamFileFilter {
|
||||
// addFileType(".AIFF");
|
||||
// addFileType(".FLAC");
|
||||
addFileType(".flac");
|
||||
addFileType(".sud");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ public class CTClassifierParams implements Cloneable, Serializable, ManagedParam
|
||||
|
||||
|
||||
public CTClassifierParams() {
|
||||
// this.uniqueID = UUID.randomUUID().toString(); // see comment below
|
||||
//this.uniqueID = UUID.randomUUID().toString();
|
||||
//System.out.println("Create classifier params: " + uniqueID);
|
||||
}
|
||||
|
||||
|
||||
@ -32,13 +33,10 @@ public class CTClassifierParams implements Cloneable, Serializable, ManagedParam
|
||||
public String classifierName = "";
|
||||
|
||||
|
||||
// /**
|
||||
// * A unique ID for the classifier that never changes. This is important for accessing data selectors.
|
||||
// * GET RID OF THIS, Every time you make a new set of params you get a new ID and it then creates a new
|
||||
// * classifier selector with default settings, so the classifier selectors never work.
|
||||
// Classifier selectors need to be names on something that's not oging to change, so the module name and the classifier species ame.
|
||||
// */
|
||||
// public String uniqueID;
|
||||
/**
|
||||
* A unique ID for the classifier that never changes. This is important for accessing data selectors.
|
||||
*/
|
||||
public String uniqueID = UUID.randomUUID().toString();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ public class BearingClassifierParams extends CTClassifierParams implements Manag
|
||||
public BearingClassifierParams(){
|
||||
super();
|
||||
type = CTClassifierType.BEARINGCLASSIFIER;
|
||||
//System.out.println("Bearing classifier params");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,8 @@ public class IDIClassifierParams extends CTClassifierParams implements Serializa
|
||||
public IDIClassifierParams(){
|
||||
super();
|
||||
type = CTClassifierType.IDICLASSIFIER;
|
||||
//System.out.println("IDI classifier params: " + this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,7 +44,7 @@ public class Chi2ThresholdClassifier implements CTClassifier {
|
||||
public Chi2ThresholdClassifier(ClickTrainControl clickTrainControl, int defaultSpeciesID) {
|
||||
this.clickTrainControl=clickTrainControl;
|
||||
clssfrParams.speciesFlag=defaultSpeciesID;
|
||||
createDataSelector(clickTrainControl.getParentDataBlock());
|
||||
//createDataSelector(clickTrainControl.getParentDataBlock());
|
||||
}
|
||||
|
||||
|
||||
@ -110,12 +110,15 @@ public class Chi2ThresholdClassifier implements CTClassifier {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the data selector.
|
||||
* @param source - the source data block
|
||||
* @return the data selector.
|
||||
*/
|
||||
public void createDataSelector(PamDataBlock<?> source) {
|
||||
//System.out.println("Create data selector " +" " + clssfrParams.classifierName + " " + clssfrParams.speciesFlag + " " + clssfrParams.uniqueID );
|
||||
|
||||
if (dataSelector==null || dataSelector.getPamDataBlock()!=source) {
|
||||
//create the data selector
|
||||
//System.out.println("Data selector: " + dataSelector);
|
||||
@ -123,7 +126,6 @@ public class Chi2ThresholdClassifier implements CTClassifier {
|
||||
|
||||
dataSelector=source.getDataSelectCreator().getDataSelector(clickTrainControl.getUnitName() + "_" + clssfrParams.classifierName
|
||||
+ "_X2_threshold_classifier", false, null);
|
||||
//System.out.println("Data selector: " + dataSelector);
|
||||
}
|
||||
else {
|
||||
dataSelector=null;
|
||||
@ -198,7 +200,6 @@ public class Chi2ThresholdClassifier implements CTClassifier {
|
||||
|
||||
@Override
|
||||
public void setParams(CTClassifierParams ctClassifierParams) {
|
||||
// TODO Auto-generated method stub
|
||||
this.clssfrParams=(Chi2ThresholdParams) ctClassifierParams;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ public class Chi2ThresholdParams extends CTClassifierParams implements ManagedPa
|
||||
public Chi2ThresholdParams(){
|
||||
super();
|
||||
super.type=CTClassifierType.CHI2THRESHOLD;
|
||||
//System.out.println("Chi2thrwesh classifier params: " + this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +74,7 @@ public class StandardClassifier implements CTClassifier {
|
||||
private void createClassifiers() {
|
||||
classifiers = new ArrayList<CTClassifier>();
|
||||
|
||||
|
||||
//System.out.println("------CREATE CLASSIFIERS: -------");
|
||||
//do this so that is CLASSIFIER_TYPES changes order things still work.
|
||||
for (int i=0; i<CLASSIFIER_TYPES.length; i++) {
|
||||
|
||||
@ -104,6 +104,7 @@ public class StandardClassifier implements CTClassifier {
|
||||
*/
|
||||
private void setClassifierParams() {
|
||||
|
||||
|
||||
if (standardClssfrParams.ctClassifierParams ==null || standardClssfrParams.ctClassifierParams.length != classifiers.size()) {
|
||||
standardClssfrParams.ctClassifierParams = new CTClassifierParams[classifiers.size()];
|
||||
standardClssfrParams.enable = new boolean[classifiers.size()];
|
||||
@ -119,6 +120,11 @@ public class StandardClassifier implements CTClassifier {
|
||||
standardClssfrParams.ctClassifierParams[i] = classifiers.get(i).getParams();
|
||||
}
|
||||
else {
|
||||
|
||||
//set the current species ID and name for convenience
|
||||
standardClssfrParams.ctClassifierParams[i].classifierName=standardClssfrParams.classifierName;
|
||||
standardClssfrParams.ctClassifierParams[i].speciesFlag=standardClssfrParams.speciesFlag;
|
||||
|
||||
//the standard classifier should have settings set.
|
||||
classifiers.get(i).setParams(standardClssfrParams.ctClassifierParams[i]);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public class StandardClassifierParams extends CTClassifierParams {
|
||||
///very important to set this or else the clasifier manager does not
|
||||
//know which classifier to create.
|
||||
type = CTClassifierType.STANDARDCLASSIFIER;
|
||||
//System.out.println("Standard classifier params: " + this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,6 +26,7 @@ public class TemplateClassifierParams extends CTClassifierParams implements Mana
|
||||
super.type=CTClassifierType.TEMPLATECLASSIFIER;
|
||||
// chi2ThresholdParams = new Chi2ThresholdParams();
|
||||
// template = DefualtSpectrumTemplates.getTemplate(SpectrumTemplateType.BEAKED_WHALE);
|
||||
//System.out.println("Template classifier params: " + this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,6 +76,8 @@ public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
|
||||
*/
|
||||
private ControlField<Double> minPercClicks;
|
||||
|
||||
private Chi2ThresholdParams currParams;
|
||||
|
||||
public SimpleCTClassifierPane(Chi2ThresholdClassifier simpleChi2Classifier) {
|
||||
super(null);
|
||||
this.simpleChi2Classifier=simpleChi2Classifier;
|
||||
@ -214,6 +216,9 @@ public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
|
||||
public Chi2ThresholdParams getParams(Chi2ThresholdParams currParams) {
|
||||
//System.out.println("Get PERC spinner value; " + minPercClicks.getSpinner().getValue());
|
||||
|
||||
//System.out.println("Chi2 pane get params: " + this.currParams.speciesFlag + " " + this.currParams.uniqueID + " " + this.currParams);
|
||||
|
||||
|
||||
currParams.chi2Threshold=chi2Threshold.getSpinner().getValue();
|
||||
//HACK - for some reason Integer spinner is returning a double
|
||||
currParams.minClicks=minClicks.getSpinner().getValue().intValue();
|
||||
@ -224,17 +229,25 @@ public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
|
||||
simpleChi2Classifier.getDataSelector().getDialogPaneFX().getParams(true);
|
||||
}
|
||||
|
||||
return currParams;
|
||||
currParams.uniqueID = this.currParams.uniqueID;
|
||||
|
||||
return currParams=this.currParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParams(Chi2ThresholdParams input) {
|
||||
|
||||
this.currParams = input;
|
||||
|
||||
//System.out.println("Chi2 pane set params: " + this.currParams.speciesFlag + " " + currParams.uniqueID + " " + currParams);
|
||||
|
||||
chi2Threshold.getSpinner().getValueFactory().setValue(input.chi2Threshold);
|
||||
//HACK - for some reason Integer spinner is returning a double
|
||||
minClicks.getSpinner().getValueFactory().setValue((double) input.minClicks);
|
||||
minTime.getSpinner().getValueFactory().setValue(input.minTime);
|
||||
minPercClicks.getSpinner().getValueFactory().setValue(input.minPercentage*100.);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,7 +64,6 @@ public class StandardClassifierGraphics implements CTClassifierGraphics {
|
||||
@Override
|
||||
public void setParams(CTClassifierParams params) {
|
||||
standardClassifierPane.setParams((StandardClassifierParams) params);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,7 +84,15 @@ public class StandardClassifierPane extends SettingsPane<StandardClassifierPara
|
||||
@Override
|
||||
public void setParams(StandardClassifierParams input) {
|
||||
for (int i=0; i<standardClassifier.getClassifiers().size(); i++) {
|
||||
|
||||
standardClassifier.getClassifiers().get(i).setParams(input.ctClassifierParams[i]);
|
||||
/**
|
||||
* It is important to set this here because otherwise the params can be out of sync with the classifer class. Usually this
|
||||
* is not an issue because they are set later, however, if there is a paramter that does not have a correpsonding UI control, then
|
||||
* this may change back to default - thus we have to explicitlly set here. (Note this caused issues with the uniqueID data selector string)
|
||||
*/
|
||||
standardClassifier.getClassifiers().get(i).getCTClassifierGraphics().setParams(input.ctClassifierParams[i]);
|
||||
|
||||
enableSwitch[i].setSelected(input.enable[i]);
|
||||
disableClassifierPane(i);
|
||||
}
|
||||
|
@ -65,8 +65,6 @@ public class AmplitudeChi2AdvPane extends AdvMHTVarPane {
|
||||
@Override
|
||||
public AmplitudeChi2Params getParams(SimpleChi2VarParams currParams) {
|
||||
|
||||
System.out.println("Get params: AMPLITUDE");
|
||||
|
||||
AmplitudeChi2Params newParams = new AmplitudeChi2Params(super.getParams(currParams));
|
||||
|
||||
newParams.maxAmpJump = ampJumpSpinner.getValue();
|
||||
|
Binary file not shown.
@ -27,8 +27,8 @@ public class DLLocalisation extends AbstractLocalisation {
|
||||
this.angles = bearingAnnotation.getBearingLocalisation().getAngles();
|
||||
this.setSubArrayType(bearingAnnotation.getBearingLocalisation().getSubArrayType());
|
||||
|
||||
System.out.println("Loc content!: " + this.getLocContents().hasLocContent(LocContents.HAS_AMBIGUITY) + " angles: " + angles.length);
|
||||
PamUtils.PamArrayUtils.printArray(angles);
|
||||
//System.out.println("Loc content!: " + this.getLocContents().hasLocContent(LocContents.HAS_AMBIGUITY) + " angles: " + angles.length);
|
||||
//PamUtils.PamArrayUtils.printArray(angles);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +58,7 @@ public abstract class DLTaskThread extends Thread {
|
||||
for (int i =0; i<modelResult.size(); i++) {
|
||||
// modelResult.get(i).setClassNameID(getClassNameIDs());
|
||||
// modelResult.get(i).setBinaryClassification(isBinaryResult(modelResult.get(i)));
|
||||
newResult(modelResult.get(i), groupedRawData.get(i));
|
||||
newDLResult(modelResult.get(i), groupedRawData.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
@ -79,7 +79,7 @@ public abstract class DLTaskThread extends Thread {
|
||||
* @param soundSpotResult - the new result.
|
||||
* @param groupedRawData - the grouped data unit.
|
||||
*/
|
||||
public abstract void newResult(GenericPrediction soundSpotResult, GroupedRawData groupedRawData);
|
||||
public abstract void newDLResult(GenericPrediction soundSpotResult, GroupedRawData groupedRawData);
|
||||
|
||||
/**
|
||||
* Get the grouped data queue
|
||||
|
@ -161,7 +161,7 @@ public class SoundSpotClassifier implements DLClassiferModel, PamSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newResult(GenericPrediction soundSpotResult, GroupedRawData groupedRawData) {
|
||||
public void newDLResult(GenericPrediction soundSpotResult, GroupedRawData groupedRawData) {
|
||||
soundSpotResult.setClassNameID(getClassNameIDs());
|
||||
soundSpotResult.setBinaryClassification(isBinaryResult(soundSpotResult));
|
||||
newResult(soundSpotResult, groupedRawData);
|
||||
@ -241,11 +241,12 @@ public class SoundSpotClassifier implements DLClassiferModel, PamSettings {
|
||||
* @param modelResult - the model result;
|
||||
* @param groupedRawData - the grouped raw data.
|
||||
*/
|
||||
private void newResult(GenericPrediction modelResult, GroupedRawData groupedRawData) {
|
||||
protected void newResult(GenericPrediction modelResult, GroupedRawData groupedRawData) {
|
||||
this.dlControl.getDLClassifyProcess().newModelResult(modelResult, groupedRawData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void prepModel() {
|
||||
//System.out.println("PrepModel! !!!");
|
||||
|
@ -323,7 +323,7 @@ public class GenericDLClassifier implements DLClassiferModel, PamSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newResult(GenericPrediction modelResult, GroupedRawData groupedRawData) {
|
||||
public void newDLResult(GenericPrediction modelResult, GroupedRawData groupedRawData) {
|
||||
modelResult.setClassNameID(getClassNameIDs(genericModelParams));
|
||||
modelResult.setBinaryClassification(isBinaryResult(modelResult, genericModelParams));
|
||||
newResult(modelResult, groupedRawData);
|
||||
@ -331,6 +331,15 @@ public class GenericDLClassifier implements DLClassiferModel, PamSettings {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a new result form the thread queue to the process.
|
||||
* @param modelResult - the model result;
|
||||
* @param groupedRawData - the grouped raw data.
|
||||
*/
|
||||
protected void newResult(GenericPrediction modelResult, GroupedRawData groupedRawData) {
|
||||
this.dlControl.getDLClassifyProcess().newModelResult(modelResult, groupedRawData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class name IDs
|
||||
* @return an array of class name IDs
|
||||
|
@ -169,7 +169,7 @@ public class KetosClassifier implements DLClassiferModel, PamSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newResult(GenericPrediction soundSpotResult, GroupedRawData groupedRawData) {
|
||||
public void newDLResult(GenericPrediction soundSpotResult, GroupedRawData groupedRawData) {
|
||||
soundSpotResult.setClassNameID(GenericDLClassifier.getClassNameIDs(ketosDLParams));
|
||||
soundSpotResult.setBinaryClassification(GenericDLClassifier.isBinaryResult(soundSpotResult, ketosDLParams));
|
||||
newResult(soundSpotResult, groupedRawData);
|
||||
@ -177,6 +177,15 @@ public class KetosClassifier implements DLClassiferModel, PamSettings {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a new result form the thread queue to the process.
|
||||
* @param modelResult - the model result;
|
||||
* @param groupedRawData - the grouped raw data.
|
||||
*/
|
||||
protected void newResult(GenericPrediction modelResult, GroupedRawData groupedRawData) {
|
||||
this.dlControl.getDLClassifyProcess().newModelResult(modelResult, groupedRawData);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void closeModel() {
|
||||
|
Loading…
Reference in New Issue
Block a user