mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Closes #7 NXDN Decoder * Implements: NXDN4800, NXDN9600, Type-C and Type-D decoding and trunk tracking. * Redesigns tuner and channel frequency error management.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2025 Dennis Sheirer
|
||||
* Copyright (C) 2014-2026 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
|
||||
@@ -52,6 +52,44 @@ public enum Dibit
|
||||
mPhase = phase;
|
||||
}
|
||||
|
||||
private static final float SOFT_SYMBOL_QUADRANT_BOUNDARY = (float)(Math.PI / 2.0);
|
||||
|
||||
/**
|
||||
* Decodes the sample value to determine the correct QPSK quadrant and maps the value to a Dibit symbol.
|
||||
* @param sample in radians.
|
||||
* @return symbol decision.
|
||||
*/
|
||||
public static Dibit fromSample(float sample)
|
||||
{
|
||||
if(sample > 0)
|
||||
{
|
||||
return sample > SOFT_SYMBOL_QUADRANT_BOUNDARY ? Dibit.D01_PLUS_3 : Dibit.D00_PLUS_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return sample < -SOFT_SYMBOL_QUADRANT_BOUNDARY ? Dibit.D11_MINUS_3 : Dibit.D10_MINUS_1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the error from the sample by first mapping it to a symbol and the error is the difference from
|
||||
* the ideal phase of that symbol.
|
||||
* @param sample to process
|
||||
* @return error from ideal
|
||||
*/
|
||||
public static float getError(float sample)
|
||||
{
|
||||
if(sample > 0)
|
||||
{
|
||||
return sample > SOFT_SYMBOL_QUADRANT_BOUNDARY ? Dibit.D01_PLUS_3.mPhase - sample : Dibit.D00_PLUS_1.mPhase - sample;
|
||||
}
|
||||
else
|
||||
{
|
||||
return sample < -SOFT_SYMBOL_QUADRANT_BOUNDARY ? Dibit.D11_MINUS_3.mPhase - sample : Dibit.D10_MINUS_1.mPhase - sample;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Binary value of the symbol
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user