Class SpectrogramMarkProcess
- All Implemented Interfaces:
PamObserver
,ProcessAnnotator
,SpectrogramMarkObserver
- Direct Known Subclasses:
ClipProcess
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:
-
Field Summary
Fields inherited from interface Spectrogram.SpectrogramMarkObserver
MOUSE_DOWN, MOUSE_DRAG, MOUSE_UP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
pamStart()
Called for each process to tell it to start (may not be necessary for processes which are listening for data anyway).void
pamStop()
Stops the process.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.Methods inherited from class PamguardMVC.PamProcess
absMillisecondsToSamples, absSamplesToMilliseconds, addData, addMultiPlexDataBlock, addOutputDataBlock, changedThreading, clearOldData, createAnnotations, destroyProcess, dumpBufferStatus, flushDataBlockBuffers, getAncestorDataBlock, getAnnotation, getChainPosition, getCompatibleDataUnits, getCpuPercent, getFrequencyRange, getLastSourceNotificationObject, getLastSourceNotificationType, getMuiltiplexDataBlock, getNumAnnotations, getNumMuiltiplexDataBlocks, getNumOutputDataBlocks, getObserverName, getObserverObject, getOfflineData, getOfflineData, getOutputDataBlock, getOutputDataBlocks, getPamControlledUnit, getParentDataBlock, getParentDataBlocks, getParentProcess, getProcessCheck, getProcessName, getRawSourceDataBlock, getRawSourceDataBlock, getRequiredDataHistory, getSampleRate, getSourceDataBlock, getSourceProcess, hasOutputDatablock, isCanMultiThread, isExternalProcess, isMultiplex, makePamProcess, masterClockUpdate, newData, noteNewSettings, notifyModelChanged, prepareProcess, prepareProcessOK, processNewBuoyData, receiveSourceNotification, relMillisecondsToSamples, relSamplesToMilliseconds, removeAllDataBlocks, removeAllMultiPlexDataBlocks, removeMultiPlexDataBlock, removeObservable, removeOutputDatablock, resetDataBlocks, saveViewerData, setCanMultiThread, setExternalProcess, setMultiplex, setParentDataBlock, setParentDataBlock, setProcessCheck, setProcessName, setSampleRate, setupProcess, toString, updateData
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface Spectrogram.SpectrogramMarkObserver
canMark, getMarkName
-
Constructor Details
-
SpectrogramMarkProcess
-
-
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 interfaceSpectrogramMarkObserver
- Parameters:
display
- spectrogram displaydownUp
- 0 = mouse down, 1 = mouse up, 2 = drag + button number in upper 16 bits.channel
- channel or sequence number, depending on the sourcestartMilliseconds
- start time in milliseconds.duration
- duration in milliseconds.f1
- min frequency in Hzf2
- 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
- Specified by:
getMarkObserverName
in interfaceSpectrogramMarkObserver
- 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 classPamProcess
-
pamStop
public void pamStop()Description copied from class:PamProcess
Stops the process.- Specified by:
pamStop
in classPamProcess
-