mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 00:57:31 -05:00
Resolves 1122. Adds decimation to NBFMDecoder so that channel bandwidth is reduced to min sample rate needed. This reduces the impact on channel power measurement from adjacent channels. (#1129)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 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
|
||||
@@ -15,7 +14,7 @@
|
||||
*
|
||||
* 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.filter.channelizer;
|
||||
|
||||
@@ -40,6 +39,7 @@ public class PolyphaseChannelSource extends TunerChannelSource
|
||||
{
|
||||
// private final static Logger mLog = LoggerFactory.getLogger(PolyphaseChannelSource.class);
|
||||
|
||||
private static final int PROCESSED_BUFFER_SAMPLE_SIZE = 2048;
|
||||
private ReusableComplexBufferAssembler mReusableComplexBufferAssembler;
|
||||
private IPolyphaseChannelOutputProcessor mPolyphaseChannelOutputProcessor;
|
||||
private IPolyphaseChannelOutputProcessor mReplacementPolyphaseChannelOutputProcessor;
|
||||
@@ -71,7 +71,7 @@ public class PolyphaseChannelSource extends TunerChannelSource
|
||||
super(producerSourceEventListener, tunerChannel);
|
||||
mPolyphaseChannelOutputProcessor = outputProcessor;
|
||||
mChannelSampleRate = channelSampleRate;
|
||||
mReusableComplexBufferAssembler = new ReusableComplexBufferAssembler(2500, mChannelSampleRate);
|
||||
mReusableComplexBufferAssembler = new ReusableComplexBufferAssembler(PROCESSED_BUFFER_SAMPLE_SIZE, mChannelSampleRate);
|
||||
|
||||
float[] filterCoefficients = getLowPassFilter(channelSampleRate, channelSpecification.getPassFrequency(),
|
||||
channelSpecification.getStopFrequency());
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 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.filter.decimate;
|
||||
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBuffer;
|
||||
|
||||
/**
|
||||
* No decimation filter.
|
||||
*/
|
||||
public class ComplexDecimateX0Filter implements IComplexDecimationFilter
|
||||
{
|
||||
@Override
|
||||
public float[] decimateComplex(float[] samples)
|
||||
{
|
||||
return samples;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReusableComplexBuffer decimate(ReusableComplexBuffer buffer)
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2021 Dennis Sheirer
|
||||
* Copyright (C) 2014-2022 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
|
||||
@@ -24,7 +24,7 @@ package io.github.dsheirer.dsp.filter.decimate;
|
||||
*/
|
||||
public class DecimationFilterFactory
|
||||
{
|
||||
private static final int[] SUPPORTED_RATES = new int[]{2,4,8,16,32,64,128,256,512,1024};
|
||||
private static final int[] SUPPORTED_RATES = new int[]{0,2,4,8,16,32,64,128,256,512,1024};
|
||||
|
||||
/**
|
||||
* Creates a real-valued decimation filter for float array sample buffers providing greater than 100 dB of
|
||||
@@ -37,6 +37,8 @@ public class DecimationFilterFactory
|
||||
{
|
||||
switch(decimationRate)
|
||||
{
|
||||
case 0:
|
||||
return new RealDecimateX0Filter();
|
||||
case 2:
|
||||
return new RealDecimateX2Filter();
|
||||
case 4:
|
||||
@@ -74,6 +76,8 @@ public class DecimationFilterFactory
|
||||
{
|
||||
switch(decimationRate)
|
||||
{
|
||||
case 0:
|
||||
return new ComplexDecimateX0Filter();
|
||||
case 2:
|
||||
return new ComplexDecimateX2Filter();
|
||||
case 4:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2021 Dennis Sheirer
|
||||
* Copyright (C) 2014-2022 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
|
||||
@@ -19,10 +19,24 @@
|
||||
|
||||
package io.github.dsheirer.dsp.filter.decimate;
|
||||
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBuffer;
|
||||
|
||||
/**
|
||||
* Interface for a decimation filter for float array sample buffers
|
||||
*/
|
||||
public interface IComplexDecimationFilter
|
||||
{
|
||||
/**
|
||||
* Decimates an array of float complex samples
|
||||
* @param samples to decimate
|
||||
* @return decimated samples
|
||||
*/
|
||||
float[] decimateComplex(float[] samples);
|
||||
|
||||
/**
|
||||
* Decimates an buffer of float complex samples
|
||||
* @param buffer to decimate
|
||||
* @return decimated samples
|
||||
*/
|
||||
ReusableComplexBuffer decimate(ReusableComplexBuffer buffer);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 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.filter.decimate;
|
||||
|
||||
/**
|
||||
* No decimation filter.
|
||||
*/
|
||||
public class RealDecimateX0Filter implements IRealDecimationFilter
|
||||
{
|
||||
@Override
|
||||
public float[] decimateReal(float[] samples)
|
||||
{
|
||||
return samples;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2021 Dennis Sheirer
|
||||
* Copyright (C) 2014-2022 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
|
||||
@@ -20,6 +20,8 @@
|
||||
package io.github.dsheirer.dsp.filter.halfband.complex;
|
||||
|
||||
import io.github.dsheirer.dsp.filter.decimate.IComplexDecimationFilter;
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBuffer;
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBufferQueue;
|
||||
|
||||
/**
|
||||
* Complex half-band filter that processes samples on a per-array basis, versus a per-sample basis.
|
||||
@@ -35,6 +37,7 @@ public class ComplexHalfBandDecimationFilter implements IComplexDecimationFilter
|
||||
private int mCoefficientsLengthMinus2;
|
||||
private int mBufferPointer;
|
||||
private int mHalf;
|
||||
private ReusableComplexBufferQueue mReusableComplexBufferQueue = new ReusableComplexBufferQueue("half-band decimation filter");
|
||||
|
||||
/**
|
||||
* Constructs a complex sample half-band decimate x2 filter using the specified filter coefficients.
|
||||
@@ -118,4 +121,17 @@ public class ComplexHalfBandDecimationFilter implements IComplexDecimationFilter
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decimates the complex samples and returns a buffer of decimated samples.
|
||||
* @param buffer to decimate
|
||||
* @return decimated buffer.
|
||||
*/
|
||||
@Override
|
||||
public ReusableComplexBuffer decimate(ReusableComplexBuffer buffer)
|
||||
{
|
||||
float[] decimated = decimateComplex(buffer.getSamples());
|
||||
buffer.decrementUserCount();
|
||||
return mReusableComplexBufferQueue.getBuffer(decimated, buffer.getTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user