mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
Fix synchronization problem in RawDataTransfroms
This commit is contained in:
parent
6b15b3d536
commit
cd89c65d7c
@ -188,7 +188,8 @@ public class RawDataTransforms {
|
||||
* @param fftLength
|
||||
* @return Power spectrum
|
||||
*/
|
||||
public synchronized double[] getPowerSpectrum(int channel, int fftLength) {
|
||||
public double[] getPowerSpectrum(int channel, int fftLength) {
|
||||
synchronized (synchObject) {
|
||||
if (powerSpectra == null) {
|
||||
powerSpectra = new double[PamUtils.getNumChannels(dataUnit.getChannelBitmap())][];
|
||||
}
|
||||
@ -212,6 +213,7 @@ public class RawDataTransforms {
|
||||
}
|
||||
return powerSpectra[channel];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -220,7 +222,8 @@ public class RawDataTransforms {
|
||||
* @param fftLength
|
||||
* @return Sum of power spectra
|
||||
*/
|
||||
public synchronized double[] getTotalPowerSpectrum(int fftLength) {
|
||||
public double[] getTotalPowerSpectrum(int fftLength) {
|
||||
synchronized (synchObject) {
|
||||
if (fftLength == 0) {
|
||||
fftLength = getCurrentSpectrumLength();
|
||||
}
|
||||
@ -240,6 +243,7 @@ public class RawDataTransforms {
|
||||
}
|
||||
return totalPowerSpectrum;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -253,7 +257,8 @@ public class RawDataTransforms {
|
||||
* @param fftLength - the FFT length to use.
|
||||
* @return the complex spectrum - the comnplex spectrum of the wave data from the specified channel.
|
||||
*/
|
||||
public synchronized ComplexArray getComplexSpectrumHann(int channel, int fftLength) {
|
||||
public ComplexArray getComplexSpectrumHann(int channel, int fftLength) {
|
||||
synchronized (synchObject) {
|
||||
complexSpectrum = new ComplexArray[PamUtils.getNumChannels(dataUnit.getChannelBitmap())];
|
||||
if (complexSpectrum[channel] == null
|
||||
|| complexSpectrum.length != fftLength / 2) {
|
||||
@ -263,6 +268,7 @@ public class RawDataTransforms {
|
||||
}
|
||||
return complexSpectrum[channel];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -389,7 +395,8 @@ public class RawDataTransforms {
|
||||
* @param fftLength
|
||||
* @return the complex spectrum
|
||||
*/
|
||||
public synchronized ComplexArray getComplexSpectrum(int channel, int fftLength) {
|
||||
public ComplexArray getComplexSpectrum(int channel, int fftLength) {
|
||||
synchronized (synchObject) {
|
||||
double[] paddedRawData;
|
||||
double[] rawData;
|
||||
int i, mn;
|
||||
@ -413,6 +420,7 @@ public class RawDataTransforms {
|
||||
}
|
||||
return complexSpectrum[channel];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -420,7 +428,8 @@ public class RawDataTransforms {
|
||||
* @param iChan channel index
|
||||
* @return analytic waveform
|
||||
*/
|
||||
public synchronized double[] getAnalyticWaveform(int iChan) {
|
||||
public double[] getAnalyticWaveform(int iChan) {
|
||||
synchronized (synchObject) {
|
||||
if (analyticWaveform == null) {
|
||||
analyticWaveform = new double[getNChan()][];
|
||||
}
|
||||
@ -429,6 +438,7 @@ public class RawDataTransforms {
|
||||
// }
|
||||
return analyticWaveform[iChan];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filtered or unfiltered analytic waveform. Easy access method for click
|
||||
@ -439,7 +449,8 @@ public class RawDataTransforms {
|
||||
* @param fftFilterParams fft filter parameters.
|
||||
* @return analystic waveform.
|
||||
*/
|
||||
public synchronized double[] getAnalyticWaveform(int iChan, boolean filtered, FFTFilterParams fftFilterParams) {
|
||||
public double[] getAnalyticWaveform(int iChan, boolean filtered, FFTFilterParams fftFilterParams) {
|
||||
synchronized (synchObject) {
|
||||
if (filtered == false || fftFilterParams == null) {
|
||||
return getAnalyticWaveform(iChan);
|
||||
}
|
||||
@ -447,6 +458,7 @@ public class RawDataTransforms {
|
||||
return getFilteredAnalyticWaveform(fftFilterParams, iChan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a filtered version of the analytic waveform. In principle, this could be made more efficient
|
||||
|
Loading…
Reference in New Issue
Block a user