mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-24 11:12:27 -04:00
DSD demod: DMR integration debug (2). Added eye diagram capability by delaying Q signal by 20 samples (2400 baud)
This commit is contained in:
parent
f167241da7
commit
90a5b75e91
@ -123,10 +123,11 @@ void DSDDMRVoice::process()
|
|||||||
case 9:
|
case 9:
|
||||||
processSlot9(symbolIndex);
|
processSlot9(symbolIndex);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10: // this is the post-process case
|
||||||
postProcess(symbolIndex);
|
postProcess(symbolIndex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
m_dsdDecoder->m_fsmState = DSDDecoder::DSDLookForSync;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,10 +173,12 @@ void DSDDMRVoice::preProcess()
|
|||||||
|
|
||||||
void DSDDMRVoice::postProcess(int symbolIndex)
|
void DSDDMRVoice::postProcess(int symbolIndex)
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr, "DSDDMRVoice::postProcess: m_symbolIndex: %d", m_symbolIndex);
|
||||||
m_dsdDecoder->getDibit(); // get dibit from symbol but do nothing with it
|
m_dsdDecoder->getDibit(); // get dibit from symbol but do nothing with it
|
||||||
|
|
||||||
if (symbolIndex == 54+12+54-1) // very last symbol -> go back to search sync state
|
if (symbolIndex == 54+12+54-1) // very last symbol -> go back to search sync state
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "\nDSDDMRVoice::postProcess: end of frame\n");
|
||||||
m_dsdDecoder->m_fsmState = DSDDecoder::DSDLookForSync;
|
m_dsdDecoder->m_fsmState = DSDDecoder::DSDLookForSync;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,12 @@ public:
|
|||||||
private:
|
private:
|
||||||
int getSlotIndex(int symbolInMajorBlockIndex) //!< calculates current slot index and returns symbol index in the slot
|
int getSlotIndex(int symbolInMajorBlockIndex) //!< calculates current slot index and returns symbol index in the slot
|
||||||
{
|
{
|
||||||
|
if (m_majorBlock > 5) // this is the post-process case
|
||||||
|
{
|
||||||
|
m_slotIndex = 10;
|
||||||
|
return symbolInMajorBlockIndex;
|
||||||
|
}
|
||||||
|
|
||||||
if (symbolInMajorBlockIndex < 54)
|
if (symbolInMajorBlockIndex < 54)
|
||||||
{
|
{
|
||||||
m_slotIndex = 0;
|
m_slotIndex = 0;
|
||||||
@ -109,11 +115,6 @@ private:
|
|||||||
m_slotIndex = 9;
|
m_slotIndex = 9;
|
||||||
return symbolInMajorBlockIndex - 54+12+36+18+24+18+36+12+54;
|
return symbolInMajorBlockIndex - 54+12+36+18+24+18+36+12+54;
|
||||||
}
|
}
|
||||||
else if (symbolInMajorBlockIndex < 54+12+36+18+24+18+36+12+54+24+54+12+54)
|
|
||||||
{
|
|
||||||
m_slotIndex = 10; // dummy slot for last skipped symbols
|
|
||||||
return symbolInMajorBlockIndex - 54+12+36+18+24+18+36+12+54+24;
|
|
||||||
}
|
|
||||||
else // cannot go there if using this function in its valid context (input is a remainder of division by 288)
|
else // cannot go there if using this function in its valid context (input is a remainder of division by 288)
|
||||||
{
|
{
|
||||||
m_slotIndex = -1; // invalid slot
|
m_slotIndex = -1; // invalid slot
|
||||||
|
@ -59,6 +59,9 @@ DSDDemod::DSDDemod(SampleSink* sampleSink) :
|
|||||||
m_audioBuffer.resize(1<<14);
|
m_audioBuffer.resize(1<<14);
|
||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
|
|
||||||
|
m_sampleBuffer = new qint16[1<<17]; // 128 kS
|
||||||
|
m_sampleBufferIndex = 0;
|
||||||
|
|
||||||
m_movingAverage.resize(16, 0);
|
m_movingAverage.resize(16, 0);
|
||||||
|
|
||||||
DSPEngine::instance()->addAudioSink(&m_audioFifo);
|
DSPEngine::instance()->addAudioSink(&m_audioFifo);
|
||||||
@ -66,6 +69,7 @@ DSDDemod::DSDDemod(SampleSink* sampleSink) :
|
|||||||
|
|
||||||
DSDDemod::~DSDDemod()
|
DSDDemod::~DSDDemod()
|
||||||
{
|
{
|
||||||
|
delete[] m_sampleBuffer;
|
||||||
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
|
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +106,7 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
|
|
||||||
if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, c, &ci))
|
if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, c, &ci))
|
||||||
{
|
{
|
||||||
qint16 sample;
|
qint16 sample, delayedSample;
|
||||||
|
|
||||||
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())) / (Real) (1<<30);
|
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())) / (Real) (1<<30);
|
||||||
m_movingAverage.feed(m_magsq);
|
m_movingAverage.feed(m_magsq);
|
||||||
@ -135,40 +139,53 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
sample = 0;
|
sample = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sample s(sample, 0.0);
|
if (m_sampleBufferIndex < (1<<17)) {
|
||||||
|
m_sampleBufferIndex++;
|
||||||
|
} else {
|
||||||
|
m_sampleBufferIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sampleBuffer[m_sampleBufferIndex] = sample;
|
||||||
|
|
||||||
|
if (m_sampleBufferIndex < 20) {
|
||||||
|
delayedSample = m_sampleBuffer[(1<<17) - 20 + m_sampleBufferIndex];
|
||||||
|
} else {
|
||||||
|
delayedSample = m_sampleBuffer[m_sampleBufferIndex - 20];
|
||||||
|
}
|
||||||
|
|
||||||
|
Sample s(sample, delayedSample); // I=signal, Q=signal delayed by 20 samples (2400 baud: lowest rate)
|
||||||
m_scopeSampleBuffer.push_back(s);
|
m_scopeSampleBuffer.push_back(s);
|
||||||
m_dsdDecoder.pushSample(sample);
|
m_dsdDecoder.pushSample(sample);
|
||||||
|
|
||||||
// if (m_running.m_audioMute)
|
// if (m_running.m_audioMute)
|
||||||
// {
|
// {
|
||||||
// m_audioBuffer[m_audioBufferFill].l = 0;
|
// m_audioBuffer[m_audioBufferFill].l = 0;
|
||||||
// m_audioBuffer[m_audioBufferFill].r = 0;
|
// m_audioBuffer[m_audioBufferFill].r = 0;
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// m_audioBuffer[m_audioBufferFill].l = sample;
|
// m_audioBuffer[m_audioBufferFill].l = (sample * m_running.m_volume) / 100;
|
||||||
// m_audioBuffer[m_audioBufferFill].r = sample;
|
// m_audioBuffer[m_audioBufferFill].r = (sample * m_running.m_volume) / 100;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// ++m_audioBufferFill;
|
// ++m_audioBufferFill;
|
||||||
//
|
//
|
||||||
// if (m_audioBufferFill >= m_audioBuffer.size())
|
// if (m_audioBufferFill >= m_audioBuffer.size())
|
||||||
// {
|
// {
|
||||||
// uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 10);
|
// uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 10);
|
||||||
//
|
//
|
||||||
// if (res != m_audioBufferFill)
|
// if (res != m_audioBufferFill)
|
||||||
// {
|
// {
|
||||||
// qDebug("DSDDemod::feed: %u/%u audio samples written", res, m_audioBufferFill);
|
// qDebug("DSDDemod::feed: %u/%u audio samples written", res, m_audioBufferFill);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// m_audioBufferFill = 0;
|
// m_audioBufferFill = 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
m_interpolatorDistanceRemain += m_interpolatorDistance;
|
m_interpolatorDistanceRemain += m_interpolatorDistance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if (m_audioBufferFill > 0)
|
// if (m_audioBufferFill > 0)
|
||||||
// {
|
// {
|
||||||
// uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 10);
|
// uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 10);
|
||||||
@ -182,18 +199,23 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
int nbAudioSamples;
|
int nbAudioSamples;
|
||||||
short *audio = m_dsdDecoder.getAudio(nbAudioSamples);
|
short *dsdAudio = m_dsdDecoder.getAudio(nbAudioSamples);
|
||||||
|
|
||||||
if (nbAudioSamples > 0)
|
if (nbAudioSamples > 0)
|
||||||
{
|
{
|
||||||
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], nbAudioSamples, 10);
|
uint res = m_audioFifo.write((const quint8*) dsdAudio, nbAudioSamples, 10);
|
||||||
|
qDebug("DSDDemod::feed: written %d audio samples (%d)", res, nbAudioSamples);
|
||||||
if (res != nbAudioSamples)
|
m_dsdDecoder.resetAudio();
|
||||||
{
|
// qDebug("\nDSDDemod::feed: got %d audio samples (%lu)", nbAudioSamples, m_audioBuffer.size());
|
||||||
qDebug("NFMDemod::feed: %u/%u tail samples written", res, nbAudioSamples);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (nbAudioSamples >= m_audioBuffer.size())
|
||||||
|
// {
|
||||||
|
// uint res = m_audioFifo.write((const quint8*) dsdAudio, nbAudioSamples, 10);
|
||||||
|
// qDebug("DSDDemod::feed: written %d audio samples (%d)", res, nbAudioSamples);
|
||||||
|
// m_dsdDecoder.resetAudio();
|
||||||
|
// }
|
||||||
|
|
||||||
if ((m_scope != 0) && (m_scopeEnabled))
|
if ((m_scope != 0) && (m_scopeEnabled))
|
||||||
{
|
{
|
||||||
m_scope->feed(m_scopeSampleBuffer.begin(), m_scopeSampleBuffer.end(), true); // true = real samples for what it's worth
|
m_scope->feed(m_scopeSampleBuffer.begin(), m_scopeSampleBuffer.end(), true); // true = real samples for what it's worth
|
||||||
|
@ -172,6 +172,8 @@ private:
|
|||||||
SampleVector m_scopeSampleBuffer;
|
SampleVector m_scopeSampleBuffer;
|
||||||
AudioVector m_audioBuffer;
|
AudioVector m_audioBuffer;
|
||||||
uint m_audioBufferFill;
|
uint m_audioBufferFill;
|
||||||
|
qint16 *m_sampleBuffer; //!< samples ring buffer
|
||||||
|
int m_sampleBufferIndex;
|
||||||
|
|
||||||
AudioFifo m_audioFifo;
|
AudioFifo m_audioFifo;
|
||||||
SampleSink* m_scope;
|
SampleSink* m_scope;
|
||||||
|
@ -151,7 +151,7 @@ void FileSourceGui::handleSourceMessages()
|
|||||||
|
|
||||||
while ((message = m_sampleSource->getOutputMessageQueueToGUI()->pop()) != 0)
|
while ((message = m_sampleSource->getOutputMessageQueueToGUI()->pop()) != 0)
|
||||||
{
|
{
|
||||||
qDebug("FileSourceGui::handleSourceMessages: message: %s", message->getIdentifier());
|
//qDebug("FileSourceGui::handleSourceMessages: message: %s", message->getIdentifier());
|
||||||
|
|
||||||
if (handleMessage(*message))
|
if (handleMessage(*message))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user