mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
* Uses same shared architecture and symbol processor pattern as other C4FM decoders. * Adds soft symbol processing and sync detection. * Removes RRC filter and replaces with improved channel filter. * Viterbi soft symbol decoding with demodulator reliability weighting * Improved sync reacquisition in low SNR * Improved handling for phase wrapping and interpolation * NAC Tracker updated to track by NAC count * Native buffers returning partial buffers * Message processor uses only valid LDU1 words * Reduced phantom TDU messages * Tuner/Channe frequency error corrections don't reset the symbol trackers and fix possible divide by zero error * LSM timing error detector now updates per symbol block size instead of sample buffer size - faster convergence * New unit tests * Resolves several issues, including a lagging sync detect offset issue in the recently updated P25P1 C4FM decoder. * Consolidate filter designers for each protocol back into the FilterFactory class. * DMR, P25 Phase 1 C4FM and LSM, and P25 Phase 2 decoders design the baseband filter once and share the taps across the I and Q filters. Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* 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
|
||||
* 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.buffer;
|
||||
|
||||
import io.github.dsheirer.sample.complex.ComplexSamples;
|
||||
import io.github.dsheirer.sample.complex.InterleavedComplexSamples;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* JUnit tests for the float native buffer.
|
||||
*/
|
||||
public class FloatNativeBufferTest
|
||||
{
|
||||
private static final int SAMPLE_COUNT = 5000;
|
||||
|
||||
/**
|
||||
* Creates interleaved complex samples where each value is unique and non-zero.
|
||||
*/
|
||||
private static float[] getSamples()
|
||||
{
|
||||
float[] samples = new float[SAMPLE_COUNT * 2];
|
||||
|
||||
for(int x = 0; x < samples.length; x++)
|
||||
{
|
||||
samples[x] = x + 1;
|
||||
}
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test: the complex samples iterator returns every sample exactly once, with a final chunk that holds the remaining
|
||||
* samples rather than padding them to the full chunk length with zero valued samples.
|
||||
*/
|
||||
@Test
|
||||
void testComplexSamplesIterator()
|
||||
{
|
||||
float[] samples = getSamples();
|
||||
List<Integer> lengths = new ArrayList<>();
|
||||
int pointer = 0;
|
||||
|
||||
Iterator<ComplexSamples> iterator = new FloatNativeBuffer(samples, 0L, 0.0f).iterator();
|
||||
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
ComplexSamples chunk = iterator.next();
|
||||
lengths.add(chunk.i().length);
|
||||
|
||||
for(int x = 0; x < chunk.i().length; x++)
|
||||
{
|
||||
assertEquals(samples[pointer++], chunk.i()[x], "Inphase sample " + (pointer / 2));
|
||||
assertEquals(samples[pointer++], chunk.q()[x], "Quadrature sample " + (pointer / 2));
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(samples.length, pointer, "Sample count");
|
||||
assertEquals(List.of(2048, 2048, 904), lengths, "Chunk lengths");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test: the interleaved complex samples iterator returns every sample exactly once, without zero padding.
|
||||
*/
|
||||
@Test
|
||||
void testInterleavedComplexSamplesIterator()
|
||||
{
|
||||
float[] samples = getSamples();
|
||||
List<Integer> lengths = new ArrayList<>();
|
||||
int pointer = 0;
|
||||
|
||||
Iterator<InterleavedComplexSamples> iterator = new FloatNativeBuffer(samples, 0L, 0.0f).iteratorInterleaved();
|
||||
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
float[] chunk = iterator.next().samples();
|
||||
lengths.add(chunk.length / 2);
|
||||
|
||||
for(float sample : chunk)
|
||||
{
|
||||
assertEquals(samples[pointer], sample, "Sample " + pointer);
|
||||
pointer++;
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(samples.length, pointer, "Sample count");
|
||||
assertEquals(List.of(2048, 2048, 904), lengths, "Chunk lengths");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user