mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 17:17:29 -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:
112
src/main/java/io/github/dsheirer/dsp/symbol/Dibit.java
Normal file
112
src/main/java/io/github/dsheirer/dsp/symbol/Dibit.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package io.github.dsheirer.dsp.symbol;
|
||||
|
||||
public enum Dibit
|
||||
{
|
||||
D01_PLUS_3( false, true, 1, 4 ),
|
||||
D00_PLUS_1( false, false, 0, 0 ),
|
||||
D10_MINUS_1( true, false, 2, 8 ),
|
||||
D11_MINUS_3( true, true, 3, 12 );
|
||||
|
||||
private boolean mBit1;
|
||||
private boolean mBit2;
|
||||
private int mLowValue;
|
||||
private int mHighValue;
|
||||
|
||||
private Dibit( boolean bit1, boolean bit2, int lowValue, int highValue )
|
||||
{
|
||||
mBit1 = bit1;
|
||||
mBit2 = bit2;
|
||||
mLowValue = lowValue;
|
||||
mHighValue = highValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowable transition state 1 for trellis coded modulation. Indicates
|
||||
* the dibit that differs from this dibit in the LSB bit position.
|
||||
*/
|
||||
public Dibit getAllowableTransition1()
|
||||
{
|
||||
switch( this )
|
||||
{
|
||||
case D00_PLUS_1:
|
||||
return D01_PLUS_3;
|
||||
case D01_PLUS_3:
|
||||
return D00_PLUS_1;
|
||||
case D10_MINUS_1:
|
||||
return D11_MINUS_3;
|
||||
case D11_MINUS_3:
|
||||
return D10_MINUS_1;
|
||||
default:
|
||||
/* We'll never get here */
|
||||
return D00_PLUS_1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowable transition state 2 for trellis coded modulation. Indicates
|
||||
* the dibit that differs from this dibit in the MSB bit position.
|
||||
*/
|
||||
public Dibit getAllowableTransition2()
|
||||
{
|
||||
switch( this )
|
||||
{
|
||||
case D00_PLUS_1:
|
||||
return D10_MINUS_1;
|
||||
case D01_PLUS_3:
|
||||
return D11_MINUS_3;
|
||||
case D10_MINUS_1:
|
||||
return D00_PLUS_1;
|
||||
case D11_MINUS_3:
|
||||
return D01_PLUS_3;
|
||||
default:
|
||||
/* We'll never get here */
|
||||
return D00_PLUS_1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the trellis coded modulation dibit is allowed to transition
|
||||
* to the dibit argument.
|
||||
*/
|
||||
public boolean isAllowableTransition( Dibit dibit )
|
||||
{
|
||||
return dibit == getAllowableTransition1() ||
|
||||
dibit == getAllowableTransition2();
|
||||
}
|
||||
|
||||
public boolean getBit1()
|
||||
{
|
||||
return mBit1;
|
||||
}
|
||||
|
||||
public boolean getBit2()
|
||||
{
|
||||
return mBit2;
|
||||
}
|
||||
|
||||
public int getLowValue()
|
||||
{
|
||||
return mLowValue;
|
||||
}
|
||||
|
||||
public int getHighValue()
|
||||
{
|
||||
return mHighValue;
|
||||
}
|
||||
|
||||
public static Dibit inverted( Dibit symbol )
|
||||
{
|
||||
switch( symbol )
|
||||
{
|
||||
case D10_MINUS_1:
|
||||
return D11_MINUS_3;
|
||||
case D11_MINUS_3:
|
||||
return D01_PLUS_3;
|
||||
case D00_PLUS_1:
|
||||
return D10_MINUS_1;
|
||||
case D01_PLUS_3:
|
||||
default:
|
||||
return D00_PLUS_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
src/main/java/io/github/dsheirer/dsp/symbol/FrameSync.java
Normal file
21
src/main/java/io/github/dsheirer/dsp/symbol/FrameSync.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package io.github.dsheirer.dsp.symbol;
|
||||
|
||||
public enum FrameSync
|
||||
{
|
||||
P25_PHASE1_ERROR_90_CCW( 0xFFEFAFAAEEAAl ),
|
||||
P25_PHASE1_NORMAL( 0x5575F5FF77FFl ), // +33333 -3 +33 -33 +33 -3333 +3 -3 +3 -33333
|
||||
P25_PHASE1_ERROR_90_CW( 0x001050551155l ),
|
||||
P25_PHASE1_ERROR_180( 0xAA8A0A008800l );
|
||||
|
||||
private long mSync;
|
||||
|
||||
private FrameSync( long sync )
|
||||
{
|
||||
mSync = sync;
|
||||
}
|
||||
|
||||
public long getSync()
|
||||
{
|
||||
return mSync;
|
||||
}
|
||||
}
|
||||
149
src/main/java/io/github/dsheirer/dsp/symbol/Slicer.java
Normal file
149
src/main/java/io/github/dsheirer/dsp/symbol/Slicer.java
Normal file
@@ -0,0 +1,149 @@
|
||||
package io.github.dsheirer.dsp.symbol;
|
||||
|
||||
import io.github.dsheirer.instrument.tap.stream.SymbolEventTap;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
/**
|
||||
* Symbol slicer with auto-aligning baud timing
|
||||
*/
|
||||
public class Slicer implements Listener<Boolean>
|
||||
{
|
||||
public enum Output{ NORMAL, INVERTED };
|
||||
|
||||
private BitSet mBitSet = new BitSet();
|
||||
private int mSymbolLength;
|
||||
private int mDecisionThreshold;
|
||||
private int mSampleCounter;
|
||||
private SymbolEventTap mSymbolEventTap;
|
||||
|
||||
private boolean mNormalOutput = true;
|
||||
private Listener<Boolean> mListener;
|
||||
|
||||
public Slicer( Output output, int samplesPerSymbol )
|
||||
{
|
||||
mNormalOutput = ( output == Output.NORMAL );
|
||||
|
||||
mSymbolLength = samplesPerSymbol;
|
||||
|
||||
/* Round up */
|
||||
mDecisionThreshold = (int)( mSymbolLength / 2 ) + ( mSymbolLength % 2 );
|
||||
}
|
||||
|
||||
public void receive( Boolean sample )
|
||||
{
|
||||
if( mSampleCounter >= 0 )
|
||||
{
|
||||
if( sample )
|
||||
{
|
||||
mBitSet.set( mSampleCounter );
|
||||
}
|
||||
else
|
||||
{
|
||||
mBitSet.clear( mSampleCounter );
|
||||
}
|
||||
}
|
||||
|
||||
mSampleCounter++;
|
||||
|
||||
if( mSampleCounter >= mSymbolLength )
|
||||
{
|
||||
boolean decision = mBitSet.cardinality() >= mDecisionThreshold;
|
||||
|
||||
send( decision );
|
||||
|
||||
/* Shift timing left if the left bit in the bitset is opposite
|
||||
* the decision and the right bit is the same */
|
||||
if( ( mBitSet.get( 0 ) ^ decision ) &&
|
||||
( !( mBitSet.get( mSymbolLength - 1 ) ^ decision ) ) )
|
||||
{
|
||||
sendTapEvent( mBitSet, SymbolEvent.Shift.LEFT, decision );
|
||||
|
||||
reset();
|
||||
|
||||
mSampleCounter--;
|
||||
}
|
||||
/* Shift timing right if the left bit is the same as the
|
||||
* decision and the right bit is opposite */
|
||||
else if( ( !( mBitSet.get( 0 ) ^ decision ) ) &&
|
||||
( mBitSet.get( mSymbolLength - 1 ) ^ decision ) )
|
||||
{
|
||||
sendTapEvent( mBitSet, SymbolEvent.Shift.RIGHT, decision );
|
||||
|
||||
/* Last bit from previous symbol to pre-fill next symbol */
|
||||
boolean previousSoftBit = mBitSet.get( mSymbolLength - 1 );
|
||||
|
||||
reset();
|
||||
|
||||
if( previousSoftBit )
|
||||
{
|
||||
mBitSet.set( 0 );
|
||||
}
|
||||
|
||||
mSampleCounter++;
|
||||
}
|
||||
/* No shift */
|
||||
else
|
||||
{
|
||||
sendTapEvent( mBitSet, SymbolEvent.Shift.NONE, decision );
|
||||
|
||||
reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the bit decision to the listener
|
||||
*/
|
||||
private void send( boolean decision )
|
||||
{
|
||||
if( mListener != null )
|
||||
{
|
||||
mListener.receive( mNormalOutput ? decision : !decision );
|
||||
}
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
mBitSet.clear();
|
||||
mSampleCounter = 0;
|
||||
}
|
||||
|
||||
public void setListener( Listener<Boolean> listener)
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void removeListener( Listener<Boolean> listener )
|
||||
{
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends instrumentation tap event to all registered listeners
|
||||
*/
|
||||
private void sendTapEvent(BitSet bitset, SymbolEvent.Shift shift, boolean decision )
|
||||
{
|
||||
if( mSymbolEventTap != null )
|
||||
{
|
||||
SymbolEvent event =
|
||||
new SymbolEvent( bitset.get( 0, mSymbolLength ),
|
||||
mSymbolLength,
|
||||
decision,
|
||||
shift );
|
||||
|
||||
mSymbolEventTap.receive( event );
|
||||
}
|
||||
}
|
||||
|
||||
public void addTap( SymbolEventTap tap )
|
||||
{
|
||||
mSymbolEventTap = tap;
|
||||
}
|
||||
|
||||
public void removeTap()
|
||||
{
|
||||
mSymbolEventTap = null;
|
||||
}
|
||||
}
|
||||
77
src/main/java/io/github/dsheirer/dsp/symbol/SymbolEvent.java
Normal file
77
src/main/java/io/github/dsheirer/dsp/symbol/SymbolEvent.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*******************************************************************************
|
||||
* 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.dsp.symbol;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
public class SymbolEvent
|
||||
{
|
||||
private BitSet mBitset;
|
||||
private int mSamplesPerSymbol;
|
||||
private boolean mDecision;
|
||||
private Shift mShift;
|
||||
|
||||
public SymbolEvent( BitSet bitset, int samplesPerSymbol, boolean decision, Shift shift )
|
||||
{
|
||||
mBitset = bitset;
|
||||
mSamplesPerSymbol = samplesPerSymbol;
|
||||
mDecision = decision;
|
||||
mShift = shift;
|
||||
}
|
||||
|
||||
public BitSet getBitSet()
|
||||
{
|
||||
return mBitset;
|
||||
}
|
||||
|
||||
public int getSamplesPerSymbol()
|
||||
{
|
||||
return mSamplesPerSymbol;
|
||||
}
|
||||
|
||||
public boolean getDecision()
|
||||
{
|
||||
return mDecision;
|
||||
}
|
||||
|
||||
public Shift getShift()
|
||||
{
|
||||
return mShift;
|
||||
}
|
||||
|
||||
public enum Shift
|
||||
{
|
||||
LEFT( "<" ),
|
||||
AGGRESSIVE_LEFT( "<<" ),
|
||||
RIGHT( ">" ),
|
||||
AGGRESSIVE_RIGHT( ">>" ),
|
||||
NONE( "=" );
|
||||
|
||||
private String mLabel;
|
||||
|
||||
private Shift( String label )
|
||||
{
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* 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.dsp.symbol;
|
||||
|
||||
/**
|
||||
* Interface to allow an external process indicate that it has detected a
|
||||
* sync pattern in the bit stream
|
||||
*/
|
||||
public interface SyncDetectListener
|
||||
{
|
||||
public void syncDetected();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* 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.dsp.symbol;
|
||||
|
||||
|
||||
public interface SyncDetectProvider
|
||||
{
|
||||
public void setSyncDetectListener( SyncDetectListener listener );
|
||||
}
|
||||
Reference in New Issue
Block a user