mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
Bug fix for raw spectrogram in TDDisplayFX
This commit is contained in:
parent
7bb8c76898
commit
0b2a706c3a
@ -51,6 +51,7 @@ public class PamUtils {
|
|||||||
channels++;
|
channels++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Looks like this has been returning 1 instead of -1 for many years.
|
* Looks like this has been returning 1 instead of -1 for many years.
|
||||||
* May need to revert to this behaviour if modules have come to depend
|
* May need to revert to this behaviour if modules have come to depend
|
||||||
@ -58,6 +59,7 @@ public class PamUtils {
|
|||||||
*/
|
*/
|
||||||
if (channels > 1)
|
if (channels > 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return singleChan;
|
return singleChan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,6 +417,8 @@ public abstract class ScrollingImageSegmenter {
|
|||||||
* @param tm - the repaint time in millis.
|
* @param tm - the repaint time in millis.
|
||||||
*/
|
*/
|
||||||
public void paintImages(GraphicsContext g, TDProjectorFX tdProjector, double scrollStart, long tm) {
|
public void paintImages(GraphicsContext g, TDProjectorFX tdProjector, double scrollStart, long tm) {
|
||||||
|
//System.out.println("ScrollingImageSegmenter: paintImages: " + tm);
|
||||||
|
|
||||||
if (tm==0) {
|
if (tm==0) {
|
||||||
paintImages(g, tdProjector, scrollStart);
|
paintImages(g, tdProjector, scrollStart);
|
||||||
return;
|
return;
|
||||||
@ -452,6 +454,7 @@ public abstract class ScrollingImageSegmenter {
|
|||||||
double y1;
|
double y1;
|
||||||
double y2;
|
double y2;
|
||||||
double tcMillis;
|
double tcMillis;
|
||||||
|
|
||||||
for (int i=0; i<this.imageSegments.size(); i++) {
|
for (int i=0; i<this.imageSegments.size(); i++) {
|
||||||
//Parameters:
|
//Parameters:
|
||||||
// img - the image to be drawn or null.
|
// img - the image to be drawn or null.
|
||||||
@ -482,8 +485,8 @@ public abstract class ScrollingImageSegmenter {
|
|||||||
y2=tdProjector.getYPix(maxYVal);
|
y2=tdProjector.getYPix(maxYVal);
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("Paint the image: tC: "
|
// System.out.println("Paint the image: tC: "
|
||||||
// + "" + tC + " tCEnd: " + tCEnd + " tcMillis " + tcMillis + " y1: " + y1 + " y2 " + y2 );
|
// + "" + tC + " tCEnd: " + tCEnd + " tcMillis " + tcMillis + " y1: " + y1 + " y2 " + y2 );
|
||||||
|
|
||||||
g.drawImage(imageSegments.get(i),
|
g.drawImage(imageSegments.get(i),
|
||||||
0,
|
0,
|
||||||
|
@ -85,12 +85,24 @@ public abstract class FFTPlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void lastUnitDrawn(GraphicsContext g, double scrollStart, TDProjectorFX tdProjector,int plotnumber) {
|
public void lastUnitDrawn(GraphicsContext g, double scrollStart, TDProjectorFX tdProjector, int plotnumber) {
|
||||||
|
|
||||||
if (rawClipInfo.getScaleInfo()==null) return;
|
//System.out.println("FFTPlotManager: Last drawn unit1");
|
||||||
|
|
||||||
int plot = PamUtils.getSingleChannel(rawClipInfo.getScaleInfo().getPlotChannels()[plotnumber]); //needs to be the plot channels because the waveSegmenter is organised by channel
|
if (rawClipInfo.getScaleInfo()==null){
|
||||||
|
System.err.println("FFTPlotManager: the rawClipInfo.getScaleInfo() is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//needs to be the plot channels because the waveSegmenter is organised by channel
|
||||||
|
int plot = PamUtils.getSingleChannel(rawClipInfo.getScaleInfo().getPlotChannels()[plotnumber]);
|
||||||
|
|
||||||
|
if (rawClipInfo.getScaleInfo().getPlotChannels()[plotnumber]==0) plot=0;
|
||||||
|
|
||||||
|
// System.out.println("FFTPlotManager: Last drawn unit2: " + " " + rawClipInfo.getScaleInfo().getPlotChannels()[plotnumber] + " " + plotnumber);
|
||||||
|
//
|
||||||
|
// System.out.println("FFTPlotManager: Last drawn unit2: " + plot + " rawClipInfo.getScaleInfoIndex(): "
|
||||||
|
// + rawClipInfo.getScaleInfoIndex() + " " +rawClipInfo.getScaleInfos().indexOf(getFrequencyScaleInfo()));
|
||||||
|
|
||||||
//only draw the writable images once we have the last data unit.
|
//only draw the writable images once we have the last data unit.
|
||||||
if (plot>=0 && fftImageSegmenter[plot]!=null && rawClipInfo.getScaleInfoIndex()==rawClipInfo.getScaleInfos().indexOf(getFrequencyScaleInfo())) {
|
if (plot>=0 && fftImageSegmenter[plot]!=null && rawClipInfo.getScaleInfoIndex()==rawClipInfo.getScaleInfos().indexOf(getFrequencyScaleInfo())) {
|
||||||
@ -310,7 +322,7 @@ public abstract class FFTPlotManager {
|
|||||||
double timeMillisFFT;
|
double timeMillisFFT;
|
||||||
int newtc;
|
int newtc;
|
||||||
//if zero just draw one line to be efficient
|
//if zero just draw one line to be efficient
|
||||||
// System.out.println("SpectrogramLength: " + spectrogram.length);
|
//System.out.println("SpectrogramLength: " + spectrogram.length);
|
||||||
|
|
||||||
//maybe compress image?
|
//maybe compress image?
|
||||||
|
|
||||||
@ -331,14 +343,15 @@ public abstract class FFTPlotManager {
|
|||||||
|
|
||||||
tc=newtc;
|
tc=newtc;
|
||||||
|
|
||||||
//double[] minmax = PamUtils.getMinAndMax(spectrogram);
|
// double[] minmax = PamUtils.getMinAndMax(spectrogram);
|
||||||
//System.out.println("Plot spectrogram: tc " + tc + " minmax: " + 20*Math.log10(minmax[0])+clipLevel + " " + 20*Math.log10(minmax[1])+ " Clip level: " + clipLevel);
|
// System.out.println("Plot spectrogram: tc " + tc + " minmax: " + 20*Math.log10(minmax[0])+clipLevel + " " + 20*Math.log10(minmax[1])+ " Clip level: " + clipLevel);
|
||||||
|
|
||||||
|
|
||||||
//how many lines in the image does the FFT take up?
|
//how many lines in the image does the FFT take up?
|
||||||
|
|
||||||
for (int j=0; j<writableImage.getHeight(); j++) {
|
for (int j=0; j<writableImage.getHeight(); j++) {
|
||||||
|
|
||||||
|
writableImage.getPixelWriter().setColor(0, j, Color.BLACK);
|
||||||
|
|
||||||
//what is the spectrum value for the height?
|
//what is the spectrum value for the height?
|
||||||
int spec = (int) ((j/(double) writableImage.getHeight())*spectrogram[i].length);
|
int spec = (int) ((j/(double) writableImage.getHeight())*spectrogram[i].length);
|
||||||
|
|
||||||
@ -437,20 +450,20 @@ public abstract class FFTPlotManager {
|
|||||||
return dB;
|
return dB;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Stroke a vertical line in the writable image.
|
// * Stroke a vertical line in the writable image.
|
||||||
// * @param writableImage - the writable image
|
// * @param writableImage - the writable image
|
||||||
// * @param x1 - x start of the line to stroke.
|
// * @param x1 - x start of the line to stroke.
|
||||||
// * @param y1 - y start of the line to stroke.
|
// * @param y1 - y start of the line to stroke.
|
||||||
// * @param x2 - x end of the line to stroke.
|
// * @param x2 - x end of the line to stroke.
|
||||||
// * @param y2 -
|
// * @param y2 -
|
||||||
// */
|
// */
|
||||||
// private void strokeLine(WritableImageSegment writableImage, int x1, int y1, int y2, Color color) {
|
// private void strokeLine(WritableImageSegment writableImage, int x1, int y1, int y2, Color color) {
|
||||||
// //weird. y==y2 does not work but i<y2 does?
|
// //weird. y==y2 does not work but i<y2 does?
|
||||||
// for (int i=y1; i<y2; i++) {
|
// for (int i=y1; i<y2; i++) {
|
||||||
// writableImage.getPixelWriter().setColor((int) Math.min(x1, writableImage.getWidth()-1), i, color);
|
// writableImage.getPixelWriter().setColor((int) Math.min(x1, writableImage.getWidth()-1), i, color);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,6 +75,7 @@ public abstract class RawWavePlotManager {
|
|||||||
|
|
||||||
int plot = PamUtils.getSingleChannel(rawClipInfo.getScaleInfo().getPlotChannels()[plotnumber]); //needs to be the plot channels because the waveSegmenter is organised by channel
|
int plot = PamUtils.getSingleChannel(rawClipInfo.getScaleInfo().getPlotChannels()[plotnumber]); //needs to be the plot channels because the waveSegmenter is organised by channel
|
||||||
|
|
||||||
|
if (rawClipInfo.getScaleInfo().getPlotChannels()[plotnumber]==0) plot=0;
|
||||||
|
|
||||||
//System.out.println("Plot plot: " + plot + " " + plotnumber);
|
//System.out.println("Plot plot: " + plot + " " + plotnumber);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user