mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
Simple fix to amplitude calculations which were not thread safe. Not
constants are stored per channel rather than a single constant, so will be fine.
This commit is contained in:
parent
027a854084
commit
01c41a2896
@ -920,9 +920,11 @@ public class AcquisitionProcess extends PamProcess {
|
||||
*/
|
||||
public double rawAmplitude2dB(double rawAmplitude, int channel, boolean fast){
|
||||
|
||||
channel = checkSingleChannel(channel);
|
||||
|
||||
double constantTerm;
|
||||
if (fast && fixedAmplitudeConstantTerm != 0) {
|
||||
constantTerm = fixedAmplitudeConstantTerm;
|
||||
if (fast && fixedAmplitudeConstantTerm[channel] != 0) {
|
||||
constantTerm = fixedAmplitudeConstantTerm[channel];
|
||||
}
|
||||
else {
|
||||
constantTerm = getAmplitudeConstantTerm(channel);
|
||||
@ -944,6 +946,18 @@ public class AcquisitionProcess extends PamProcess {
|
||||
return dB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check it's a single channel and not a channel map.
|
||||
* @param channel
|
||||
* @return single channel if it seemed to be a bitmap.
|
||||
*/
|
||||
private int checkSingleChannel(int channel) {
|
||||
int bitCount = PamUtils.getNumChannels(channel);
|
||||
if (bitCount > 1 || channel > 32) {
|
||||
channel = PamUtils.getLowestChannel(channel);
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some devices may be setting this per channel.
|
||||
@ -969,17 +983,20 @@ public class AcquisitionProcess extends PamProcess {
|
||||
* like preamp gain will remain constant. Contains a constant
|
||||
* term in the SPL calculations bases on preamp gains and
|
||||
* hdrophone sensitivities.
|
||||
* Changes to be channel specific since with multi threading it goes horribly
|
||||
* wrong if different channels have different sensitivities.
|
||||
*/
|
||||
double fixedAmplitudeConstantTerm;
|
||||
private double[] fixedAmplitudeConstantTerm = new double[PamConstants.MAX_CHANNELS];
|
||||
|
||||
DaqSystem ampSystem;
|
||||
private DaqSystem ampSystem;
|
||||
/**
|
||||
* Gets the fixedAmplitudeConstantTerm based on channel and hydrophone
|
||||
* numbers.
|
||||
* Gets the fixedAmplitudeConstantTerm based on channel and hydrophone This is
|
||||
* the hydrophone sensitivity + all gains + ADC sensitivity in counts / volt.
|
||||
* @param channel = single software channel
|
||||
* @return constant term for amplitude calculations
|
||||
*/
|
||||
private double getAmplitudeConstantTerm(int channel) {
|
||||
channel = checkSingleChannel(channel);
|
||||
// need to fish around a bit working out which hydrophone it is, etc.
|
||||
PamArray array = ArrayManager.getArrayManager().getCurrentArray();
|
||||
int hydrophoneChannel = acquisitionControl.getChannelHydrophone(channel);
|
||||
@ -1000,12 +1017,14 @@ public class AcquisitionProcess extends PamProcess {
|
||||
}
|
||||
return (hSens + preamp.getGain() + xtra);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares for fast amplitude calculations
|
||||
* @param channel
|
||||
*/
|
||||
public void prepareFastAmplitudeCalculation(int channel) {
|
||||
fixedAmplitudeConstantTerm = getAmplitudeConstantTerm(channel);
|
||||
public double prepareFastAmplitudeCalculation(int channel) {
|
||||
channel = checkSingleChannel(channel);
|
||||
return fixedAmplitudeConstantTerm[channel] = getAmplitudeConstantTerm(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ public class PamFFTProcess extends PamProcess {
|
||||
|
||||
private double[] dataToFFT;
|
||||
|
||||
private ComplexArray fftData;
|
||||
// private ComplexArray fftData;
|
||||
|
||||
private double[] fftRealBlock;
|
||||
|
||||
@ -198,7 +198,7 @@ public class PamFFTProcess extends PamProcess {
|
||||
channelPointer[i] = 0;
|
||||
}
|
||||
}
|
||||
fftData = new ComplexArray(fftParameters.fftLength);
|
||||
// fftData = new ComplexArray(fftParameters.fftLength);
|
||||
/*
|
||||
* Tell the output data block - should then get passed on to Spectrogram
|
||||
* display which can come back and work it out for itself that life has
|
||||
|
Loading…
Reference in New Issue
Block a user