Class FileInputSystem
- All Implemented Interfaces:
 FileDateObserver,ActionListener,EventListener,DataInputStore,DataStoreInfoHolder,PamSettings,SettingsNameProvider
- Direct Known Subclasses:
 FolderInputSystem
- Author:
 - Doug Gillespie
 - See Also:
 
- 
Nested Class Summary
Nested Classes - 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AcquisitionControlprotected AcquisitionDialogprotected AudioFormatprotected AudioInputStreamprotected intprotected ByteConverterprotected FileInputSystem.CollectorThreadprotected longCurrent analysis time - start of last data unit created.protected booleanprotected PamLabelprotected FileDateDialogStripprotected FileInputParametersprotected JComboBoxprotected PamProgressBarprotected JButtonprotected longusing a system.currentTimeMS not PamCalander time to predict eta.protected AudioDataQueueprotected JCheckBoxprotected PamLabelstatic final Stringprotected ThreadFields inherited from class Acquisition.DaqSystem
PARAMETER_FIXED, PARAMETER_UNKNOWN, STREAM_CLOSED, STREAM_ENDED, STREAM_OPEN, STREAM_PAUSED, STREAM_RUNNING - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidstatic double[]bytesToSamples(byte[] byteArray, long nBytes, int channel, AudioFormat audioFormat) Format one channel of the data in a byte array into a sample array.booleancanPlayBack(float sampleRate) protected voidFLAC uses such a different way of decoding data to wav and aif that it needs to use it's own reader.protected JPanelvoidCalled after DAQ has stopped - for whatever reason.booleanCalled by AcquisitionDialog.GetParams so that parameters can be extracted from the dialog component.voidCalled by AcquisitionDialog.SetParams so that the dialog componenet can update it's fieldsvoidfileDateChange(FileDate fileDate) protected voidCalled when all files to be processed have been processed.Get the acquisition control for the input systemVery specific command handler for batch status which will only work with the acquisition folderinputSystem or the tritech file processing.intgetDaqSpecificDialogComponent(AcquisitionDialog acquisitionDialog) The AcquisitionDialog has been designed to that each data source type can plug in it's own panel of device specific controls.intGets a name for the acquisition device (may just be a number but need to generalise).protected JPanelGets and where necessary creates ...longgetEta()longgetFileStartTime(File file) Interpret the file name to get the file time.intintdoublegetPeak2PeakVoltage(int swChannel) static doublegetSample(byte[] buffer, int position, int bytesPerSample, boolean isBigEndian) Convenience method for getting samples from a byte array.intGet the number of bits in each sample.floatlonglonggetStoreInfo(PamWorkMonitor workMonitor, boolean detail) Get information about the input store (e.g.voidinterpretNewFile(WavFileType newFile) Called when a new file or folder is selected.booleanprotected booleanloadByteConverter(AudioFormat audioFormat) protected booleanopenNextFile(long totalSamples) Open next file in a list for continuous processing, not the function that opens a file for normal processing.booleanOpen the audio stream for processing.booleanprepareSystem(AcquisitionControl daqControl) Prepare the DaqSystem.booleanrestoreSettings(PamControlledUnitSettings pamControlledUnitSettings) booleanvoidsayEta()voidsayEta(long timeMs) protected voidbooleansetAnalysisStartTime(long startTime) Set an analysis start time.voidsetNewFile(String newFile) Called when user selects a file in the dialog.voidsetSelected(boolean select) Tell a DAQ system it's been selected or deselected.voidsetSelectedFileTypes(List<SoundFileType> selectedFileTypes) Called when the file or file list selection is changes and finds a list of all sound file types included in the selection.voidsetStreamStatus(int streamStatus) booleanstartSystem(AcquisitionControl daqControl) Start the DaqSystem.voidstopSystem(AcquisitionControl daqControl) Stop the DaqSystem.voidsystemHasStopped(boolean wasRunning) Methods inherited from class Acquisition.DaqSystem
areSampleSettingsOk, getChannelGain, getDaqSpecificChannelListNode, getDaqSpecificChannelListPanel, getDAQSpecificPane, getInputChannelMap, getPlaybackSystem, getStallCheckSeconds, getStartButtonToolTip, getStreamStatus, notifyModelChanged, showSampleSettingsDialog, startButtonXtraActions, supportsChannelLists 
- 
Field Details
- 
sysType
- See Also:
 
 - 
fileNameCombo
 - 
fileSelect
 - 
acquisitionDialog
 - 
fileInputParameters
 - 
acquisitionControl
 - 
blockSamples
protected int blockSamples - 
fileProgress
 - 
etaLabel
 - 
speedLabel
 - 
fileStartTime
protected long fileStartTimeusing a system.currentTimeMS not PamCalander time to predict eta. - 
dontStop
protected volatile boolean dontStop - 
audioFormat
 - 
audioStream
 - 
collectorThread
 - 
theThread
 - 
newDataUnits
 - 
repeat
 - 
byteConverter
 - 
fileDateStrip
 - 
currentAnalysisTime
protected volatile long currentAnalysisTimeCurrent analysis time - start of last data unit created. Can help to control restarts. 
 - 
 - 
Constructor Details
- 
FileInputSystem
 
 - 
 - 
Method Details
- 
getDaqSpecificDialogComponent
Description copied from class:DaqSystemThe AcquisitionDialog has been designed to that each data source type can plug in it's own panel of device specific controls. These could be things like a file name, gain settings, channel lists, whatever is available for the specific deviceThe AcquisitionDialog will handle placing this component on the dialog when a particular DaqSystem is selected. The component will be placed between a drop down list of available DaqSystem's and a section of the dialog showing the sample rate and number of channels.
- Specified by:
 getDaqSpecificDialogComponentin classDaqSystem- Parameters:
 acquisitionDialog- the AcquisitionDialog this component will be added to- Returns:
 - dialog component specific to this DAQ device
 
 - 
getDialogPanel
Gets and where necessary creates ...- Returns:
 - Daq dialog panel.
 
 - 
createDaqDialogPanel
 - 
dialogSetParams
public void dialogSetParams()Description copied from class:DaqSystemCalled by AcquisitionDialog.SetParams so that the dialog componenet can update it's fields- Specified by:
 dialogSetParamsin classDaqSystem
 - 
dialogGetParams
public boolean dialogGetParams()Description copied from class:DaqSystemCalled by AcquisitionDialog.GetParams so that parameters can be extracted from the dialog component. The DaqSystem should also implement PamSettings and handle storage of parameters between runs.- Specified by:
 dialogGetParamsin classDaqSystem- Returns:
 - true if the parameters and selections are OK. If false is returned the Acquisition dialog will not respond to its Ok button.
 
 - 
getSystemType
- Specified by:
 getSystemTypein classDaqSystem- Returns:
 - The 'type' of data source for display in the Data Source dialog
 
Calling functions should be able to handle 'null'
 
 - 
getSystemName
- Specified by:
 getSystemNamein classDaqSystem- Returns:
 - A string describing the data source, e.g. the sound card name, file name, udp port, etc.
 
 - 
actionPerformed
- Specified by:
 actionPerformedin interfaceActionListener
 - 
selectFile
protected void selectFile() - 
setNewFile
Called when user selects a file in the dialog.- Parameters:
 newFile-
 - 
getFirstFile
 - 
interpretNewFile
Called when a new file or folder is selected.- Parameters:
 newFile-
 - 
loadByteConverter
 - 
setStreamStatus
public void setStreamStatus(int streamStatus) - Overrides:
 setStreamStatusin classDaqSystem
 - 
getMaxChannels
public int getMaxChannels()- Specified by:
 getMaxChannelsin classDaqSystem- Returns:
 - the maximum number of channels supporrted by the selected device, or PARAMETER_UNKNOWN
 
 - 
getMaxSampleRate
public int getMaxSampleRate()- Specified by:
 getMaxSampleRatein classDaqSystem- Returns:
 - the maximum sample rate supporrted by the selected device, or PARAMETER_UNKNOWN
 
 - 
getPeak2PeakVoltage
public double getPeak2PeakVoltage(int swChannel) - Specified by:
 getPeak2PeakVoltagein classDaqSystem- Returns:
 - peak to peak voltage for the device or PARAMETER_UNKNOWN
 
 - 
isRealTime
public boolean isRealTime()- Specified by:
 isRealTimein classDaqSystem- Returns:
 - true for real time systems (e.g. sound cards, NI cards, wav files which are being played back over speakers. false for reading files which are to be processed as fast as possible with no playback.
 
 - 
getSkipStartFileTime
public long getSkipStartFileTime() - 
canPlayBack
public boolean canPlayBack(float sampleRate) - Specified by:
 canPlayBackin classDaqSystem- Returns:
 - true if the system can also play back sound - likely to be true for sound cards and ASIO, and some NI cards, false for wav files. Simulator ?
 
 - 
getSettingsReference
- Specified by:
 getSettingsReferencein interfacePamSettings- Returns:
 - The serialisable object that will be stored
 
 - 
getSettingsVersion
public long getSettingsVersion()- Specified by:
 getSettingsVersionin interfacePamSettings- Returns:
 - An integer version number for the settings
 
 - 
getUnitName
- Specified by:
 getUnitNamein interfaceSettingsNameProvider- Returns:
 - A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.
 
 - 
getUnitType
- Specified by:
 getUnitTypein interfacePamSettings- Returns:
 - A Name specific to the type, e.g. Click detector
 
 - 
restoreSettings
- Specified by:
 restoreSettingsin interfacePamSettings- Parameters:
 pamControlledUnitSettings-- Returns:
 - true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required
 
 - 
getChannels
public int getChannels() - 
getSampleRate
public float getSampleRate() - 
prepareSystem
Description copied from class:DaqSystemPrepare the DaqSystem.Usually this is the time for opening files, preparing data buffers, etc.
- Specified by:
 prepareSystemin classDaqSystem- Parameters:
 daqControl- AcquisitionControl unit.- Returns:
 - true if OK, false otherwise.
 
 - 
getCurrentFile
 - 
getDataUnitSamples
public int getDataUnitSamples()- Specified by:
 getDataUnitSamplesin classDaqSystem- Returns:
 - the number of samples expected in each data unit.
 
 - 
prepareInputFile
public boolean prepareInputFile()Open the audio stream for processing.- Returns:
 - true if audio stream opened correctly.
 
 - 
runFileAnalysis
public boolean runFileAnalysis() - 
getFileStartTime
Interpret the file name to get the file time.Moved to a separate function so it can be overridden in a special version for the DCL5 data set.
- Parameters:
 file- audio file.- Returns:
 - time in milliseconds.
 
 - 
startSystem
Description copied from class:DaqSystemStart the DaqSystem. This is called immediately after PrepareSystemMost things should be ready from the call to PrepareSystem. In StartSystem you will generally need to start a thread which will read in the data and place PamDataUnits in a buffer from where they are read by the main thred and passed on to other Pam modules for processing (see SoundCardSystem for an example)
- Specified by:
 startSystemin classDaqSystem- Parameters:
 daqControl- AcquisitionControl unit.- Returns:
 - true if OK, false otherwise
 
 - 
stopSystem
Description copied from class:DaqSystemStop the DaqSystem.- Specified by:
 stopSystemin classDaqSystem- Parameters:
 daqControl-
 - 
systemHasStopped
public void systemHasStopped(boolean wasRunning)  - 
collectFlacData
protected void collectFlacData()FLAC uses such a different way of decoding data to wav and aif that it needs to use it's own reader. - 
openNextFile
protected boolean openNextFile(long totalSamples) Open next file in a list for continuous processing, not the function that opens a file for normal processing.- Parameters:
 totalSamples-- Returns:
 
 - 
bytesToSamples
public static double[] bytesToSamples(byte[] byteArray, long nBytes, int channel, AudioFormat audioFormat) Format one channel of the data in a byte array into a sample array. - 
getSample
public static double getSample(byte[] buffer, int position, int bytesPerSample, boolean isBigEndian) Convenience method for getting samples from a byte array. Samples should be signed, integer, of either endian-ness, and 8, 16, 24, or 32 bits long. Result is scaled to the range of [-1,1). Note that .wav files are little-endian and .aif files are big-endian. - 
daqHasEnded
public void daqHasEnded()Description copied from class:DaqSystemCalled after DAQ has stopped - for whatever reason. Nost DAQ systems will not need to do anything here, but they could potentially clean up memory The motivation for putting this here now is for the folder analysis system so that it can start analysing the next file.- Specified by:
 daqHasEndedin classDaqSystem
 - 
fileListComplete
protected void fileListComplete()Called when all files to be processed have been processed. - 
getStatusBarComponent
- Overrides:
 getStatusBarComponentin classDaqSystem
 - 
sayEta
public void sayEta() - 
getEta
public long getEta() - 
sayEta
public void sayEta(long timeMs)  - 
getDeviceName
Description copied from class:DaqSystemGets a name for the acquisition device (may just be a number but need to generalise).- Specified by:
 getDeviceNamein classDaqSystem- Returns:
 
 - 
getSampleBits
public int getSampleBits()Description copied from class:DaqSystemGet the number of bits in each sample.- Overrides:
 getSampleBitsin classDaqSystem- Returns:
 - the number of bits in each sample.
 
 - 
fileDateChange
- Specified by:
 fileDateChangein interfaceFileDateObserver
 - 
getAquisitionControl
Get the acquisition control for the input system- Returns:
 - the acquisition control.
 
 - 
setSelected
public void setSelected(boolean select) Description copied from class:DaqSystemTell a DAQ system it's been selected or deselected.- Overrides:
 setSelectedin classDaqSystem- Parameters:
 select-
 - 
getSelectedFileTypes
- Returns:
 - the selectedFileTypes
 
 - 
setSelectedFileTypes
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.- Parameters:
 selectedFileTypes- the selectedFileTypes to set
 - 
getStoreInfo
Description copied from interface:DataStoreInfoHolderGet information about the input store (e.g. start times of all files).- Specified by:
 getStoreInfoin interfaceDataStoreInfoHolder- Parameters:
 workMonitor- monitor for work progress, should be called whenever a task is likely to take a long time so that a progress bar can update.detail- get detail of all files.- Returns:
 - information about data input.
 
 - 
setAnalysisStartTime
public boolean setAnalysisStartTime(long startTime) Description copied from interface:DataInputStoreSet an analysis start time. This might get called just before processing starts, in which case- Specified by:
 setAnalysisStartTimein interfaceDataInputStore- Parameters:
 startTime-- Returns:
 - ok if no problems.
 
 - 
getBatchStatus
Description copied from interface:DataInputStoreVery specific command handler for batch status which will only work with the acquisition folderinputSystem or the tritech file processing.- Specified by:
 getBatchStatusin interfaceDataInputStore- Returns:
 
 
 -