PamDetection
Class AcousticDataUnit

java.lang.Object
  extended by PamguardMVC.PamDataUnit
      extended by PamDetection.AcousticDataUnit
All Implemented Interfaces:
java.lang.Comparable<PamDataUnit>
Direct Known Subclasses:
AveragedSpectraDataUnit, BackgroundDataUnit, FFTDataUnit, IshDetFnDataUnit, NoiseDataUnit, NormalizedDataUnit, PamDetection, RawDataUnit, SpectralEtiDataUnit, VetoBackgroundDataUnit, WhistleClassificationDataUnit

public abstract class AcousticDataUnit
extends PamDataUnit

Basic class for all acoustic data, everything from raw audio data to final detections with localisations

Author:
Doug Gillespie

Field Summary
static int AMPLITUDE_SCALE_DBREMPA
          Amplitude value is in dB relative to 1 micropascal
static int AMPLITUDE_SCALE_LINREFSD
          Amplitude scale is linear relative to full scale
private  double calculatedAmlitudeDB
           
protected  long duration
          also in samples for precision.
protected  double[] frequency
          Frequency limits of the data in the data unit.
private  double measuredAmplitude
          measured amplitude contains the most easily used value of amplitude.
private  int measuredAmplitudeType
           
protected  long startSample
          all acoustic data must somehow have a knowledge of sample rate.
 
Fields inherited from class PamguardMVC.PamDataUnit
absBlockIndex, channelBitmap, localisation, oLL, timeMilliseconds
 
Constructor Summary
AcousticDataUnit(long timeMilliseconds, int channelBitmap, long startSample, long duration)
           
 
Method Summary
 void amplifyMeasuredAmplitudeByDB(double gaindB)
           
 void amplifyMeasuredAmplitudeByLinear(double gaindB)
           
private  double calculateAmplitudeDB()
           
 int compareTo(PamDataUnit o)
           
 double getAmplitudeDB()
           
 double getCalculatedAmlitudeDB()
           
 long getDuration()
           
 double[] getFrequency()
           
 double getFrequencyOverlap(AcousticDataUnit o)
          returns the frequency overlap of another unit on this unit - so if the other unit is longer in time and completely coveres this unit, the overlap is 1.0, if the other unit is shorter or not aligned, then the overlap will be < 1.
 long getLastSample()
           
 double getMeasuredAmplitude()
           
 int getMeasuredAmplitudeType()
           
 double getSeconds()
           
 long getStartSample()
           
 double getTimeOverlap(AcousticDataUnit o)
          returns the time overlap of another unit on this unit - so if the other unit is longer in time and completely coveres this unit, the overlap is 1.0, if the other unit is shorter or not aligned, then the overlap will be < 1.
private  double linAmplitudeToDB(double linamp)
           
 void setCalculatedAmlitudeDB(double calculatedAmlitudeDB)
           
 void setDuration(long duration)
           
 void setFrequency(double[] frequency)
           
 void setInfo(long timeMilliseconds, int channelBitmap, long startSample, long duration)
           
 void setMeasuredAmplitude(double measuredAmplitude)
           
 void setMeasuredAmplitude(double measuredAmplitude, int measuredAmplitudeType)
           
 void setMeasuredAmplitudeType(int measuredAmplitudeType)
           
 void setStartSample(long startSample)
           
 
Methods inherited from class PamguardMVC.PamDataUnit
clearUpdateCount, getAbsBlockIndex, getChannelBitmap, getDatabaseIndex, getDatabaseUpdateOf, getDataUnitFileInformation, getGpsPosition, getLastUpdateTime, getLocalisation, getOriginLatLong, getPairAngle, getParentDataBlock, getTimeMilliseconds, getUpdateCount, setAbsBlockIndex, setChannelBitmap, setDatabaseIndex, setDatabaseUpdateOf, setDataUnitFileInformation, setLastUpdateTime, setLocalisation, setOriginLatLong, setParentDataBlock, setTimeMilliseconds, updateDataUnit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startSample

protected long startSample
all acoustic data must somehow have a knowledge of sample rate. This gives the ultimate in precise timing for all data


duration

protected long duration
also in samples for precision. The PamDataBlock class has knowledge of the sample rate, which can be used to convert this into seconds.


frequency

protected double[] frequency
Frequency limits of the data in the data unit.


measuredAmplitude

private double measuredAmplitude
measured amplitude contains the most easily used value of amplitude. The int's below tell us how it was measured (this list will need extending, as will the getAmplitudedB function.


AMPLITUDE_SCALE_DBREMPA

public static final int AMPLITUDE_SCALE_DBREMPA
Amplitude value is in dB relative to 1 micropascal

See Also:
Constant Field Values

AMPLITUDE_SCALE_LINREFSD

public static final int AMPLITUDE_SCALE_LINREFSD
Amplitude scale is linear relative to full scale

See Also:
Constant Field Values

measuredAmplitudeType

private int measuredAmplitudeType

calculatedAmlitudeDB

private double calculatedAmlitudeDB
Constructor Detail

AcousticDataUnit

public AcousticDataUnit(long timeMilliseconds,
                        int channelBitmap,
                        long startSample,
                        long duration)
Method Detail

getMeasuredAmplitude

public double getMeasuredAmplitude()
Returns:
Returns the measuredAmplitude.

getMeasuredAmplitudeType

public int getMeasuredAmplitudeType()
Returns:
Returns the measuredAmplitudeType.

amplifyMeasuredAmplitudeByDB

public void amplifyMeasuredAmplitudeByDB(double gaindB)

amplifyMeasuredAmplitudeByLinear

public void amplifyMeasuredAmplitudeByLinear(double gaindB)

setMeasuredAmplitude

public void setMeasuredAmplitude(double measuredAmplitude,
                                 int measuredAmplitudeType)
Parameters:
measuredAmplitude - The measuredAmplitude to set.

getAmplitudeDB

public double getAmplitudeDB()

calculateAmplitudeDB

private double calculateAmplitudeDB()

linAmplitudeToDB

private double linAmplitudeToDB(double linamp)

getLastSample

public long getLastSample()

getCalculatedAmlitudeDB

public double getCalculatedAmlitudeDB()

setCalculatedAmlitudeDB

public void setCalculatedAmlitudeDB(double calculatedAmlitudeDB)

getDuration

public long getDuration()
Returns:
the length of the acoustic data in samples

setDuration

public void setDuration(long duration)

getFrequency

public double[] getFrequency()

setFrequency

public void setFrequency(double[] frequency)

getStartSample

public long getStartSample()
Returns:
The start sample of the data unit counting from the start of the run.

setStartSample

public void setStartSample(long startSample)

getSeconds

public double getSeconds()
Returns:
the start time of the data unit in seconds relative to the start of the run.

setMeasuredAmplitude

public void setMeasuredAmplitude(double measuredAmplitude)

setMeasuredAmplitudeType

public void setMeasuredAmplitudeType(int measuredAmplitudeType)

setInfo

public void setInfo(long timeMilliseconds,
                    int channelBitmap,
                    long startSample,
                    long duration)

getTimeOverlap

public double getTimeOverlap(AcousticDataUnit o)
returns the time overlap of another unit on this unit - so if the other unit is longer in time and completely coveres this unit, the overlap is 1.0, if the other unit is shorter or not aligned, then the overlap will be < 1.

Parameters:
o - Other AcousticDataUnit
Returns:
fractional overlap in time

getFrequencyOverlap

public double getFrequencyOverlap(AcousticDataUnit o)
returns the frequency overlap of another unit on this unit - so if the other unit is longer in time and completely coveres this unit, the overlap is 1.0, if the other unit is shorter or not aligned, then the overlap will be < 1.

Parameters:
o - Other AcousticDataUnit
Returns:
fractional overlap in time

compareTo

public int compareTo(PamDataUnit o)
Specified by:
compareTo in interface java.lang.Comparable<PamDataUnit>
Overrides:
compareTo in class PamDataUnit