Changes audio module decimation filter from lowpass to bandpass so that we can remove 0-250 Hz and any LTR signalling from the audio output.

This commit is contained in:
Denny
2016-08-21 07:21:38 -04:00
parent 3af4b953f4
commit d466ec9f5e
5 changed files with 745 additions and 735 deletions

View File

@@ -46,15 +46,15 @@ public class AudioModule extends Module implements IAudioPacketProvider,
static static
{ {
FIRFilterSpecification specification = FIRFilterSpecification.lowPassBuilder() //Band-pass filter to both decimate (48kHz to 8kHz) and block 0 - 300 Hz (LTR signalling).
.sampleRate(48000) FIRFilterSpecification specification = FIRFilterSpecification.bandPassBuilder()
.gridDensity(16) .sampleRate( 48000 )
.passBandCutoff(3000) .stopFrequency1( 150 )
.passBandAmplitude(1.0) .passFrequencyBegin( 300 )
.passBandRipple(0.01) .passFrequencyEnd( 3500 )
.stopBandStart(4000) .stopFrequency2( 4000 )
.stopBandAmplitude(0.0) .stopRipple( 0.0004 )
.stopBandRipple(0.027) .passRipple( 0.008)
.build(); .build();
RemezFIRFilterDesigner designer = new RemezFIRFilterDesigner(specification); RemezFIRFilterDesigner designer = new RemezFIRFilterDesigner(specification);
@@ -86,16 +86,12 @@ public class AudioModule extends Module implements IAudioPacketProvider,
private Listener<AudioPacket> mAudioPacketListener; private Listener<AudioPacket> mAudioPacketListener;
private PolyphaseFIRDecimatingFilter_RB mAudioDecimationFilter; private PolyphaseFIRDecimatingFilter_RB mAudioDecimationFilter;
//TODO: remove this -- is being replaced by the DemodulatedAudioFilterModule
private RealFIRFilter_R_R mAudioFilter = new RealFIRFilter_R_R(
Filters.FIR_BANDPASS_AUDIO_48KHZ.getCoefficients(), 2.0f);
public AudioModule(boolean record) public AudioModule(boolean record)
{ {
mSourceID = ++UNIQUE_ID; mSourceID = ++UNIQUE_ID;
mAudioMetadata = new AudioMetadata(mSourceID, record); mAudioMetadata = new AudioMetadata(mSourceID, record);
mAudioDecimationFilter = new PolyphaseFIRDecimatingFilter_RB(mDecimationCoefficients, 6); mAudioDecimationFilter = new PolyphaseFIRDecimatingFilter_RB(mDecimationCoefficients, 6, 2.0f);
mAudioDecimationFilter.setListener(new Listener<RealBuffer>() mAudioDecimationFilter.setListener(new Listener<RealBuffer>()
{ {
@Override @Override

View File

@@ -40,37 +40,35 @@ public class FilterViewer extends Application
*/ */
private float[] getFilter() private float[] getFilter()
{ {
FIRFilterSpecification specification = FIRFilterSpecification.lowPassBuilder() // FIRFilterSpecification specification = FIRFilterSpecification.lowPassBuilder()
.sampleRate( 48000 ) // .sampleRate( 48000 )
.gridDensity( 16 )
.passBandCutoff( 3000 )
.passBandAmplitude( 1.0 )
.passBandRipple( 0.01 )
.stopBandStart( 4000 )
.stopBandAmplitude( 0.0 )
.stopBandRipple( 0.027 )
.build();
// FIRFilterSpecification specification = FIRFilterSpecification.highPassBuilder()
// .sampleRate( 8000 )
// .gridDensity( 16 ) // .gridDensity( 16 )
// .stopBandCutoff( 2000 ) // .passBandCutoff( 3000 )
// .stopBandAmplitude( 0.0 )
// .stopBandRipple( 0.003 )
// .passBandStart( 3000 )
// .passBandAmplitude( 1.0 ) // .passBandAmplitude( 1.0 )
// .passBandRipple( 0.001 ) // .passBandRipple( 0.01 )
// .stopBandStart( 4000 )
// .stopBandAmplitude( 0.0 )
// .stopBandRipple( 0.027 )
// .build(); // .build();
FIRFilterSpecification specification = FIRFilterSpecification.highPassBuilder()
.sampleRate( 8000 )
.stopBandCutoff( 250 )
.stopBandAmplitude( 0.0 )
.stopBandRipple( 0.01 )
.passBandStart( 300 )
.passBandAmplitude( 1.0 )
.passBandRipple( 0.01 )
.build();
// FIRFilterSpecification specification = FIRFilterSpecification.bandPassBuilder() // FIRFilterSpecification specification = FIRFilterSpecification.bandPassBuilder()
// .sampleRate( 8000 ) // .sampleRate( 48000 )
// .order( 164 ) // .stopFrequency1( 150 )
// .stopFrequency1( 1100 ) // .passFrequencyBegin( 200 )
// .passFrequencyBegin( 1200 ) // .passFrequencyEnd( 3950 )
// .passFrequencyEnd( 2400 ) // .stopFrequency2( 4000 )
// .stopFrequency2( 2500 ) // .stopRipple( 0.0005 )
// .stopRipple( 0.01 ) // .passRipple( 0.003)
// .passRipple( 0.01 )
// .build(); // .build();
float[] taps = null; float[] taps = null;

View File

@@ -43,6 +43,7 @@ public class PolyphaseFIRDecimatingFilter_RB extends FIRFilter implements Listen
private RealToRealBufferAssembler mAssembler; private RealToRealBufferAssembler mAssembler;
private int mDecimationRatio; private int mDecimationRatio;
private float mAccumulator = 0.0f; private float mAccumulator = 0.0f;
private float mGain = 1.0f;
/** /**
* Polyphase filter stage for decimating real-valued sample buffers by the decimation ratio. Creates a number of * Polyphase filter stage for decimating real-valued sample buffers by the decimation ratio. Creates a number of
@@ -55,10 +56,13 @@ public class PolyphaseFIRDecimatingFilter_RB extends FIRFilter implements Listen
* to the nyquist frequency for an output sample rate equal to the input sample rate divided by the decimation ratio. * to the nyquist frequency for an output sample rate equal to the input sample rate divided by the decimation ratio.
* *
* @param decimationRatio to decimate the input sample rate by. * @param decimationRatio to decimate the input sample rate by.
* @param gain to apply to the filtered output. Use a value of 1.0 to apply no gain.
*/ */
public PolyphaseFIRDecimatingFilter_RB(float[] coefficients, int decimationRatio) public PolyphaseFIRDecimatingFilter_RB(float[] coefficients, int decimationRatio, float gain)
{ {
mDecimationRatio = decimationRatio; mDecimationRatio = decimationRatio;
mGain = gain;
createFilterStages(coefficients, mDecimationRatio); createFilterStages(coefficients, mDecimationRatio);
mFilterStagePointer = mFilterStages.size() - 1; mFilterStagePointer = mFilterStages.size() - 1;
} }
@@ -127,7 +131,7 @@ public class PolyphaseFIRDecimatingFilter_RB extends FIRFilter implements Listen
if(mFilterStagePointer < 0) if(mFilterStagePointer < 0)
{ {
mAssembler.receive(mAccumulator); mAssembler.receive(mAccumulator * mGain);
mAccumulator = 0.0f; mAccumulator = 0.0f;
mFilterStagePointer = mFilterStages.size() - 1; mFilterStagePointer = mFilterStages.size() - 1;
@@ -177,7 +181,7 @@ public class PolyphaseFIRDecimatingFilter_RB extends FIRFilter implements Listen
} }
float[] coefficients = designer.getImpulseResponse(); float[] coefficients = designer.getImpulseResponse();
PolyphaseFIRDecimatingFilter_RB filter = new PolyphaseFIRDecimatingFilter_RB(coefficients, 6); PolyphaseFIRDecimatingFilter_RB filter = new PolyphaseFIRDecimatingFilter_RB(coefficients, 6, 1.0f);
filter.setListener(new Listener<RealBuffer>() filter.setListener(new Listener<RealBuffer>()
{ {
@Override @Override

View File

@@ -43,9 +43,9 @@ import audio.metadata.MetadataType;
public class LTRNetDecoderState extends DecoderState public class LTRNetDecoderState extends DecoderState
{ {
private final static Logger mLog = LoggerFactory.getLogger( LTRNetDecoderState.class ); private final static Logger mLog = LoggerFactory.getLogger(LTRNetDecoderState.class);
private DecimalFormat mDecimalFormatter = new DecimalFormat( "0.00000" ); private DecimalFormat mDecimalFormatter = new DecimalFormat("0.00000");
private TreeSet<String> mTalkgroups = new TreeSet<String>(); private TreeSet<String> mTalkgroups = new TreeSet<String>();
private TreeSet<String> mTalkgroupsFirstHeard = new TreeSet<String>(); private TreeSet<String> mTalkgroupsFirstHeard = new TreeSet<String>();
@@ -53,11 +53,11 @@ public class LTRNetDecoderState extends DecoderState
private TreeSet<Integer> mUniqueIDs = new TreeSet<Integer>(); private TreeSet<Integer> mUniqueIDs = new TreeSet<Integer>();
private TreeSet<String> mNeighborIDs = new TreeSet<String>(); private TreeSet<String> mNeighborIDs = new TreeSet<String>();
private TreeSet<String> mSiteIDs = new TreeSet<String>(); private TreeSet<String> mSiteIDs = new TreeSet<String>();
private HashMap<Integer,Long> mReceiveFrequencies = private HashMap<Integer, Long> mReceiveFrequencies =
new HashMap<Integer,Long>(); new HashMap<Integer, Long>();
private HashMap<Integer,Long> mTransmitFrequencies = private HashMap<Integer, Long> mTransmitFrequencies =
new HashMap<Integer,Long>(); new HashMap<Integer, Long>();
private HashMap<Integer,String> mActiveCalls = new HashMap<Integer,String>(); private HashMap<Integer, String> mActiveCalls = new HashMap<Integer, String>();
private String mTalkgroup; private String mTalkgroup;
private Alias mTalkgroupAlias; private Alias mTalkgroupAlias;
@@ -65,9 +65,9 @@ public class LTRNetDecoderState extends DecoderState
private int mChannelNumber; private int mChannelNumber;
private long mFrequency = 0; private long mFrequency = 0;
public LTRNetDecoderState( AliasList aliasList ) public LTRNetDecoderState(AliasList aliasList)
{ {
super( aliasList ); super(aliasList);
} }
@Override @Override
@@ -77,80 +77,80 @@ public class LTRNetDecoderState extends DecoderState
} }
@Override @Override
public void receive( Message message ) public void receive(Message message)
{ {
if( message.isValid() ) if (message.isValid())
{ {
State state = State.IDLE; State state = State.IDLE;
if( message instanceof LTRNetOSWMessage ) if (message instanceof LTRNetOSWMessage)
{ {
LTRNetOSWMessage ltr = (LTRNetOSWMessage)message; LTRNetOSWMessage ltr = (LTRNetOSWMessage) message;
switch( ltr.getMessageType() ) switch (ltr.getMessageType())
{ {
case CA_ENDD: case CA_ENDD:
if( mChannelNumber == 0 ) if (mChannelNumber == 0)
{ {
mChannelNumber = ltr.getChannel(); mChannelNumber = ltr.getChannel();
broadcast( ChangedAttribute.CHANNEL_NUMBER ); broadcast(ChangedAttribute.CHANNEL_NUMBER);
} }
/* Process FCC Station ID Events */ /* Process FCC Station ID Events */
if( ltr.getGroup() == 254 ) if (ltr.getGroup() == 254)
{ {
if( mCurrentCallEvent == null || if (mCurrentCallEvent == null ||
mCurrentCallEvent.getCallEventType() != mCurrentCallEvent.getCallEventType() !=
CallEventType.STATION_ID ) CallEventType.STATION_ID)
{ {
mCurrentCallEvent = new LTRCallEvent.Builder( mCurrentCallEvent = new LTRCallEvent.Builder(
DecoderType.LTR_NET, CallEventType.STATION_ID ) DecoderType.LTR_NET, CallEventType.STATION_ID)
.aliasList( getAliasList() ) .aliasList(getAliasList())
.channel( String.valueOf( mChannelNumber ) ) .channel(String.valueOf(mChannelNumber))
.frequency( mFrequency ) .frequency(mFrequency)
.to( ltr.getTalkgroupID() ) .to(ltr.getTalkgroupID())
.build(); .build();
broadcast( mCurrentCallEvent ); broadcast(mCurrentCallEvent);
broadcast( new DecoderStateEvent( this, broadcast(new DecoderStateEvent(this,
Event.START, State.DATA ) ); Event.START, State.DATA));
} }
else else
{ {
broadcast( new DecoderStateEvent( this, broadcast(new DecoderStateEvent(this,
Event.CONTINUATION, State.DATA ) ); Event.CONTINUATION, State.DATA));
} }
} }
else else
{ {
processCallEndMessage( ltr ); processCallEndMessage(ltr);
} }
break; break;
case CA_STRT: case CA_STRT:
if( mChannelNumber == 0 ) if (mChannelNumber == 0)
{ {
mChannelNumber = ltr.getChannel(); mChannelNumber = ltr.getChannel();
broadcast( ChangedAttribute.CHANNEL_NUMBER ); broadcast(ChangedAttribute.CHANNEL_NUMBER);
} }
/* If the call event channel matches our current channel /* If the call event channel matches our current channel
* then it's a call, otherwise it's a call detect. */ * then it's a call, otherwise it's a call detect. */
if( ltr.getChannel() == mChannelNumber ) if (ltr.getChannel() == mChannelNumber)
{ {
processCallMessage( ltr ); processCallMessage(ltr);
} }
else else
{ {
processCallDetectMessage( ltr ); processCallDetectMessage(ltr);
} }
break; break;
case SY_IDLE: case SY_IDLE:
if( mChannelNumber != ltr.getChannel() ) if (mChannelNumber != ltr.getChannel())
{ {
mChannelNumber = ltr.getChannel(); mChannelNumber = ltr.getChannel();
broadcast( ChangedAttribute.CHANNEL_NUMBER ); broadcast(ChangedAttribute.CHANNEL_NUMBER);
} }
break; break;
case MA_CHNH: case MA_CHNH:
@@ -159,26 +159,26 @@ public class LTRNetDecoderState extends DecoderState
break; break;
case FQ_RXHI: case FQ_RXHI:
case FQ_RXLO: case FQ_RXLO:
if( ltr.getFrequency() > 0 ) if (ltr.getFrequency() > 0)
{ {
mReceiveFrequencies.put( ltr.getHomeRepeater(), mReceiveFrequencies.put(ltr.getHomeRepeater(),
ltr.getFrequency() ); ltr.getFrequency());
} }
break; break;
case FQ_TXHI: case FQ_TXHI:
case FQ_TXLO: case FQ_TXLO:
if( ltr.getFrequency() > 0 ) if (ltr.getFrequency() > 0)
{ {
mTransmitFrequencies.put( ltr.getHomeRepeater(), mTransmitFrequencies.put(ltr.getHomeRepeater(),
ltr.getFrequency() ); ltr.getFrequency());
} }
break; break;
case ID_NBOR: case ID_NBOR:
String neighborID = ltr.getNeighborID(); String neighborID = ltr.getNeighborID();
if( neighborID != null ) if (neighborID != null)
{ {
mNeighborIDs.add( neighborID ); mNeighborIDs.add(neighborID);
} }
break; break;
case ID_UNIQ: case ID_UNIQ:
@@ -186,59 +186,59 @@ public class LTRNetDecoderState extends DecoderState
int uniqueID = ltr.getRadioUniqueID(); int uniqueID = ltr.getRadioUniqueID();
if( uniqueID != LTRNetOSWMessage.INT_NULL_VALUE ) if (uniqueID != LTRNetOSWMessage.INT_NULL_VALUE)
{ {
mUniqueIDs.add( uniqueID ); mUniqueIDs.add(uniqueID);
} }
if( getCurrentLTRCallEvent() == null ) if (getCurrentLTRCallEvent() == null)
{ {
mCurrentCallEvent = new LTRCallEvent.Builder( mCurrentCallEvent = new LTRCallEvent.Builder(
DecoderType.LTR_NET, CallEventType.REGISTER ) DecoderType.LTR_NET, CallEventType.REGISTER)
.aliasList( getAliasList() ) .aliasList(getAliasList())
.channel( String.valueOf( mChannelNumber ) ) .channel(String.valueOf(mChannelNumber))
.frequency( mFrequency ) .frequency(mFrequency)
.from( String.valueOf( uniqueID ) ) .from(String.valueOf(uniqueID))
.build(); .build();
} }
else else
{ {
mCurrentCallEvent.setFromID( mCurrentCallEvent.setFromID(
String.valueOf( ltr.getRadioUniqueID() ) ); String.valueOf(ltr.getRadioUniqueID()));
mCurrentCallEvent.setDetails( "Unique ID" ); mCurrentCallEvent.setDetails("Unique ID");
broadcast( mCurrentCallEvent ); broadcast(mCurrentCallEvent);
} }
mTalkgroup = String.valueOf( uniqueID ); mTalkgroup = String.valueOf(uniqueID);
broadcast( ChangedAttribute.TO_TALKGROUP ); broadcast(ChangedAttribute.TO_TALKGROUP);
mTalkgroupAlias = ltr.getRadioUniqueIDAlias(); mTalkgroupAlias = ltr.getRadioUniqueIDAlias();
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS ); broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
break; break;
case ID_SITE: case ID_SITE:
String siteID = ltr.getSiteID(); String siteID = ltr.getSiteID();
if( siteID != null ) if (siteID != null)
{ {
mSiteIDs.add( siteID ); mSiteIDs.add(siteID);
} }
break; break;
default: default:
break; break;
} }
} }
else if( message instanceof LTRNetISWMessage ) else if (message instanceof LTRNetISWMessage)
{ {
LTRNetISWMessage ltr = ((LTRNetISWMessage)message); LTRNetISWMessage ltr = ((LTRNetISWMessage) message);
switch( ltr.getMessageType() ) switch (ltr.getMessageType())
{ {
case CA_STRT: case CA_STRT:
processCallMessage( ltr ); processCallMessage(ltr);
break; break;
case CA_ENDD: case CA_ENDD:
processCallEndMessage( ltr ); processCallEndMessage(ltr);
break; break;
case ID_ESNH: case ID_ESNH:
case ID_ESNL: case ID_ESNL:
@@ -246,33 +246,33 @@ public class LTRNetDecoderState extends DecoderState
String esn = ltr.getESN(); String esn = ltr.getESN();
if( !esn.contains( "xxxx" ) ) if (!esn.contains("xxxx"))
{ {
mESNs.add( ltr.getESN() ); mESNs.add(ltr.getESN());
} }
mDescription = "ESN"; mDescription = "ESN";
broadcast( ChangedAttribute.DESCRIPTION ); broadcast(ChangedAttribute.DESCRIPTION);
mTalkgroup = ltr.getESN(); mTalkgroup = ltr.getESN();
broadcast( ChangedAttribute.TO_TALKGROUP ); broadcast(ChangedAttribute.TO_TALKGROUP);
mTalkgroupAlias = ltr.getESNAlias(); mTalkgroupAlias = ltr.getESNAlias();
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS ); broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
broadcast( new DecoderStateEvent( this, Event.DECODE, State.DATA ) ); broadcast(new DecoderStateEvent(this, Event.DECODE, State.DATA));
if( mCurrentCallEvent == null ) if (mCurrentCallEvent == null)
{ {
mCurrentCallEvent = new LTRCallEvent.Builder( mCurrentCallEvent = new LTRCallEvent.Builder(
DecoderType.LTR_NET, CallEventType.REGISTER_ESN ) DecoderType.LTR_NET, CallEventType.REGISTER_ESN)
.aliasList( getAliasList() ) .aliasList(getAliasList())
.details( "ESN:" + ltr.getESN() ) .details("ESN:" + ltr.getESN())
.frequency( mFrequency ) .frequency(mFrequency)
.from( ltr.getESN() ) .from(ltr.getESN())
.build(); .build();
broadcast( mCurrentCallEvent ); broadcast(mCurrentCallEvent);
} }
break; break;
@@ -281,36 +281,36 @@ public class LTRNetDecoderState extends DecoderState
int uniqueid = ltr.getRadioUniqueID(); int uniqueid = ltr.getRadioUniqueID();
if( uniqueid != LTRNetISWMessage.INT_NULL_VALUE ) if (uniqueid != LTRNetISWMessage.INT_NULL_VALUE)
{ {
mUniqueIDs.add( uniqueid ); mUniqueIDs.add(uniqueid);
mDescription = "REGISTER UID"; mDescription = "REGISTER UID";
broadcast( ChangedAttribute.DESCRIPTION ); broadcast(ChangedAttribute.DESCRIPTION);
mTalkgroup = String.valueOf( uniqueid ); mTalkgroup = String.valueOf(uniqueid);
broadcast( ChangedAttribute.TO_TALKGROUP ); broadcast(ChangedAttribute.TO_TALKGROUP);
mTalkgroupAlias = ltr.getRadioUniqueIDAlias(); mTalkgroupAlias = ltr.getRadioUniqueIDAlias();
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS ); broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
if( getCurrentLTRCallEvent() == null ) if (getCurrentLTRCallEvent() == null)
{ {
mCurrentCallEvent = new LTRCallEvent.Builder( mCurrentCallEvent = new LTRCallEvent.Builder(
DecoderType.LTR_NET, CallEventType.REGISTER ) DecoderType.LTR_NET, CallEventType.REGISTER)
.aliasList( getAliasList() ) .aliasList(getAliasList())
.channel( String.valueOf( mChannelNumber ) ) .channel(String.valueOf(mChannelNumber))
.frequency( mFrequency ) .frequency(mFrequency)
.from( String.valueOf( uniqueid ) ) .from(String.valueOf(uniqueid))
.build(); .build();
} }
else else
{ {
mCurrentCallEvent.setFromID( mCurrentCallEvent.setFromID(
String.valueOf( ltr.getRadioUniqueID() ) ); String.valueOf(ltr.getRadioUniqueID()));
mCurrentCallEvent.setDetails( "Unique ID" ); mCurrentCallEvent.setDetails("Unique ID");
broadcast( mCurrentCallEvent ); broadcast(mCurrentCallEvent);
} }
} }
break; break;
@@ -323,9 +323,9 @@ public class LTRNetDecoderState extends DecoderState
public LTRCallEvent getCurrentLTRCallEvent() public LTRCallEvent getCurrentLTRCallEvent()
{ {
if( mCurrentCallEvent != null ) if (mCurrentCallEvent != null)
{ {
return (LTRCallEvent)mCurrentCallEvent; return (LTRCallEvent) mCurrentCallEvent;
} }
return null; return null;
@@ -336,228 +336,228 @@ public class LTRNetDecoderState extends DecoderState
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append( "Activity Summary\n" ); sb.append("Activity Summary\n");
sb.append( "Decoder:\tLTR-Net\n\n" ); sb.append("Decoder:\tLTR-Net\n\n");
if( mSiteIDs.isEmpty() ) if (mSiteIDs.isEmpty())
{ {
sb.append( "Site:\tUnknown\n" ); sb.append("Site:\tUnknown\n");
} }
else else
{ {
Iterator<String> it = mSiteIDs.iterator(); Iterator<String> it = mSiteIDs.iterator();
while( it.hasNext() ) while (it.hasNext())
{ {
sb.append( "Site:\t" ); sb.append("Site:\t");
String siteID = it.next(); String siteID = it.next();
sb.append( siteID ); sb.append(siteID);
if( hasAliasList() ) if (hasAliasList())
{ {
Alias siteAlias = getAliasList().getSiteID( String.valueOf( siteID ) ); Alias siteAlias = getAliasList().getSiteID(String.valueOf(siteID));
if( siteAlias != null ) if (siteAlias != null)
{ {
sb.append( " " ); sb.append(" ");
sb.append( siteAlias.getName() ); sb.append(siteAlias.getName());
} }
} }
sb.append( "\n" ); sb.append("\n");
} }
} }
sb.append( "\nLCNs (transmit | receive)\n" ); sb.append("\nLCNs (transmit | receive)\n");
if( mReceiveFrequencies.isEmpty() && mTransmitFrequencies.isEmpty() ) if (mReceiveFrequencies.isEmpty() && mTransmitFrequencies.isEmpty())
{ {
sb.append( " None\n" ); sb.append(" None\n");
} }
else else
{ {
for( int x = 1; x < 21; x++ ) for (int x = 1; x < 21; x++)
{ {
long rcv = 0; long rcv = 0;
if( mReceiveFrequencies.containsKey( x ) ) if (mReceiveFrequencies.containsKey(x))
{ {
rcv = mReceiveFrequencies.get( x ); rcv = mReceiveFrequencies.get(x);
} }
long xmt = 0; long xmt = 0;
if( mTransmitFrequencies.containsKey( x ) ) if (mTransmitFrequencies.containsKey(x))
{ {
xmt = mTransmitFrequencies.get( x ); xmt = mTransmitFrequencies.get(x);
} }
if( rcv > 0 || xmt > 0 ) if (rcv > 0 || xmt > 0)
{ {
if( x < 10 ) if (x < 10)
{ {
sb.append( " " ); sb.append(" ");
} }
sb.append( x ); sb.append(x);
sb.append( ": " ); sb.append(": ");
if( xmt == 0 ) if (xmt == 0)
{ {
sb.append( "---.-----" ); sb.append("---.-----");
} }
else else
{ {
sb.append( mDecimalFormatter.format( (double)xmt/1E6d ) ); sb.append(mDecimalFormatter.format((double) xmt / 1E6d));
} }
sb.append( " | " ); sb.append(" | ");
if( rcv == 0 ) if (rcv == 0)
{ {
sb.append( "---.-----" ); sb.append("---.-----");
} }
else else
{ {
sb.append( mDecimalFormatter.format( (double)rcv/1E6d ) ); sb.append(mDecimalFormatter.format((double) rcv / 1E6d));
} }
if( x == mChannelNumber ) if (x == mChannelNumber)
{ {
sb.append( " **" ); sb.append(" **");
} }
sb.append( "\n" ); sb.append("\n");
} }
} }
} }
sb.append( "\nTalkgroups\n" ); sb.append("\nTalkgroups\n");
if( mTalkgroups.isEmpty() ) if (mTalkgroups.isEmpty())
{ {
sb.append( " None\n" ); sb.append(" None\n");
} }
else else
{ {
Iterator<String> it = mTalkgroups.iterator(); Iterator<String> it = mTalkgroups.iterator();
while( it.hasNext() ) while (it.hasNext())
{ {
String tgid = it.next(); String tgid = it.next();
sb.append( " " ); sb.append(" ");
sb.append( tgid ); sb.append(tgid);
sb.append( " " ); sb.append(" ");
if( hasAliasList() ) if (hasAliasList())
{ {
Alias alias = getAliasList().getTalkgroupAlias( tgid ); Alias alias = getAliasList().getTalkgroupAlias(tgid);
if( alias != null ) if (alias != null)
{ {
sb.append( alias.getName() ); sb.append(alias.getName());
} }
} }
sb.append( "\n" ); sb.append("\n");
} }
} }
sb.append( "\nRadio Unique IDs\n" ); sb.append("\nRadio Unique IDs\n");
if( mUniqueIDs.isEmpty() ) if (mUniqueIDs.isEmpty())
{ {
sb.append( " None\n" ); sb.append(" None\n");
} }
else else
{ {
Iterator<Integer> it = mUniqueIDs.iterator(); Iterator<Integer> it = mUniqueIDs.iterator();
while( it.hasNext() ) while (it.hasNext())
{ {
int uid = it.next(); int uid = it.next();
sb.append( " " ); sb.append(" ");
sb.append( uid ); sb.append(uid);
sb.append( " " ); sb.append(" ");
if( hasAliasList() ) if (hasAliasList())
{ {
Alias alias = getAliasList().getUniqueID( uid ); Alias alias = getAliasList().getUniqueID(uid);
if( alias != null ) if (alias != null)
{ {
sb.append( alias.getName() ); sb.append(alias.getName());
} }
} }
sb.append( "\n" ); sb.append("\n");
} }
} }
sb.append( "\nESNs\n" ); sb.append("\nESNs\n");
if( mESNs.isEmpty() ) if (mESNs.isEmpty())
{ {
sb.append( " None\n" ); sb.append(" None\n");
} }
else else
{ {
Iterator<String> it = mESNs.iterator(); Iterator<String> it = mESNs.iterator();
while( it.hasNext() ) while (it.hasNext())
{ {
String esn = it.next(); String esn = it.next();
sb.append( " " ); sb.append(" ");
sb.append( esn ); sb.append(esn);
sb.append( " " ); sb.append(" ");
if( hasAliasList() ) if (hasAliasList())
{ {
Alias alias = getAliasList().getESNAlias( esn ); Alias alias = getAliasList().getESNAlias(esn);
if( alias != null ) if (alias != null)
{ {
sb.append( alias.getName() ); sb.append(alias.getName());
} }
} }
sb.append( "\n" ); sb.append("\n");
} }
} }
sb.append( "\nNeighbor Sites\n" ); sb.append("\nNeighbor Sites\n");
if( mNeighborIDs.isEmpty() ) if (mNeighborIDs.isEmpty())
{ {
sb.append( " None\n" ); sb.append(" None\n");
} }
else else
{ {
Iterator<String> it = mNeighborIDs.iterator(); Iterator<String> it = mNeighborIDs.iterator();
while( it.hasNext() ) while (it.hasNext())
{ {
String neighbor = it.next(); String neighbor = it.next();
sb.append( " " ); sb.append(" ");
sb.append( neighbor ); sb.append(neighbor);
sb.append( " " ); sb.append(" ");
if( hasAliasList() ) if (hasAliasList())
{ {
Alias alias = getAliasList().getSiteID( String.valueOf( neighbor ) ); Alias alias = getAliasList().getSiteID(String.valueOf(neighbor));
if( alias != null ) if (alias != null)
{ {
sb.append( alias.getName() ); sb.append(alias.getName());
} }
} }
sb.append( "\n" ); sb.append("\n");
} }
} }
@@ -567,124 +567,132 @@ public class LTRNetDecoderState extends DecoderState
/** /**
* Call Detect - current channel messages indicate a call on another channel * Call Detect - current channel messages indicate a call on another channel
*/ */
private void processCallDetectMessage( LTRNetMessage message ) private void processCallDetectMessage(LTRNetMessage message)
{ {
if( !mActiveCalls.containsKey( message.getChannel() ) || if (!mActiveCalls.containsKey(message.getChannel()) ||
!mActiveCalls.get( message.getChannel() ).contentEquals( message.getTalkgroupID() ) ) !mActiveCalls.get(message.getChannel()).contentEquals(message.getTalkgroupID()))
{ {
mActiveCalls.put( message.getChannel(), message.getTalkgroupID() ); mActiveCalls.put(message.getChannel(), message.getTalkgroupID());
int channel = message.getChannel(); int channel = message.getChannel();
long frequency = 0; long frequency = 0;
if( mTransmitFrequencies.containsKey( channel ) ) if (mTransmitFrequencies.containsKey(channel))
{ {
frequency = mTransmitFrequencies.get( channel ); frequency = mTransmitFrequencies.get(channel);
} }
broadcast( new LTRCallEvent.Builder( DecoderType.LTR_NET, CallEventType.CALL_DETECT ) broadcast(new LTRCallEvent.Builder(DecoderType.LTR_NET, CallEventType.CALL_DETECT)
.aliasList( getAliasList() ) .aliasList(getAliasList())
.channel( String.valueOf( message.getChannel() ) ) .channel(String.valueOf(message.getChannel()))
.frequency( frequency ) .frequency(frequency)
.to( message.getTalkgroupID() ) .to(message.getTalkgroupID())
.build() ); .build());
} }
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.IDLE ) ); broadcast(new DecoderStateEvent(this, Event.CONTINUATION, State.IDLE));
} }
/** /**
* Indicates if the talkgroup is different than the talkgroup specified in * Indicates if the talkgroup is different than the talkgroup specified in
* the current call event * the current call event
*/ */
private boolean isDifferentTalkgroup( String talkgroup ) private boolean isDifferentTalkgroup(String talkgroup)
{ {
return talkgroup != null && return talkgroup != null &&
mCurrentCallEvent != null && mCurrentCallEvent != null &&
mCurrentCallEvent.getToID() != null && mCurrentCallEvent.getToID() != null &&
!mCurrentCallEvent.getToID().contentEquals( talkgroup ); !mCurrentCallEvent.getToID().contentEquals(talkgroup);
} }
private void processCallMessage( LTRNetMessage message ) private boolean isValidTalkgroup(String talkgroup)
{
return talkgroup != null && !talkgroup.matches("0-00-000");
}
private void processCallMessage(LTRNetMessage message)
{ {
int group = message.getGroup(); int group = message.getGroup();
/* Process call registration */ /* Process call registration */
if( group == 253 ) if (group == 253)
{ {
broadcast( new DecoderStateEvent( this, Event.START, State.DATA ) ); broadcast(new DecoderStateEvent(this, Event.START, State.DATA));
mDescription = "REGISTER"; mDescription = "REGISTER";
broadcast( ChangedAttribute.DESCRIPTION ); broadcast(ChangedAttribute.DESCRIPTION);
} }
/* Process call */ /* Process call */
else else
{ {
String talkgroup = message.getTalkgroupID(); String talkgroup = message.getTalkgroupID();
if (isValidTalkgroup(talkgroup))
{
final LTRCallEvent current = getCurrentLTRCallEvent(); final LTRCallEvent current = getCurrentLTRCallEvent();
/* If this is a new call or the talkgroup is different from the current /* If this is a new call or the talkgroup is different from the current
* call, create a new call event */ * call, create a new call event */
if( current == null || isDifferentTalkgroup( talkgroup ) ) if (current == null || isDifferentTalkgroup(talkgroup))
{ {
/* Invalidate the current call */ /* Invalidate the current call */
if( current != null ) if (current != null)
{ {
current.setValid( false ); current.setValid(false);
broadcast( current ); broadcast(current);
} }
mTalkgroup = message.getTalkgroupID(); mTalkgroup = message.getTalkgroupID();
broadcast( ChangedAttribute.TO_TALKGROUP ); broadcast(ChangedAttribute.TO_TALKGROUP);
/* A talkgroup must be seen at least once before it will be added /* A talkgroup must be seen at least once before it will be added
* to the mTalkgroups list that is used in the activity summary, * to the mTalkgroups list that is used in the activity summary,
* so that we don't pollute the summary with one-off error talkgroups */ * so that we don't pollute the summary with one-off error talkgroups */
if( mTalkgroupsFirstHeard.contains( mTalkgroup ) ) if (mTalkgroupsFirstHeard.contains(mTalkgroup))
{ {
mTalkgroups.add( mTalkgroup ); mTalkgroups.add(mTalkgroup);
} }
else else
{ {
mTalkgroupsFirstHeard.add( mTalkgroup ); mTalkgroupsFirstHeard.add(mTalkgroup);
} }
mTalkgroupAlias = message.getTalkgroupIDAlias(); mTalkgroupAlias = message.getTalkgroupIDAlias();
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS ); broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
CallEvent callEvent = new LTRCallEvent.Builder( DecoderType.LTR_NET, CallEventType.CALL ) CallEvent callEvent = new LTRCallEvent.Builder(DecoderType.LTR_NET, CallEventType.CALL)
.aliasList( getAliasList() ) .aliasList(getAliasList())
.channel( String.valueOf( message.getChannel() ) ) .channel(String.valueOf(message.getChannel()))
.frequency( mFrequency ) .frequency(mFrequency)
.to( message.getTalkgroupID() ) .to(message.getTalkgroupID())
.build(); .build();
broadcast( callEvent ); broadcast(callEvent);
mCurrentCallEvent = callEvent; mCurrentCallEvent = callEvent;
broadcast( new Metadata( MetadataType.TO, mTalkgroup, mTalkgroupAlias, true ) ); broadcast(new Metadata(MetadataType.TO, mTalkgroup, mTalkgroupAlias, true));
broadcast( new DecoderStateEvent( this, Event.START, State.CALL ) ); broadcast(new DecoderStateEvent(this, Event.START, State.CALL));
} }
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.CALL ) ); broadcast(new DecoderStateEvent(this, Event.CONTINUATION, State.CALL));
}
} }
} }
private void processCallEndMessage( LTRNetMessage message ) private void processCallEndMessage(LTRNetMessage message)
{ {
if( mCurrentCallEvent != null && if (mCurrentCallEvent != null &&
mCurrentCallEvent.getCallEventType() == CallEventType.CALL ) mCurrentCallEvent.getCallEventType() == CallEventType.CALL)
{ {
mCurrentCallEvent.setEnd( System.currentTimeMillis() ); mCurrentCallEvent.setEnd(System.currentTimeMillis());
broadcast( mCurrentCallEvent ); broadcast(mCurrentCallEvent);
} }
mCurrentCallEvent = null; mCurrentCallEvent = null;
broadcast( new DecoderStateEvent( this, Event.END, State.FADE ) ); broadcast(new DecoderStateEvent(this, Event.END, State.FADE));
} }
/** /**
@@ -711,23 +719,23 @@ public class LTRNetDecoderState extends DecoderState
*/ */
private void resetState() private void resetState()
{ {
if( mCurrentCallEvent != null && mCurrentCallEvent if (mCurrentCallEvent != null && mCurrentCallEvent
.getCallEventType() == CallEventType.CALL ) .getCallEventType() == CallEventType.CALL)
{ {
mCurrentCallEvent.end(); mCurrentCallEvent.end();
broadcast( mCurrentCallEvent ); broadcast(mCurrentCallEvent);
} }
mCurrentCallEvent = null; mCurrentCallEvent = null;
mTalkgroup = null; mTalkgroup = null;
broadcast( ChangedAttribute.TO_TALKGROUP ); broadcast(ChangedAttribute.TO_TALKGROUP);
mTalkgroupAlias = null; mTalkgroupAlias = null;
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS ); broadcast(ChangedAttribute.TO_TALKGROUP_ALIAS);
mDescription = null; mDescription = null;
broadcast( ChangedAttribute.DESCRIPTION ); broadcast(ChangedAttribute.DESCRIPTION);
} }
public String getToTalkgroup() public String getToTalkgroup()
@@ -762,9 +770,9 @@ public class LTRNetDecoderState extends DecoderState
} }
@Override @Override
public void receiveDecoderStateEvent( DecoderStateEvent event ) public void receiveDecoderStateEvent(DecoderStateEvent event)
{ {
switch( event.getEvent() ) switch (event.getEvent())
{ {
case RESET: case RESET:
resetState(); resetState();
@@ -778,7 +786,7 @@ public class LTRNetDecoderState extends DecoderState
} }
@Override @Override
public void start( ScheduledExecutorService executor ) public void start(ScheduledExecutorService executor)
{ {
} }

View File

@@ -152,8 +152,12 @@ public class P25AudioModule extends Module implements Listener<Message>,
if (!mLibraryLoadStatusLogged) if (!mLibraryLoadStatusLogged)
{ {
mLog.info("JMBE audio conversion library successfully loaded" StringBuilder sb = new StringBuilder();
+ " - P25 audio will be available"); sb.append("JMBE audio conversion library [");
sb.append(library.getVersion());
sb.append("] successfully loaded - P25 audio will be available");
mLog.info(sb.toString());
mLibraryLoadStatusLogged = true; mLibraryLoadStatusLogged = true;
} }