clipgenerator
Class ClipProcess

java.lang.Object
  extended by PamguardMVC.PamProcess
      extended by Spectrogram.SpectrogramMarkProcess
          extended by clipgenerator.ClipProcess
All Implemented Interfaces:
Annotator, PamObserver, SpectrogramMarkObserver

public class ClipProcess
extends SpectrogramMarkProcess


Field Summary
 
Fields inherited from class PamguardMVC.PamProcess
outputDataBlocks, processName, sampleRate
 
Fields inherited from interface Spectrogram.SpectrogramMarkObserver
MOUSE_DOWN, MOUSE_UP
 
Constructor Summary
ClipProcess(PamControlledUnit pamControlledUnit)
           
 
Method Summary
 void spectrogramNotification(SpectrogramDisplay display, int downUp, int channel, long startMilliseconds, long duration, double f1, double f2)
          Override this to process data from the marked spectrogram.
 
Methods inherited from class Spectrogram.SpectrogramMarkProcess
getMarkObserverName, pamStart, pamStop
 
Methods inherited from class PamguardMVC.PamProcess
absMillisecondsToSamples, absSamplesToMilliseconds, addOutputDataBlock, changedThreading, clearOldData, createAnnotations, destroyProcess, fillXMLElement, fillXMLParameters, getAncestorDataBlock, getAnnotation, getBackendProcess, getChainPosition, getCpuPercent, getNumAnnotations, getNumOutputDataBlocks, getObserverName, getObserverObject, getOfflineData, getOutputDataBlock, getPamControlledUnit, getParentDataBlock, getParentProcess, getProcessName, getRawSourceDataBlock, getRequiredDataHistory, getSampleRate, getSourceDataBlock, getSourceProcess, isCanMultiThread, makePamProcess, masterClockUpdate, newData, noteNewSettings, notifyModelChanged, prepareProcess, relMillisecondsToSamples, relSamplesToMilliseconds, removeObservable, removeOutputDatablock, saveViewerData, setBackendProcess, setCanMultiThread, setParentDataBlock, setParentDataBlock, setProcessName, setSampleRate, setupProcess, toString, update, updateData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClipProcess

public ClipProcess(PamControlledUnit pamControlledUnit)
Method Detail

spectrogramNotification

public void spectrogramNotification(SpectrogramDisplay display,
                                    int downUp,
                                    int channel,
                                    long startMilliseconds,
                                    long duration,
                                    double f1,
                                    double f2)
Description copied from class: SpectrogramMarkProcess
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 < 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
Overrides:
spectrogramNotification in class SpectrogramMarkProcess