mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 01:27:34 -05:00
#35 Updates AM & NBFM decoders to use Adaptive Squelch, a power squelch that includes an adaptive noise floor monitor. Implements vectorized magnitude operations for AM & FM decoders. Adds talkgroup assignment and squelch controls to AM channel configuration editor. Implements new AM gain control that attempts to normalize audio gain quickly at beginning of call/transmission and maintains that gain across lifecycle of the call and resets the gain for the next call. (#1540)
Notes on usage: - When using either AM or FM squelch control use either the Heterodyne channelizer or if using the Polyphase channelizer, avoid using trunk tracking decoders like DMR or P25 or set the squelch threshold high enough to avoid changes in noise floor from polyphase channelizer where it can vary between using the one channel or the two-channel combined channel sources. Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.dsp.magnitude;
|
||||
|
||||
/**
|
||||
* Interface for implementations that calculate magnitude
|
||||
*/
|
||||
public interface IMagnitudeCalculator
|
||||
{
|
||||
float[] calculate(float[] i, float[] q);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.dsp.magnitude;
|
||||
|
||||
import io.github.dsheirer.vector.calibrate.CalibrationManager;
|
||||
import io.github.dsheirer.vector.calibrate.CalibrationType;
|
||||
import io.github.dsheirer.vector.calibrate.Implementation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Factory for creating magnitude implementations
|
||||
*/
|
||||
public class MagnitudeFactory
|
||||
{
|
||||
private static final Logger mLog = LoggerFactory.getLogger(MagnitudeFactory.class);
|
||||
|
||||
/**
|
||||
* Creates a magnitude implementation using calibration data to select the optimal
|
||||
* implementation from scalar and vector options.
|
||||
* @return demodulator instance
|
||||
*/
|
||||
public static IMagnitudeCalculator getMagnitudeCalculator()
|
||||
{
|
||||
Implementation implementation = CalibrationManager.getInstance().getImplementation(CalibrationType.MAGNITUDE);
|
||||
|
||||
switch(implementation)
|
||||
{
|
||||
case VECTOR_SIMD_64:
|
||||
return new VectorMagnitudeCalculator64();
|
||||
case VECTOR_SIMD_128:
|
||||
return new VectorMagnitudeCalculator128();
|
||||
case VECTOR_SIMD_256:
|
||||
return new VectorMagnitudeCalculator256();
|
||||
case VECTOR_SIMD_512:
|
||||
return new VectorMagnitudeCalculator512();
|
||||
case SCALAR:
|
||||
default:
|
||||
return new ScalarMagnitudeCalculator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.dsp.magnitude;
|
||||
|
||||
/**
|
||||
* Scalar implementation of magnitude
|
||||
*/
|
||||
public class ScalarMagnitudeCalculator implements IMagnitudeCalculator
|
||||
{
|
||||
@Override
|
||||
public float[] calculate(float[] i, float[] q)
|
||||
{
|
||||
float[] magnitude = new float[i.length];
|
||||
|
||||
for(int x = 0; x < i.length; x++)
|
||||
{
|
||||
magnitude[x] = ((i[x] * i[x]) + (q[x] * q[x]));
|
||||
}
|
||||
|
||||
return magnitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.dsp.magnitude;
|
||||
|
||||
import io.github.dsheirer.vector.VectorUtilities;
|
||||
import jdk.incubator.vector.FloatVector;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
|
||||
/**
|
||||
* Vector implementation of magnitude calculation.
|
||||
*/
|
||||
public class VectorMagnitudeCalculator128 implements IMagnitudeCalculator
|
||||
{
|
||||
private static final VectorSpecies<Float> VECTOR_SPECIES = FloatVector.SPECIES_128;
|
||||
|
||||
@Override
|
||||
public float[] calculate(float[] i, float[] q)
|
||||
{
|
||||
VectorUtilities.checkComplexArrayLength(i, q, VECTOR_SPECIES);
|
||||
float[] magnitude = new float[i.length];
|
||||
|
||||
FloatVector iVector, qVector, result;
|
||||
for(int x = 0; x < i.length; x += VECTOR_SPECIES.length())
|
||||
{
|
||||
iVector = FloatVector.fromArray(VECTOR_SPECIES, i, x);
|
||||
qVector = FloatVector.fromArray(VECTOR_SPECIES, q, x);
|
||||
result = iVector.mul(iVector).add(qVector.mul(qVector));
|
||||
result.intoArray(magnitude, x);
|
||||
}
|
||||
|
||||
return magnitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.dsp.magnitude;
|
||||
|
||||
import io.github.dsheirer.vector.VectorUtilities;
|
||||
import jdk.incubator.vector.FloatVector;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
|
||||
/**
|
||||
* Vector implementation of magnitude calculation.
|
||||
*/
|
||||
public class VectorMagnitudeCalculator256 implements IMagnitudeCalculator
|
||||
{
|
||||
private static final VectorSpecies<Float> VECTOR_SPECIES = FloatVector.SPECIES_256;
|
||||
|
||||
@Override
|
||||
public float[] calculate(float[] i, float[] q)
|
||||
{
|
||||
VectorUtilities.checkComplexArrayLength(i, q, VECTOR_SPECIES);
|
||||
float[] magnitude = new float[i.length];
|
||||
|
||||
FloatVector iVector, qVector, result;
|
||||
for(int x = 0; x < i.length; x += VECTOR_SPECIES.length())
|
||||
{
|
||||
iVector = FloatVector.fromArray(VECTOR_SPECIES, i, x);
|
||||
qVector = FloatVector.fromArray(VECTOR_SPECIES, q, x);
|
||||
result = iVector.mul(iVector).add(qVector.mul(qVector));
|
||||
result.intoArray(magnitude, x);
|
||||
}
|
||||
|
||||
return magnitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.dsp.magnitude;
|
||||
|
||||
import io.github.dsheirer.vector.VectorUtilities;
|
||||
import jdk.incubator.vector.FloatVector;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
|
||||
/**
|
||||
* Vector implementation of magnitude calculation.
|
||||
*/
|
||||
public class VectorMagnitudeCalculator512 implements IMagnitudeCalculator
|
||||
{
|
||||
private static final VectorSpecies<Float> VECTOR_SPECIES = FloatVector.SPECIES_512;
|
||||
|
||||
@Override
|
||||
public float[] calculate(float[] i, float[] q)
|
||||
{
|
||||
VectorUtilities.checkComplexArrayLength(i, q, VECTOR_SPECIES);
|
||||
float[] magnitude = new float[i.length];
|
||||
|
||||
FloatVector iVector, qVector, result;
|
||||
for(int x = 0; x < i.length; x += VECTOR_SPECIES.length())
|
||||
{
|
||||
iVector = FloatVector.fromArray(VECTOR_SPECIES, i, x);
|
||||
qVector = FloatVector.fromArray(VECTOR_SPECIES, q, x);
|
||||
result = iVector.mul(iVector).add(qVector.mul(qVector));
|
||||
result.intoArray(magnitude, x);
|
||||
}
|
||||
|
||||
return magnitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.dsp.magnitude;
|
||||
|
||||
import io.github.dsheirer.vector.VectorUtilities;
|
||||
import jdk.incubator.vector.FloatVector;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
|
||||
/**
|
||||
* Vector implementation of magnitude calculation.
|
||||
*/
|
||||
public class VectorMagnitudeCalculator64 implements IMagnitudeCalculator
|
||||
{
|
||||
private static final VectorSpecies<Float> VECTOR_SPECIES = FloatVector.SPECIES_64;
|
||||
|
||||
@Override
|
||||
public float[] calculate(float[] i, float[] q)
|
||||
{
|
||||
VectorUtilities.checkComplexArrayLength(i, q, VECTOR_SPECIES);
|
||||
float[] magnitude = new float[i.length];
|
||||
|
||||
FloatVector iVector, qVector, result;
|
||||
for(int x = 0; x < i.length; x += VECTOR_SPECIES.length())
|
||||
{
|
||||
iVector = FloatVector.fromArray(VECTOR_SPECIES, i, x);
|
||||
qVector = FloatVector.fromArray(VECTOR_SPECIES, q, x);
|
||||
result = iVector.mul(iVector).add(qVector.mul(qVector));
|
||||
result.intoArray(magnitude, x);
|
||||
}
|
||||
|
||||
return magnitude;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user