1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -05:00

DSD demod DV serial support revised audio processing

This commit is contained in:
f4exb 2016-05-09 01:26:39 +02:00
parent ea4dbc550a
commit ba71089aff
3 changed files with 69 additions and 4 deletions

View File

@ -23,6 +23,7 @@ DSPEngine::DSPEngine() :
m_audioSampleRate(48000) // Use default output device at 48 kHz
{
m_deviceEngine = new DSPDeviceEngine();
m_dvSerialSupport = false;
}
DSPEngine::~DSPEngine()

View File

@ -27,8 +27,11 @@ DVSerialWorker::DVSerialWorker() :
m_running(false),
m_currentGainIn(0),
m_currentGainOut(0),
m_upsamplerLastValue(0)
m_upsamplerLastValue(0),
m_phase(0)
{
m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0;
}
DVSerialWorker::~DVSerialWorker()
@ -77,8 +80,9 @@ void DVSerialWorker::handleInputMessages()
if (m_dvController.decode(m_dvAudioSamples, decodeMsg->getMbeFrame(), decodeMsg->getMbeRate(), dBVolume))
{
upsample6(m_dvAudioSamples, m_audioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE);
decodeMsg->getAudioFifo()->write((const quint8 *) m_audioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE * 6, 10);
upsample6(m_dvAudioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE, decodeMsg->getAudioFifo());
// upsample6(m_dvAudioSamples, m_audioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE);
// decodeMsg->getAudioFifo()->write((const quint8 *) m_audioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE * 6, 10);
}
}
@ -86,6 +90,38 @@ void DVSerialWorker::handleInputMessages()
}
}
void DVSerialWorker::upsample6(short *in, int nbSamplesIn, AudioFifo *audioFifo)
{
for (int i = 0; i < nbSamplesIn; i++)
{
int cur = (int) in[i];
int prev = (int) m_upsamplerLastValue;
qint16 upsample;
for (int j = 1; j < 7; j++)
{
upsample = (qint16) ((cur*i + prev*(6-i)) / 6);
m_audioBuffer[m_audioBufferFill].l = upsample;
m_audioBuffer[m_audioBufferFill].r = upsample;
++m_audioBufferFill;
if (m_audioBufferFill >= m_audioBuffer.size())
{
uint res = audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 10);
if (res != m_audioBufferFill)
{
qDebug("DVSerialWorker::upsample6: %u/%u audio samples written", res, m_audioBufferFill);
}
m_audioBufferFill = 0;
}
}
m_upsamplerLastValue = in[i];
}
}
void DVSerialWorker::upsample6(short *in, short *out, int nbSamplesIn)
{
for (int i = 0; i < nbSamplesIn; i++)
@ -94,6 +130,21 @@ void DVSerialWorker::upsample6(short *in, short *out, int nbSamplesIn)
int prev = (int) m_upsamplerLastValue;
short up;
// for (int j = 0; j < 6; j++)
// {
// up = 32768.0f * cos(m_phase);
// *out = up;
// out ++;
// *out = up;
// out ++;
// m_phase += M_PI / 6.0;
// }
//
// if ((i % 2) == 1)
// {
// m_phase = 0.0f;
// }
up = (cur*1 + prev*5) / 6;
*out = up;
out++;

View File

@ -21,6 +21,8 @@
#include <QObject>
#include <QDebug>
#include <vector>
#include "dvcontroller.h"
#include "util/message.h"
#include "util/syncmessenger.h"
@ -97,15 +99,26 @@ public slots:
void handleInputMessages();
private:
struct AudioSample {
qint16 l;
qint16 r;
};
typedef std::vector<AudioSample> AudioVector;
void upsample6(short *in, short *out, int nbSamplesIn);
void upsample6(short *in, int nbSamplesIn, AudioFifo *audioFifo);
SerialDV::DVController m_dvController;
bool m_running;
int m_currentGainIn;
int m_currentGainOut;
short m_dvAudioSamples[SerialDV::MBE_AUDIO_BLOCK_SIZE];
short m_audioSamples[SerialDV::MBE_AUDIO_BLOCK_SIZE * 6 * 2]; // upsample to 48k and duplicate channel
//short m_audioSamples[SerialDV::MBE_AUDIO_BLOCK_SIZE * 6 * 2]; // upsample to 48k and duplicate channel
AudioVector m_audioBuffer;
uint m_audioBufferFill;
short m_upsamplerLastValue;
float m_phase;
};
#endif /* SDRBASE_DSP_DVSERIALWORKER_H_ */