|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectPamguardMVC.PamProcess
Spectrogram.SpectrogramMarkProcess
public abstract class SpectrogramMarkProcess
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.
SpectrogramDisplay,
SpectrogramMarkObserver,
PamDataBlock| Field Summary |
|---|
| Fields inherited from class PamguardMVC.PamProcess |
|---|
outputDataBlocks, processName, sampleRate |
| Fields inherited from interface Spectrogram.SpectrogramMarkObserver |
|---|
MOUSE_DOWN, MOUSE_UP |
| Constructor Summary | |
|---|---|
SpectrogramMarkProcess(PamControlledUnit pamControlledUnit)
|
|
| Method Summary | |
|---|---|
java.lang.String |
getMarkObserverName()
|
void |
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. |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SpectrogramMarkProcess(PamControlledUnit pamControlledUnit)
| Method Detail |
|---|
public void spectrogramNotification(SpectrogramDisplay display,
int downUp,
int channel,
long startMilliseconds,
long duration,
double f1,
double f2)
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.
spectrogramNotification in interface SpectrogramMarkObserverpublic java.lang.String getMarkObserverName()
getMarkObserverName in interface SpectrogramMarkObserverpublic void pamStart()
PamProcess
pamStart in class PamProcesspublic void pamStop()
PamProcess
pamStop in class PamProcess
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||