Merge branch 'master' into 39-polyphase-channelizer

# Conflicts:
#	src/main/java/io/github/dsheirer/buffer/FloatCircularBuffer.java
#	src/main/java/io/github/dsheirer/dsp/filter/FilterFactory.java
#	src/main/java/io/github/dsheirer/dsp/filter/design/FilterView.java
#	src/main/java/io/github/dsheirer/dsp/filter/design/FilterViewer.java
#	src/main/java/io/github/dsheirer/dsp/filter/fir/complex/ComplexFIRFilter.java
#	src/main/java/io/github/dsheirer/dsp/gain/ComplexFeedForwardGainControl.java
#	src/main/java/io/github/dsheirer/dsp/mixer/Oscillator.java
#	src/main/java/io/github/dsheirer/dsp/psk/LSMDemodulator.java
#	src/main/java/io/github/dsheirer/module/decode/Decoder.java
#	src/main/java/io/github/dsheirer/module/decode/DecoderFactory.java
#	src/main/java/io/github/dsheirer/module/decode/p25/P25Decoder.java
#	src/main/java/io/github/dsheirer/module/decode/p25/P25_C4FMDecoder.java
#	src/main/java/io/github/dsheirer/module/decode/p25/P25_LSMDecoder.java
#	src/main/java/io/github/dsheirer/source/tuner/TunerChannelSource.java
#	src/main/java/io/github/dsheirer/source/tuner/TunerModel.java
#	src/main/java/io/github/dsheirer/source/tuner/TunerSourceEditor.java
#	src/main/java/io/github/dsheirer/spectrum/ChannelSpectrumPanel.java
This commit is contained in:
Denny
2018-03-18 05:19:33 -04:00
89 changed files with 7253 additions and 2885 deletions

View File

@@ -1,17 +1,17 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 Dennis Sheirer
*
* Copyright (C) 2014-2018 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/>
******************************************************************************/
@@ -25,66 +25,83 @@ import java.util.Arrays;
* Circular sample buffer - allocates a buffer and stores samples in a circular
* fashion, overwriting older samples with newly arrived samples. Initially
* fills buffer with 0-valued samples
*
*
* Can be used as a delay-type buffer, to delay samples by the 'size' amount
*/
public class ComplexCircularBuffer
{
Complex[] mBuffer;
int mBufferPointer = 0;
public ComplexCircularBuffer( int size )
{
mBuffer = new Complex[ size ];
Arrays.fill( mBuffer, new Complex( 1.0f, 1.0f ) );
}
Complex[] mBuffer;
int mBufferPointer = 0;
/**
* Returns the sample currently pointed to in the buffer and stores the
* new sample in its place
* @param sample
* @return
*/
public Complex get( Complex sample )
{
Complex retVal = mBuffer[ mBufferPointer ];
public ComplexCircularBuffer(int size)
{
mBuffer = new Complex[size];
put( sample );
Arrays.fill(mBuffer, new Complex(1.0f, 1.0f));
}
return retVal;
}
public void put( Complex sample )
{
mBuffer[ mBufferPointer ] = sample;
public int length()
{
return mBuffer.length;
}
mBufferPointer++;
if( mBufferPointer >= mBuffer.length )
{
mBufferPointer = 0;
}
}
public Complex[] get( int count )
{
Complex[] samples = new Complex[ count ];
int tempCounter = mBufferPointer;
/**
* Returns the sample currently pointed to in the buffer and stores the
* new sample in its place
*
* @param sample
* @return
*/
public Complex get(Complex sample)
{
Complex retVal = mBuffer[mBufferPointer];
for( int x = 0; x < count; x++ )
{
samples[ x ] = mBuffer[ tempCounter ];
tempCounter++;
if( tempCounter > mBuffer.length - 1 )
{
tempCounter = 0;
}
}
return samples;
}
put(sample);
return retVal;
}
public void put(Complex sample)
{
mBuffer[mBufferPointer] = sample;
mBufferPointer++;
if(mBufferPointer >= mBuffer.length)
{
mBufferPointer = 0;
}
}
/**
* Returns the (count) oldest samples in a time ordered array
*/
public Complex[] get(int count)
{
Complex[] samples = new Complex[count];
int tempCounter = mBufferPointer;
for(int x = 0; x < count; x++)
{
samples[x] = mBuffer[tempCounter];
tempCounter++;
if(tempCounter > mBuffer.length - 1)
{
tempCounter = 0;
}
}
return samples;
}
/**
* Returns the samples in a time-ordered array
*/
public Complex[] getAll()
{
return get(length());
}
}

View File

@@ -1,80 +1,180 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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.buffer;
import org.apache.commons.math3.stat.descriptive.moment.Mean;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
import org.apache.commons.math3.stat.descriptive.moment.Variance;
import org.apache.commons.math3.stat.descriptive.rank.Max;
import org.apache.commons.math3.stat.descriptive.rank.Min;
import java.util.Arrays;
/**
* Circular sample buffer - allocates a buffer and stores samples in a circular
* fashion, overwriting older samples with newly arrived samples. Initially
* fills buffer with 0-valued samples
*
* Can be used as a delay-type buffer, to delay samples by the 'size' amount
* Circular sample buffer - allocates a buffer and stores samples in a circular fashion, overwriting older samples with
* newly arrived samples. Initially fills buffer with 0-valued (default) samples or with a specified value.
*/
public class DoubleCircularBuffer
{
double[] mBuffer;
int mBufferPointer = 0;
public DoubleCircularBuffer( int size )
{
mBuffer = new double[ size ];
Arrays.fill( mBuffer, 0.0 );
}
private StandardDeviation mStandardDeviation;
private Variance mVariance;
private Max mMax;
private Mean mMean;
private Min mMin;
private double[] mBuffer;
private int mBufferPointer = 0;
/**
* Puts the new value into the buffer and returns the oldest buffer value
* that it replaced
* @param newValue
* @return
*/
public double get( double newValue )
{
double oldestSample = mBuffer[ mBufferPointer ];
/**
* Creates a circular double buffer of the specified size and all entries filled with the specified initial value.
* @param size of the buffer
* @param initialFillValue to fill the buffer entries
*/
public DoubleCircularBuffer(int size, double initialFillValue)
{
mBuffer = new double[size];
Arrays.fill(mBuffer, initialFillValue);
}
mBuffer[ mBufferPointer ] = newValue;
mBufferPointer++;
if( mBufferPointer >= mBuffer.length )
{
mBufferPointer = 0;
}
return oldestSample;
}
/**
* Creates a circular double buffer of the specified size and all entries filled with an initial value of zero.
* @param size of the buffer
*/
public DoubleCircularBuffer(int size)
{
this(size, 0.0);
}
/**
* Returns the maximum from the values currently in the buffer
*/
public double max()
{
double max = 0.0d;
for( int x = 0; x < mBuffer.length; x++ )
{
if( mBuffer[ x ] > max )
{
max = mBuffer[ x ];
}
}
return max;
}
/**
* Puts the new value into the buffer and returns the oldest buffer value that it replaced
*
* @param newValue to add to the buffer
* @return oldest value that was overwritten by the new value
*/
public double get(double newValue)
{
double oldestSample = mBuffer[mBufferPointer];
mBuffer[mBufferPointer] = newValue;
mBufferPointer++;
if(mBufferPointer >= mBuffer.length)
{
mBufferPointer = 0;
}
return oldestSample;
}
public double[] getAll()
{
int valuePointer = 0;
double[] values = new double[mBuffer.length];
int bufferPointer = mBufferPointer;
while(valuePointer < values.length)
{
values[valuePointer++] = mBuffer[bufferPointer++];
if(bufferPointer >= mBuffer.length)
{
bufferPointer = 0;
}
}
return values;
}
/**
* Places the new value into the buffer, overwriting the oldest value
* @param newValue to add to the buffer
*/
public void put(double newValue)
{
mBuffer[mBufferPointer] = newValue;
mBufferPointer++;
if(mBufferPointer >= mBuffer.length)
{
mBufferPointer = 0;
}
}
/**
* Returns the maximum from the values currently in the buffer
*/
public double max()
{
if(mMax == null)
{
mMax = new Max();
}
return mMax.evaluate(mBuffer, 0, mBuffer.length);
}
/**
* Returns the minimum from the values currently in the buffer
*/
public double min()
{
if(mMin == null)
{
mMin = new Min();
}
return mMin.evaluate(mBuffer, 0, mBuffer.length);
}
public double standardDeviation()
{
if(mStandardDeviation == null)
{
mStandardDeviation = new StandardDeviation();
}
return mStandardDeviation.evaluate(mBuffer);
}
/**
* Calculates the variance of the values contained in this buffer
*/
public double variance()
{
if(mVariance == null)
{
mVariance = new Variance();
}
return mVariance.evaluate(mBuffer);
}
/**
* Calculates the average/mean of the values contained in this buffer
*/
public double mean()
{
if(mMean == null)
{
mMean = new Mean();
}
return mMean.evaluate(mBuffer, 0, mBuffer.length);
}
}