mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 00:57:31 -05:00
Updates pull request from Roman Tsypuk to convert the build system from
ant to gradle. Removes linux and windows application launch scripts and produces an executable jar with all resources included.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package io.github.dsheirer.sample.decimator;
|
||||
|
||||
import io.github.dsheirer.sample.complex.ComplexSampleListener;
|
||||
|
||||
|
||||
public class ComplexDecimator implements ComplexSampleListener
|
||||
{
|
||||
private ComplexSampleListener mListener;
|
||||
private int mCounter = 0;
|
||||
private int mDecimationRate;
|
||||
|
||||
/**
|
||||
* Constructs a new Decimator object with the specified decimation rate.
|
||||
*/
|
||||
public ComplexDecimator( int rate )
|
||||
{
|
||||
mDecimationRate = rate;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new decimation rate. Rate can be changed after this object
|
||||
* is constructed.
|
||||
*/
|
||||
public synchronized void setDecimationRate( int rate )
|
||||
{
|
||||
mDecimationRate = rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives samples allowing only 1 of every (rate) sample to go on
|
||||
* to the registered listener
|
||||
*/
|
||||
@Override
|
||||
public void receive( float i, float q )
|
||||
{
|
||||
mCounter++;
|
||||
|
||||
if( mCounter >= mDecimationRate )
|
||||
{
|
||||
mListener.receive( i, q );
|
||||
|
||||
mCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the decimated output listener
|
||||
*/
|
||||
public void setListener( ComplexSampleListener listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*******************************************************************************
|
||||
* 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.sample.decimator;
|
||||
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
|
||||
public class Decimator<T> implements Listener<T>
|
||||
{
|
||||
private int mDecimationFactor;
|
||||
private int mDecimationPointer = 0;
|
||||
private Listener<T> mListener;
|
||||
|
||||
/**
|
||||
* Constructs the class to consume samples and decimate them by the
|
||||
* DECIMATIONFACTOR.
|
||||
*
|
||||
* @param decimationFactor - number of samples to decimate. Provides one
|
||||
* sample to registered listeners and discards the next decimationFactor - 1
|
||||
* samples.
|
||||
*/
|
||||
public Decimator( int decimationFactor )
|
||||
{
|
||||
mDecimationFactor = decimationFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives and broadcasts a sample and then discards the next
|
||||
* decimationFactor -1 samples
|
||||
*/
|
||||
public void receive( T t )
|
||||
{
|
||||
if( mDecimationPointer == 0 )
|
||||
{
|
||||
if( mListener != null )
|
||||
{
|
||||
mListener.receive( t );
|
||||
}
|
||||
}
|
||||
|
||||
mDecimationPointer++;
|
||||
|
||||
//Reset the decimation pointer once it equals the decimation factor
|
||||
if( mDecimationPointer == mDecimationFactor )
|
||||
{
|
||||
mDecimationPointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a sample listener to receive samples
|
||||
*/
|
||||
public void setListener( Listener<T> listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package io.github.dsheirer.sample.decimator;
|
||||
|
||||
import io.github.dsheirer.sample.real.RealSampleListener;
|
||||
|
||||
|
||||
public class RealDecimator implements RealSampleListener
|
||||
{
|
||||
private RealSampleListener mListener;
|
||||
private int mCounter = 0;
|
||||
private int mDecimationRate;
|
||||
|
||||
/**
|
||||
* Constructs a new Decimator object with the specified decimation rate.
|
||||
*/
|
||||
public RealDecimator( int rate )
|
||||
{
|
||||
mDecimationRate = rate;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new decimation rate. Rate can be changed after this object
|
||||
* is constructed.
|
||||
*/
|
||||
public synchronized void setDecimationRate( int rate )
|
||||
{
|
||||
mDecimationRate = rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives samples allowing only 1 of every (rate) sample to go on
|
||||
* to the registered listener
|
||||
*/
|
||||
@Override
|
||||
public void receive( float sample )
|
||||
{
|
||||
mCounter++;
|
||||
|
||||
if( mCounter >= mDecimationRate )
|
||||
{
|
||||
mListener.receive( sample );
|
||||
|
||||
mCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the decimated output listener
|
||||
*/
|
||||
public void setListener( RealSampleListener listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user