mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Merge branch 'master' into 39-polyphase-channelizer
# Conflicts: # .idea/dictionaries/denny.xml # .idea/libraries/imports.xml # sdrtrunk.iml # src/audio/AudioModule.java # src/audio/broadcast/StreamManager.java # src/buffer/FloatCircularBuffer.java # src/channel/state/AlwaysUnsquelchedDecoderState.java # src/channel/state/ChannelState.java # src/channel/state/DecoderState.java # src/channel/traffic/TrafficChannelManager.java # src/controller/channel/Channel.java # src/dsp/filter/FilterFactory.java # src/dsp/filter/Window.java # src/dsp/filter/design/FilterView.java # src/dsp/filter/design/FilterViewer.java # src/dsp/filter/fir/FIRFilterSpecification.java # src/dsp/filter/fir/remez/RemezFIRFilterDesigner.java # src/dsp/gain/AutomaticGainControl.java # src/dsp/gain/ComplexFeedForwardGainControl.java # src/dsp/mixer/Oscillator.java # src/dsp/psk/LSMDemodulator.java # src/gui/control/JFrequencyControl.java # src/instrument/tap/stream/BinaryTapViewPanel.java # src/module/Module.java # src/module/ProcessingChain.java # src/module/decode/Decoder.java # src/module/decode/am/AMDecoder.java # src/module/decode/fleetsync2/Fleetsync2Decoder.java # src/module/decode/fleetsync2/Fleetsync2DecoderState.java # src/module/decode/lj1200/LJ1200Decoder.java # src/module/decode/lj1200/LJ1200DecoderState.java # src/module/decode/ltrnet/LTRNetDecoder.java # src/module/decode/ltrnet/LTRNetDecoderState.java # src/module/decode/ltrstandard/LTRStandardDecoder.java # src/module/decode/ltrstandard/LTRStandardDecoderState.java # src/module/decode/mdc1200/MDCDecoder.java # src/module/decode/mdc1200/MDCDecoderState.java # src/module/decode/mpt1327/MPT1327Decoder.java # src/module/decode/mpt1327/MPT1327DecoderState.java # src/module/decode/nbfm/NBFMDecoder.java # src/module/decode/p25/C4FMSymbolFilter.java # src/module/decode/p25/P25Decoder.java # src/module/decode/p25/P25DecoderState.java # src/module/decode/p25/P25_C4FMDecoder.java # src/module/decode/p25/P25_LSMDecoder.java # src/module/decode/p25/audio/P25AudioModule.java # src/module/decode/passport/PassportDecoder.java # src/module/decode/passport/PassportDecoderState.java # src/module/decode/tait/Tait1200Decoder.java # src/module/decode/tait/Tait1200DecoderState.java # src/module/demodulate/am/AMDemodulatorModule.java # src/module/demodulate/audio/DemodulatedAudioFilterModule.java # src/module/demodulate/fm/FMDemodulatorModule.java # src/module/log/EventLogger.java # src/record/AudioRecorder.java # src/record/RecorderManager.java # src/record/wave/ComplexBufferWaveRecorder.java # src/record/wave/RealBufferWaveRecorder.java # src/sample/Broadcaster.java # src/sample/OverflowableTransferQueue.java # src/sample/SampleType.java # src/source/ComplexSource.java # src/source/ISourceEventProvider.java # src/source/InvalidFrequencyException.java # src/source/RealSource.java # src/source/Source.java # src/source/config/SourceConfigRecording.java # src/source/config/SourceConfigTuner.java # src/source/heartbeat/Heartbeat.java # src/source/heartbeat/IHeartbeatListener.java # src/source/heartbeat/IHeartbeatProvider.java # src/source/mixer/RealMixerSource.java # src/source/recording/Recording.java # src/source/recording/RecordingSourceManager.java # src/source/tuner/ITunerChannelProvider.java # src/source/tuner/Tuner.java # src/source/tuner/TunerClass.java # src/source/tuner/TunerController.java # src/source/tuner/TunerEditor.java # src/source/tuner/TunerManager.java # src/source/tuner/TunerModel.java # src/source/tuner/TunerSourceEditor.java # src/source/tuner/TunerType.java # src/source/tuner/airspy/AirspyTuner.java # src/source/tuner/airspy/AirspyTunerController.java # src/source/tuner/airspy/AirspyTunerEditor.java # src/source/tuner/configuration/TunerConfigurationModel.java # src/source/tuner/fcd/FCDTuner.java # src/source/tuner/fcd/FCDTunerController.java # src/source/tuner/fcd/proV1/FCD1TunerController.java # src/source/tuner/fcd/proV1/FCD1TunerEditor.java # src/source/tuner/fcd/proplusV2/FCD2TunerController.java # src/source/tuner/fcd/proplusV2/FCD2TunerEditor.java # src/source/tuner/hackrf/HackRFTuner.java # src/source/tuner/hackrf/HackRFTunerController.java # src/source/tuner/hackrf/HackRFTunerEditor.java # src/source/tuner/rtl/RTL2832Tuner.java # src/source/tuner/rtl/RTL2832TunerController.java # src/source/tuner/rtl/e4k/E4KTunerController.java # src/source/tuner/rtl/e4k/E4KTunerEditor.java # src/source/tuner/rtl/r820t/R820TTunerController.java # src/source/tuner/rtl/r820t/R820TTunerEditor.java # src/source/tuner/usb/USBTransferProcessor.java # src/source/wave/ComplexWaveSource.java # src/source/wave/RealWaveSource.java # src/spectrum/ChannelSpectrumPanel.java # src/spectrum/DFTProcessor.java # src/spectrum/OverlayPanel.java # src/spectrum/SpectralDisplayPanel.java
This commit is contained in:
@@ -1,107 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 buffer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* Circular Buffer - implements a circular buffer with a method to get the
|
||||
* current head of the buffer, and put a new value in its place at the same
|
||||
* time
|
||||
*
|
||||
* Also provides averaging over the elements in the buffer
|
||||
*/
|
||||
public class BooleanAveragingBuffer {
|
||||
|
||||
private boolean[] mBuffer;
|
||||
private int mBufferPointer;
|
||||
|
||||
public BooleanAveragingBuffer( int length )
|
||||
{
|
||||
mBuffer = new boolean[ length ];
|
||||
|
||||
//Preload the array with false values
|
||||
Arrays.fill( mBuffer, false );
|
||||
}
|
||||
|
||||
public boolean get( boolean newValue )
|
||||
{
|
||||
//Fetch current boolean value
|
||||
boolean retVal = mBuffer[ mBufferPointer ];
|
||||
|
||||
//Load the new value into the buffer
|
||||
put( newValue );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the newValue into this buffer and adjusts the buffer pointer
|
||||
* to prepare for the next get/put cycle
|
||||
*/
|
||||
private void put( boolean newValue )
|
||||
{
|
||||
//Store the new value to the buffer
|
||||
mBuffer[ mBufferPointer ] = newValue;
|
||||
|
||||
//Increment the buffer pointer
|
||||
mBufferPointer++;
|
||||
|
||||
//Wrap the buffer pointer around to 0 when necessary
|
||||
if( mBufferPointer >= mBuffer.length )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the newValue into the buffer, calculates the average
|
||||
* and returns that average from this method
|
||||
*
|
||||
* This effectively performs low-pass filtering
|
||||
*/
|
||||
public boolean getAverage( boolean newValue )
|
||||
{
|
||||
//Load the new value into the buffer
|
||||
put( newValue );
|
||||
|
||||
int trueCount = 0;
|
||||
|
||||
for( int x = 0; x < mBuffer.length; x++ )
|
||||
{
|
||||
if( mBuffer[ x ] )
|
||||
{
|
||||
trueCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the number of true values in the buffer is
|
||||
* more than half, return true, otherwise, false
|
||||
*/
|
||||
if( trueCount > (int)( mBuffer.length / 2 ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package buffer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import sample.Listener;
|
||||
|
||||
public class CircularBuffer<T> implements Listener<T>
|
||||
{
|
||||
private ArrayList<T> mElements;
|
||||
private Listener<T> mListener;
|
||||
private int mPointer;
|
||||
private int mSize;
|
||||
|
||||
|
||||
/**
|
||||
* Circular Buffer - stores elements in an array list. Once the buffer is
|
||||
* full, new samples replace older samples and older samples are broadcast
|
||||
* to an optional listener.
|
||||
*
|
||||
* @param size - size of buffer
|
||||
*/
|
||||
public CircularBuffer( int size )
|
||||
{
|
||||
mSize = size;
|
||||
mElements = new ArrayList<T>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the element stored at index. Note: the index argument refers to
|
||||
* the internal storage index and does not indicate a temporal relationship
|
||||
* among elements. For example, if you get indexes 1, 2, and 3, you may be
|
||||
* getting ( oldest - 1, oldest, newest ) elements, if the internal pointer
|
||||
* is currently pointing to and will insert the next element at index 4.
|
||||
*
|
||||
* @param index - element index
|
||||
*
|
||||
* @return element or null
|
||||
*/
|
||||
public T get( int index )
|
||||
{
|
||||
if( index < mElements.size() )
|
||||
{
|
||||
return mElements.get( index );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return mSize;
|
||||
}
|
||||
|
||||
public List<T> getElements()
|
||||
{
|
||||
return Collections.unmodifiableList( mElements );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( T element )
|
||||
{
|
||||
T previous = null;
|
||||
|
||||
if( mElements.size() > mPointer )
|
||||
{
|
||||
previous = mElements.get( mPointer );
|
||||
|
||||
mElements.set( mPointer, element );
|
||||
}
|
||||
else
|
||||
{
|
||||
mElements.add( element );
|
||||
}
|
||||
|
||||
mPointer++;
|
||||
|
||||
if( mPointer >= mSize )
|
||||
{
|
||||
mPointer = 0;
|
||||
}
|
||||
|
||||
if( previous != null && mListener != null )
|
||||
{
|
||||
mListener.receive( previous );
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener( Listener<T> listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 buffer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import sample.complex.Complex;
|
||||
|
||||
/**
|
||||
* 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 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ];
|
||||
|
||||
put( sample );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public void put( Complex sample )
|
||||
{
|
||||
mBuffer[ mBufferPointer ] = sample;
|
||||
|
||||
mBufferPointer++;
|
||||
|
||||
if( mBufferPointer >= mBuffer.length )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 buffer;
|
||||
|
||||
import sample.complex.Complex;
|
||||
|
||||
/**
|
||||
* Implements a FIFO circular buffer for complex samples that provides access
|
||||
* to each complex sample by index number, where index 0 is the newest/latest
|
||||
* complex sample and index (length - 1) is the oldest sample in the buffer.
|
||||
*/
|
||||
public class ComplexTappedCircularBuffer
|
||||
{
|
||||
private Complex[] mBuffer;
|
||||
private int mBufferPointer = 0;
|
||||
|
||||
public ComplexTappedCircularBuffer( int length )
|
||||
{
|
||||
mBuffer = new Complex[ length ];
|
||||
|
||||
//Pre-load the buffer with 0-valued samples
|
||||
for( int x = 0; x < length; x++ )
|
||||
{
|
||||
mBuffer[ x ] = new Complex( 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the sample to the buffer and removes the oldest sample
|
||||
* @param sample
|
||||
*/
|
||||
public void add( Complex sample )
|
||||
{
|
||||
mBuffer[ mBufferPointer++ ] = sample;
|
||||
|
||||
//Reset the buffer pointer once it points past the end of the buffer
|
||||
if( mBufferPointer >= mBuffer.length )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a sample currently in the buffer by index position.
|
||||
*
|
||||
* Index 0 is the newest/latest sample in the buffer and index (length - 1)
|
||||
* is the oldest.
|
||||
*
|
||||
* Note: the buffer is preloaded with complex samples of 0,0 value.
|
||||
*
|
||||
* @param index where 0 is the newest/latest sample and length-1 is the oldest
|
||||
* @return complex sample from the buffer.
|
||||
* @throws ArrayIndexOutOfBoundsException if you attempt to access a sample
|
||||
* outside of the buffer size
|
||||
*/
|
||||
public Complex get( int index )
|
||||
{
|
||||
/* Since the samples are stored in a forward fashion, we have to access
|
||||
* the samples in reverse to comply with the access contract, where
|
||||
* index 0 is the newest and index (length -1) is the oldest, all
|
||||
* relative to the current buffer pointer */
|
||||
|
||||
int pointer = mBuffer.length - 1 + mBufferPointer - index;
|
||||
|
||||
if( pointer >= mBuffer.length )
|
||||
{
|
||||
pointer -= mBuffer.length;
|
||||
}
|
||||
|
||||
return mBuffer[ pointer ];
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 buffer;
|
||||
|
||||
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 DoubleCircularBuffer
|
||||
{
|
||||
double[] mBuffer;
|
||||
int mBufferPointer = 0;
|
||||
|
||||
public DoubleCircularBuffer( int size )
|
||||
{
|
||||
mBuffer = new double[ size ];
|
||||
|
||||
Arrays.fill( mBuffer, 0.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 ];
|
||||
|
||||
mBuffer[ mBufferPointer ] = newValue;
|
||||
|
||||
mBufferPointer++;
|
||||
|
||||
if( mBufferPointer >= mBuffer.length )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
|
||||
return oldestSample;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 buffer;
|
||||
|
||||
public class FloatAveragingBuffer
|
||||
{
|
||||
private float[] mBuffer;
|
||||
private float mAverage = 0.0f;
|
||||
private int mBufferSize;
|
||||
private int mBufferPointer;
|
||||
|
||||
public FloatAveragingBuffer( int size )
|
||||
{
|
||||
mBufferSize = size;
|
||||
mBuffer = new float[ size ];
|
||||
}
|
||||
|
||||
public float get( float newValue )
|
||||
{
|
||||
float oldValue = mBuffer[ mBufferPointer ];
|
||||
|
||||
if( Float.isInfinite( newValue ) || Float.isNaN( newValue ) )
|
||||
{
|
||||
mAverage = mAverage - ( oldValue / mBufferSize );
|
||||
|
||||
mBuffer[ mBufferPointer++ ] = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
mAverage = mAverage - ( oldValue / mBufferSize ) + ( newValue / mBufferSize );
|
||||
|
||||
mBuffer[ mBufferPointer++ ] = newValue;
|
||||
}
|
||||
|
||||
if( mBufferPointer >= mBufferSize )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
|
||||
return mAverage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user