Package Spectrogram

Class SpectrogramMarkProcess

java.lang.Object
PamguardMVC.PamProcess
Spectrogram.SpectrogramMarkProcess
All Implemented Interfaces:
PamObserver, ProcessAnnotator, SpectrogramMarkObserver
Direct Known Subclasses:
ClipProcess

public abstract class SpectrogramMarkProcess extends PamProcess implements SpectrogramMarkObserver
Standard process for any PamControlled unit observing marks made manually on spectrogram displays.

These processes receive a notification message from spectrgram displays when the mouse is pressed on the display and again when it is released. The notification contains the time and frequency bounds of the mark, which can then be used to perform some kind of data processing, e.g. calculate the bearing to the sound within the mark, make a waveform clip, etc.

It is important that the necessary data is available in memory for the SpectrogramMarkProcess. This is most likely to be either the spectrgram data itself, or the waveform data used to create the spectrogram FFT blocks. To ensure that these data are available, any SpectrogramDisplay which has one or more active SpectrogramMarkObservers will subscribe to the FFT and Waveform data blocks and ensure that at least one complete screen full of data is always stored. When the mouse is pressed, the SpectrogramDisplay ceases scrolling, but Pamguard data processing continues. During the time that the mouse is pressed, the SpectrogramDisplay will extend the time data are kept for as necessary to ensure that data from the mouse press time are indeed available.

This abstract subclass of PamProcess provides some simple utilities to get at the waveform data and tha FFT data.

Author:
Doug Gillespie
See Also:
  • Constructor Details

    • SpectrogramMarkProcess

      public SpectrogramMarkProcess(PamControlledUnit pamControlledUnit)
  • Method Details

    • spectrogramNotification

      public boolean spectrogramNotification(SpectrogramDisplay display, MouseEvent mouseEvent, int downUp, int channel, long startMilliseconds, long duration, double f1, double f2, TDGraphFX tdDisplay)
      Override this to process data from the marked spectrogram.

      The spectrogram will have already ensured that Raw waveform data and FFT data that made the SpectrogramDisplay are still in memory and the data blocks can be accessed using

      PamRawDataBlock rawDataBlock = (PamRawDataBlock) display.getSourceRawDataBlock();

      and

      PamDataBlock fftDataBlock = display.getSourceFFTDataBlock();

      To obtain raw data, first convert the startMilliseconds and duration to sample numbers using

      long startSample = absMillisecondsToSamples(startMilliseconds);

      and

      int numSamples = (int) relMillisecondsToSamples(duration);

      then make a bitmap of the channels you wnat -

      int channelMap;

      channelMap = PamUtils.SetBit(0, channel, 1); // just the channel that had the mark

      channelMap = rawDataBlock.getChannelMap(); // all channels in the raw data block

      Then get teh samples from the raw data block ...

      double[][] rawData = rawDataBlock.getSamples(startSample, numSamples, channelMap);

      To get the FFT data, use PamDataUnit fftDataUnit;

      int fftDataUnitIndex = fftDataBlock.getIndexOfFirstUnitAfter(startMilliseconds);

      if (fftDataUnitIndex >= 0) while (fftDataUnitIndex invalid input: '<' fftDataBlock.getUnitsCount()) {

      fftDataUnit = fftDataBlock.getDataUnit(fftDataUnitIndex, PamDataBlock.REFERENCE_CURRENT);

      if (fftDataUnit.timeMilliseconds + fftDataUnit.duration > startMilliseconds + duration) {

      break;

      }

      // process that unit in any way you want, then get the next unit

      fftDataUnitIndex ++;

      }

      Remember that the data units will contain one channel of fft data each and multiple channels may be interleaved.

      Specified by:
      spectrogramNotification in interface SpectrogramMarkObserver
      Parameters:
      display - spectrogram display
      downUp - 0 = mouse down, 1 = mouse up, 2 = drag + button number in upper 16 bits.
      channel - channel or sequence number, depending on the source
      startMilliseconds - start time in milliseconds.
      duration - duration in milliseconds.
      f1 - min frequency in Hz
      f2 - max frequency in Hz
      Returns:
      true if the user has popped up a menu or done something that should stop the sending display from carrying out any further actions on this mouse action (put in place to prevent the spectrogram menu popping up when editing marks in viewer mode).
    • getMarkObserverName

      public String getMarkObserverName()
      Specified by:
      getMarkObserverName in interface SpectrogramMarkObserver
      Returns:
      Name for the mark observer to show in the spectrogram dialog.
    • pamStart

      public void pamStart()
      Description copied from class: PamProcess
      Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway).
      Specified by:
      pamStart in class PamProcess
    • pamStop

      public void pamStop()
      Description copied from class: PamProcess
      Stops the process.
      Specified by:
      pamStop in class PamProcess