diff --git a/src/Acquisition/AcquisitionControl.java b/src/Acquisition/AcquisitionControl.java index 3d198980..e1f1025c 100644 --- a/src/Acquisition/AcquisitionControl.java +++ b/src/Acquisition/AcquisitionControl.java @@ -54,6 +54,7 @@ import asiojni.NewAsioSoundSystem; import nidaqdev.NIDAQProcess; import Acquisition.filedate.FileDate; import Acquisition.filedate.StandardFileDate; +import Acquisition.filetypes.SoundFileTypes; import Acquisition.layoutFX.AquisitionGUIFX; import Acquisition.offlineFuncs.OfflineWavFileServer; import Acquisition.rona.RonaOfflineFileServer; @@ -138,6 +139,8 @@ public class AcquisitionControl extends PamControlledUnit implements PamSettings private SUDNotificationManager sudNotificationManager; + protected SoundFileTypes soundFileTypes; + /** * Main control unit for audio data acquisition. *

@@ -162,6 +165,8 @@ public class AcquisitionControl extends PamControlledUnit implements PamSettings pamController = PamController.getInstance(); + soundFileTypes = new SoundFileTypes(this); + registerDaqSystem(new SoundCardSystem(this)); if (PlatformInfo.calculateOS() == OSType.WINDOWS) { registerDaqSystem(new ASIOSoundSystem(this)); diff --git a/src/Acquisition/FileInputSystem.java b/src/Acquisition/FileInputSystem.java index 9ec48538..1e976623 100644 --- a/src/Acquisition/FileInputSystem.java +++ b/src/Acquisition/FileInputSystem.java @@ -16,6 +16,8 @@ import java.io.IOException; import java.io.Serializable; import java.text.DateFormat; import java.util.Calendar; +import java.util.List; + import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.UnsupportedAudioFileException; @@ -53,6 +55,7 @@ import wavFiles.ByteConverter; import Acquisition.filedate.FileDate; import Acquisition.filedate.FileDateDialogStrip; import Acquisition.filedate.FileDateObserver; +import Acquisition.filetypes.SoundFileType; import Acquisition.pamAudio.PamAudioFileManager; import Acquisition.pamAudio.PamAudioFileFilter; import PamController.PamControlledUnitSettings; @@ -144,6 +147,11 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe protected ByteConverter byteConverter; protected FileDateDialogStrip fileDateStrip; + + /** + * Sound file types present in the current selections. + */ + private List selectedFileTypes; /** * Text field for skipping initial few seconds of a file. @@ -400,6 +408,9 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe if (newFile.length() == 0) return; File file = new File(newFile); + + setSelectedFileTypes(acquisitionControl.soundFileTypes.getUsedTypes(file)); + if (file == null) return; // try to work out the date of the file @@ -1222,4 +1233,27 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe getDialogPanel(); } } + + /** + * @return the selectedFileTypes + */ + public List getSelectedFileTypes() { + return selectedFileTypes; + } + + /** + * Called when the file or file list selection is changes and finds a list of all + * sound file types included in the selection. this is only implemented for SUD files + * at the moment, the idea being to offer some additional functionality. + * @param selectedFileTypes the selectedFileTypes to set + */ + public void setSelectedFileTypes(List selectedFileTypes) { + this.selectedFileTypes = selectedFileTypes; + if (selectedFileTypes == null) { + return; + } + for (SoundFileType aType : selectedFileTypes) { + aType.selected(this); + } + } } \ No newline at end of file diff --git a/src/Acquisition/FolderInputSystem.java b/src/Acquisition/FolderInputSystem.java index 86fab5ad..589b6c45 100644 --- a/src/Acquisition/FolderInputSystem.java +++ b/src/Acquisition/FolderInputSystem.java @@ -10,6 +10,8 @@ import java.awt.event.ActionListener; import java.io.File; import java.io.Serializable; import java.util.ArrayList; +import java.util.List; + import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.swing.BoxLayout; @@ -494,6 +496,9 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings{ // System.out.printf("Wav list recieved with %d files after %d millis\n", // fileListData.getFileCount(), System.currentTimeMillis() - wavListStart); allFiles = fileListData.getListCopy(); + + List asList = allFiles; + setSelectedFileTypes(acquisitionControl.soundFileTypes.getUsedTypes(allFiles)); setFileDateText(); // also open up the first file and get the sample rate and number of channels from it diff --git a/src/Acquisition/filetypes/SUDFileType.java b/src/Acquisition/filetypes/SUDFileType.java new file mode 100644 index 00000000..80fd0a36 --- /dev/null +++ b/src/Acquisition/filetypes/SUDFileType.java @@ -0,0 +1,29 @@ +package Acquisition.filetypes; + +import Acquisition.FileInputSystem; +import PamView.dialog.warn.WarnOnce; + +public class SUDFileType extends SoundFileType { + + private boolean isShown = false; + + private String sudInfoText = "There are SoundTrap SUD files in your selection. PAMGuard can now process data from these " + + "directly with no need to unpack them into WAV files. " + + "

If the SoundTrap was running with the click detector, then you should add a SoundTrap Click Detector module" + + " and detected clicks will automatically be extracted to binary files while processing the wav data." + + "

See the Click Detector help for further details"; + + public SUDFileType() { + super(".sud"); + } + + @Override + public void selected(FileInputSystem fileInputSystem) { + if (isShown) { + return; + } + WarnOnce.showWarning("SoundTrap SUD Files", sudInfoText, WarnOnce.OK_OPTION); + isShown = true; + } + +} diff --git a/src/Acquisition/filetypes/SoundFileType.java b/src/Acquisition/filetypes/SoundFileType.java new file mode 100644 index 00000000..3ed778d3 --- /dev/null +++ b/src/Acquisition/filetypes/SoundFileType.java @@ -0,0 +1,65 @@ +package Acquisition.filetypes; + +import java.io.File; +import java.util.List; + +import Acquisition.FileInputSystem; +import Acquisition.pamAudio.PamAudioFileFilter; +import PamUtils.worker.filelist.WavFileType; + +/** + * Some functions for the File and Folder input systems to give a bit of + * extra functionality / help for different file types. Primarily introduced + * to give a couple of extras for sud files. + * @author dg50 + * + */ +public abstract class SoundFileType { + + private String fileType; + + private PamAudioFileFilter fileFilter = new PamAudioFileFilter(); + + public SoundFileType(String fileType) { + this.fileType = fileType.toLowerCase(); + } + + /** + * Work out if any files of this type are included in the current selection. + * @param fileOrFolder this for a single file. + * @param includeSubfolders used with folders. + * @return true if any exist. + */ + public boolean isFileType(File oneFile) { + if (oneFile == null) { + return false; + } + if (oneFile.isFile()) { + return oneFile.getName().toLowerCase().endsWith(fileType); + } + + return false; + } + + /** + * Work out if any files of this type are included in the current selection. + * @param fileOrFolder this for a single file. + * @param includeSubfolders used with folders. + * @return true if any exist. + */ + public boolean hasFileType(List files) { + if (files == null) { + return false; + } + for (File aFile : files) { + if (isFileType(aFile)) { + return true; + } + } + + return false; + } + + public abstract void selected(FileInputSystem fileInputSystem); + +} diff --git a/src/Acquisition/filetypes/SoundFileTypes.java b/src/Acquisition/filetypes/SoundFileTypes.java new file mode 100644 index 00000000..fb0ba38d --- /dev/null +++ b/src/Acquisition/filetypes/SoundFileTypes.java @@ -0,0 +1,74 @@ +package Acquisition.filetypes; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import Acquisition.AcquisitionControl; +import PamUtils.worker.filelist.WavFileType; + +/** + * List of SoundFileType objects. + * @author dg50 + * + */ +public class SoundFileTypes { + + private AcquisitionControl acquisitionControl; + + private ArrayList availableTypes = new ArrayList<>(); + + public SoundFileTypes(AcquisitionControl acquisitionControl) { + this.acquisitionControl = acquisitionControl; + availableTypes.add(new SUDFileType()); + } + + /** + * Get a list of used file types. Reaslistically this + * can only return one value. + * @param aFile + * @return + */ + public SoundFileType getFileType(File aFile) { + ArrayList usedTypes = new ArrayList<>(); + for (SoundFileType aType : availableTypes) { + if (aType.isFileType(aFile)) { + return aType; + } + } + return null; + } + + /** + * Get a list of used file types. Reaslistically this + * can only return one value but possibly it's useful to have it in the same + * format as the multiple file version. . + * @param aFile + * @return + */ + public List getUsedTypes(File aFile) { + ArrayList usedTypes = new ArrayList<>(); + for (SoundFileType aType : availableTypes) { + if (aType.isFileType(aFile)) { + usedTypes.add(aType); + } + } + return usedTypes; + } + + /** + * Get a list of used file types for the folder Input System. + * @param aFile + * @return + */ + public List getUsedTypes(List aFile) { + ArrayList usedTypes = new ArrayList<>(); + for (SoundFileType aType : availableTypes) { + if (aType.hasFileType(aFile)) { + usedTypes.add(aType); + } + } + return usedTypes; + } + +} diff --git a/src/PamUtils/PamAudioFileFilter.java b/src/PamUtils/PamAudioFileFilter.java index b903cbf7..e1f20a95 100644 --- a/src/PamUtils/PamAudioFileFilter.java +++ b/src/PamUtils/PamAudioFileFilter.java @@ -17,7 +17,7 @@ public class PamAudioFileFilter extends PamFileFilter { // addFileType(".AIFF"); // addFileType(".FLAC"); addFileType(".flac"); -// addFileType(".sud"); + addFileType(".sud"); } } diff --git a/src/help/JavaHelpSearch/DOCS b/src/help/JavaHelpSearch/DOCS index dafb825b..0e34e06a 100644 Binary files a/src/help/JavaHelpSearch/DOCS and b/src/help/JavaHelpSearch/DOCS differ diff --git a/src/help/JavaHelpSearch/DOCS.TAB b/src/help/JavaHelpSearch/DOCS.TAB index ab7338e9..4e244554 100644 Binary files a/src/help/JavaHelpSearch/DOCS.TAB and b/src/help/JavaHelpSearch/DOCS.TAB differ diff --git a/src/help/JavaHelpSearch/OFFSETS b/src/help/JavaHelpSearch/OFFSETS index 590bf103..0a5b754c 100644 Binary files a/src/help/JavaHelpSearch/OFFSETS and b/src/help/JavaHelpSearch/OFFSETS differ diff --git a/src/help/JavaHelpSearch/POSITIONS b/src/help/JavaHelpSearch/POSITIONS index 78d2bf77..cd366c8e 100644 Binary files a/src/help/JavaHelpSearch/POSITIONS and b/src/help/JavaHelpSearch/POSITIONS differ diff --git a/src/help/JavaHelpSearch/SCHEMA b/src/help/JavaHelpSearch/SCHEMA index 8e45e04b..cdefcb6c 100644 --- a/src/help/JavaHelpSearch/SCHEMA +++ b/src/help/JavaHelpSearch/SCHEMA @@ -1,2 +1,2 @@ JavaSearch 1.0 -TMAP bs=2048 rt=1 fl=-1 id1=6679 id2=1 +TMAP bs=2048 rt=1 fl=-1 id1=6697 id2=1 diff --git a/src/help/JavaHelpSearch/TMAP b/src/help/JavaHelpSearch/TMAP index 27fc928a..6212dc30 100644 Binary files a/src/help/JavaHelpSearch/TMAP and b/src/help/JavaHelpSearch/TMAP differ diff --git a/src/help/Map.jhm b/src/help/Map.jhm index df768f7c..176022cb 100644 --- a/src/help/Map.jhm +++ b/src/help/Map.jhm @@ -574,6 +574,8 @@ + + @@ -802,6 +804,8 @@ + + diff --git a/src/help/PAMGUARD.hs b/src/help/PAMGUARD.hs index 7ee7a780..f4b3288d 100644 --- a/src/help/PAMGUARD.hs +++ b/src/help/PAMGUARD.hs @@ -1,7 +1,12 @@ - + + + + + + @@ -20,7 +25,12 @@ Help - + + + + + + @@ -39,7 +49,12 @@ - + + + + + + @@ -60,7 +75,12 @@ top - + + + + + + @@ -79,7 +99,12 @@ top - + + + + + + @@ -98,7 +123,12 @@ top - + + + + + + @@ -117,7 +147,12 @@ top - + + + + + + @@ -138,7 +173,12 @@ top TOC - + + + + + + @@ -159,7 +199,12 @@ TOC - + + + + + + @@ -180,7 +225,12 @@ TOC javax.help.TOCView - + + + + + + @@ -201,7 +251,12 @@ javax.help.TOCView PAMGUARDTOC.xml - + + + + + + @@ -220,7 +275,12 @@ PAMGUARDTOC.xml - + + + + + + @@ -239,7 +299,12 @@ PAMGUARDTOC.xml - + + + + + + @@ -260,7 +325,12 @@ PAMGUARDTOC.xml Index - + + + + + + @@ -281,7 +351,12 @@ Index - + + + + + + @@ -302,7 +377,12 @@ Index javax.help.IndexView - + + + + + + @@ -323,7 +403,12 @@ javax.help.IndexView PAMGUARDIndex.xml - + + + + + + @@ -342,7 +427,12 @@ PAMGUARDIndex.xml - + + + + + + @@ -361,7 +451,12 @@ PAMGUARDIndex.xml - + + + + + + @@ -382,7 +477,12 @@ PAMGUARDIndex.xml Search - + + + + + + @@ -403,7 +503,12 @@ Search - + + + + + + @@ -424,7 +529,12 @@ Search javax.help.SearchView - + + + + + + @@ -445,7 +555,12 @@ javax.help.SearchView JavaHelpSearch - + + + + + + @@ -464,7 +579,12 @@ JavaHelpSearch - + + + + + + diff --git a/src/help/PAMGUARDIndex.xml b/src/help/PAMGUARDIndex.xml index 733f36c4..cc52fb7b 100644 --- a/src/help/PAMGUARDIndex.xml +++ b/src/help/PAMGUARDIndex.xml @@ -2,6 +2,8 @@ + + diff --git a/src/help/PAMGUARDTOC.xml b/src/help/PAMGUARDTOC.xml index 7c27efa8..73590bca 100644 --- a/src/help/PAMGUARDTOC.xml +++ b/src/help/PAMGUARDTOC.xml @@ -278,8 +278,10 @@ - + + + @@ -426,6 +428,8 @@ + + diff --git a/src/help/detectors/clickDetectorHelp/docs/SoundTrapClickDetector.html b/src/help/detectors/clickDetectorHelp/docs/SoundTrapClickDetector.html new file mode 100644 index 00000000..dd4f329c --- /dev/null +++ b/src/help/detectors/clickDetectorHelp/docs/SoundTrapClickDetector.html @@ -0,0 +1,80 @@ + + +Click Classification +

+SoundTrap Click Detector +

SoundTrap Click Detector

+
+ +

Overview

+

If you are using a SountTrap recording device with built in click detection from +Ocean Instruments, +you may need to use a modified version of the Click Detector. +

+

The SoundTrap click detector allows you to detect and store clicks at high frequencies (say 384kHz), suitable for odontocete echolocation clicks, and +at the same time, record audio data files at a lower frequency (e.g. 96 or 48kHz). This optimises disk space usage and makes long deployments +of several months possible with moderate data storage.

+

Having two sample rates present within a single PAMGuard configuration is possible, using +Decimator modules, however such configurations become particularly +complicated to configure when the sample rate of the recorded files is lower than the sample rate of the click detector.

+

We therefore recommend that you use a modified version of the Click Detectorwhich manages it's own sample rate and +channel information based on information extracted from the SoundTrap data.

+

Note that the SoundTrap click detector should only be used for clicks automatically detected by the SoundTrap. If you want to detect clicks from the +SoundTrap recordings, then use a normal Click Detector in the normal way.

+ + +

Creating an instance of the SoundTrap Click Detector

+ +

+ From the File>Add modules>Detectors menu, or + from the pop-up menu on the data model display, select 'SoundTrap Click + Detector' near the bottom of the list. Enter a descriptive name for the new detector and press Ok. +

+ +

Importing SoundTrap Data

+

SoundTrap data are stored in proprietary files called SUD files.

+

There are two ways in which you can get data from SUD files into + the SoundTrap Click Detector.

+ +

The Old Way

+

The 'standard' way of using SoundTrap data was to inflate all of the data from the compressed SUD files. For details of this process, see the + SoundTrap user manuals and the SoundTrap Host software.

+

Normally, several inflated files are generated from each sud file:

+
    +
  1. A wav file: Audio data in standard wav file format
  2. +
  3. An XML file: Metadata on the SoundTrap configuration, file start times in various formats, etc.
  4. +
  5. If the click detector was running BCL and DWV files, which contain the times of clicks and click waveforms respectively.
  6. +
+

To convert the SUD files to the binary storage format used by PAMGuard, working in the + PAMGuard Viewer, create a Binary Store, a + SoundTrap Click Detector and also create a 'SoundTrap Detector Import' module. Then use the import module to import the BCL and DWV + data into PAMGuard. Once imported you can run Click Classifiers + and use other Click Detector offline functions to mark events, etc.

+

If you want to run additional analysis on the WAV file data (for example to make noise measurements or to detect whistles), + create a different PAMGuard configuration to process those data.

+ +

The (better) New Way

+

Current versions of PAMGuard can read SUD files directly, without first unpacking them into WAV, XML, BCL and DWV files. This not + only reduces the amount of disk space you need by about x4, but also saves a lot of time.

+

Better still, you can now set up PAMGuard in normal mode to simultaneously process the audio data in the sud file with one set of + detectors, and simultaneously extract the click detector data into appropriate files for a SoundTrap Click Detector.

+ +

Start PAMGuard in Normal Mode and add a + Sound Acquisition module. + Add a SoundTrap Click Detector, a Binary Store store and a + Database + module (optional). In the Sound Acquisition dialog + select a single SUD file or a folder of SUD files. At this point, the SoundTrap + Click Detector will be automatically configured with the correct sample rate (which won't be the sample rate displayed in the Sound Acquisition + module).

+

Configure any Click Classifiers you want to be run on the SoundTrap click data as it is imported.

+

You can then add any other detectors and measurement processes you want to run on the SoundTrap audio data, this may include + instances of the normal Click Detector module if you want to detect clicks in the lower frequency audio data.

+

Process the data in the normal way and clicks will automatically be generated within the SoundTrap click detector

+

Further process you data using the PAMGuard Viewer in the normal way.

+ + +
+
+
+ \ No newline at end of file diff --git a/src/help/sound_processing/AcquisitionHelp/docs/AcquisitionFile.html b/src/help/sound_processing/AcquisitionHelp/docs/AcquisitionFile.html index caabb5f8..bf07f25e 100644 --- a/src/help/sound_processing/AcquisitionHelp/docs/AcquisitionFile.html +++ b/src/help/sound_processing/AcquisitionHelp/docs/AcquisitionFile.html @@ -7,7 +7,9 @@

Audio Files

As well as analysing data from sound cards in real time, PAMGUARD can be used to analyse archived data -from audio filed in WAV or AIF format.

+from audio filed in WAV, + AIF, FLAC, + or SUD file format.


Setting up an Audio File

diff --git a/src/help/sound_processing/AcquisitionHelp/docs/sudfiles.html b/src/help/sound_processing/AcquisitionHelp/docs/sudfiles.html new file mode 100644 index 00000000..770bdb1b --- /dev/null +++ b/src/help/sound_processing/AcquisitionHelp/docs/sudfiles.html @@ -0,0 +1,27 @@ + + + +SUD Files + + +

SoundTrap data files

+

SUD Files

+

+SoundTrap recorders from +Ocean Instruments + store data in proprietary files called SUD files. See SoundTrap documentation for information on how to + extract SUD files from SoundTrap recorders.

+ +

Earlier versions of PAMGuard required you to 'inflate' the SUD files into standard wav audio files using + the SoundTrap Host software before they could be processed.

+

The current version of PAMGuard no longer requires this since it can read data directly from the SUD files.

+

Inflating SUD files to WAV files generally required between 3 and 5 times as much disk space and could also take + a fair amount of time, so not inflating will save both!

+ +

SoundTrap Click Detector

+

If you are using the SoundTrap build in click detector (see SoundTrap manuals) then the SUD files will also contain + detected clicks.

See the help page for the SoundTrap Click Detector + for information on how to get these clicks from the SUD files into PAMGuard.

+


+ + \ No newline at end of file diff --git a/src/soundtrap/sud/SudFileDWVHandler.java b/src/soundtrap/sud/SudFileDWVHandler.java index 6129c381..a9f780e2 100644 --- a/src/soundtrap/sud/SudFileDWVHandler.java +++ b/src/soundtrap/sud/SudFileDWVHandler.java @@ -216,6 +216,7 @@ public class SudFileDWVHandler implements SUDNotificationHandler { // channelGroupDetector = clickDetector.getChannelGroupDetector(0); ClickDetection click = new ClickDetection(1, elapsedSamples, nSamples, clickDetector, channelGroupDetector, 1); + click.setTimeMilliseconds(millis); click.setWaveData(wavData); // if (groupDetector != null) {