mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-07 16:34:45 -04:00
DSD demod: allow use of audio rates that are integer multiples of 8k other than 48k (x2,3,4,5)
This commit is contained in:
@@ -164,10 +164,10 @@ void DSPEngine::pushMbeFrame(
|
||||
int mbeVolumeIndex,
|
||||
unsigned char channels,
|
||||
bool useHP,
|
||||
bool upSample48k,
|
||||
int upsampling,
|
||||
AudioFifo *audioFifo)
|
||||
{
|
||||
m_dvSerialEngine.pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useHP, upSample48k, audioFifo);
|
||||
m_dvSerialEngine.pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useHP, upsampling, audioFifo);
|
||||
}
|
||||
#else
|
||||
void DSPEngine::pushMbeFrame(
|
||||
@@ -176,7 +176,7 @@ void DSPEngine::pushMbeFrame(
|
||||
int mbeVolumeIndex __attribute((unused)),
|
||||
unsigned char channels __attribute((unused)),
|
||||
bool useHP __attribute((unused)),
|
||||
bool upSample48k __attribute((unused)),
|
||||
int upsampling __attribute((unused)),
|
||||
AudioFifo *audioFifo __attribute((unused)))
|
||||
{}
|
||||
#endif
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
int mbeVolumeIndex,
|
||||
unsigned char channels,
|
||||
bool useHP,
|
||||
bool upSample48k,
|
||||
int upsampling,
|
||||
AudioFifo *audioFifo);
|
||||
|
||||
const QTimer& getMasterTimer() const { return m_masterTimer; }
|
||||
|
||||
@@ -253,7 +253,7 @@ void DVSerialEngine::pushMbeFrame(
|
||||
int mbeVolumeIndex,
|
||||
unsigned char channels,
|
||||
bool useLP,
|
||||
bool upSample48k,
|
||||
int upsampling,
|
||||
AudioFifo *audioFifo)
|
||||
{
|
||||
std::vector<DVSerialController>::iterator it = m_controllers.begin();
|
||||
@@ -265,7 +265,7 @@ void DVSerialEngine::pushMbeFrame(
|
||||
{
|
||||
if (it->worker->hasFifo(audioFifo))
|
||||
{
|
||||
it->worker->pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useLP, upSample48k, audioFifo);
|
||||
it->worker->pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useLP, upsampling, audioFifo);
|
||||
done = true;
|
||||
}
|
||||
else if (it->worker->isAvailable())
|
||||
@@ -283,7 +283,7 @@ void DVSerialEngine::pushMbeFrame(
|
||||
int wNum = itAvail - m_controllers.begin();
|
||||
|
||||
qDebug("DVSerialEngine::pushMbeFrame: push %p on empty queue %d", audioFifo, wNum);
|
||||
itAvail->worker->pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useLP, upSample48k, audioFifo);
|
||||
itAvail->worker->pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useLP, upsampling, audioFifo);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
int mbeVolumeIndex,
|
||||
unsigned char channels,
|
||||
bool useHP,
|
||||
bool upSample48k,
|
||||
int upsampling,
|
||||
AudioFifo *audioFifo);
|
||||
|
||||
private:
|
||||
|
||||
@@ -86,8 +86,11 @@ void DVSerialWorker::handleInputMessages()
|
||||
|
||||
if (m_dvController.decode(m_dvAudioSamples, decodeMsg->getMbeFrame(), decodeMsg->getMbeRate(), dBVolume))
|
||||
{
|
||||
if (decodeMsg->getUpsample48k()) {
|
||||
upsample6(m_dvAudioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE, decodeMsg->getChannels());
|
||||
int upsampling = decodeMsg->getUpsampling();
|
||||
upsampling = upsampling > 6 ? 6 : upsampling < 1 ? 1 : upsampling;
|
||||
|
||||
if (upsampling > 1) {
|
||||
upsample(upsampling, m_dvAudioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE, decodeMsg->getChannels());
|
||||
} else {
|
||||
noUpsample(m_dvAudioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE, decodeMsg->getChannels());
|
||||
}
|
||||
@@ -121,11 +124,11 @@ void DVSerialWorker::pushMbeFrame(const unsigned char *mbeFrame,
|
||||
int mbeVolumeIndex,
|
||||
unsigned char channels,
|
||||
bool useHP,
|
||||
bool upSample48k,
|
||||
int upsampling,
|
||||
AudioFifo *audioFifo)
|
||||
{
|
||||
m_audioFifo = audioFifo;
|
||||
m_inputMessageQueue.push(MsgMbeDecode::create(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useHP, upSample48k, audioFifo));
|
||||
m_inputMessageQueue.push(MsgMbeDecode::create(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useHP, upsampling, audioFifo));
|
||||
}
|
||||
|
||||
bool DVSerialWorker::isAvailable()
|
||||
@@ -170,6 +173,34 @@ void DVSerialWorker::upsample6(short *in, int nbSamplesIn, unsigned char channel
|
||||
}
|
||||
}
|
||||
|
||||
void DVSerialWorker::upsample(int upsampling, short *in, int nbSamplesIn, unsigned char channels)
|
||||
{
|
||||
for (int i = 0; i < nbSamplesIn; i++)
|
||||
{
|
||||
int cur = (int) in[i];
|
||||
int prev = (int) m_upsamplerLastValue;
|
||||
qint16 upsample;
|
||||
|
||||
for (int j = 1; j <= upsampling; j++)
|
||||
{
|
||||
upsample = m_upsampleFilter.run((qint16) ((cur*j + prev*(upsampling-j)) / upsampling));
|
||||
m_audioBuffer[m_audioBufferFill].l = channels & 1 ? upsample : 0;
|
||||
m_audioBuffer[m_audioBufferFill].r = (channels>>1) & 1 ? upsample : 0;
|
||||
|
||||
if (m_audioBufferFill < m_audioBuffer.size() - 1)
|
||||
{
|
||||
++m_audioBufferFill;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("DVSerialWorker::upsample6: audio buffer is full check its size");
|
||||
}
|
||||
}
|
||||
|
||||
m_upsamplerLastValue = in[i];
|
||||
}
|
||||
}
|
||||
|
||||
void DVSerialWorker::noUpsample(short *in, int nbSamplesIn, unsigned char channels)
|
||||
{
|
||||
for (int i = 0; i < nbSamplesIn; i++)
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
int getVolumeIndex() const { return m_volumeIndex; }
|
||||
unsigned char getChannels() const { return m_channels % 4; }
|
||||
bool getUseHP() const { return m_useHP; }
|
||||
bool getUpsample48k() const { return m_upSample48k; }
|
||||
int getUpsampling() const { return m_upsampling; }
|
||||
AudioFifo *getAudioFifo() { return m_audioFifo; }
|
||||
|
||||
static MsgMbeDecode* create(
|
||||
@@ -65,10 +65,10 @@ public:
|
||||
int volumeIndex,
|
||||
unsigned char channels,
|
||||
bool useHP,
|
||||
bool upSample48k,
|
||||
int upsampling,
|
||||
AudioFifo *audioFifo)
|
||||
{
|
||||
return new MsgMbeDecode(mbeFrame, (SerialDV::DVRate) mbeRateIndex, volumeIndex, channels, useHP, upSample48k, audioFifo);
|
||||
return new MsgMbeDecode(mbeFrame, (SerialDV::DVRate) mbeRateIndex, volumeIndex, channels, useHP, upsampling, audioFifo);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
int m_volumeIndex;
|
||||
unsigned char m_channels;
|
||||
bool m_useHP;
|
||||
bool m_upSample48k;
|
||||
int m_upsampling;
|
||||
AudioFifo *m_audioFifo;
|
||||
|
||||
MsgMbeDecode(const unsigned char *mbeFrame,
|
||||
@@ -85,14 +85,14 @@ public:
|
||||
int volumeIndex,
|
||||
unsigned char channels,
|
||||
bool useHP,
|
||||
bool upSample48k,
|
||||
int upsampling,
|
||||
AudioFifo *audioFifo) :
|
||||
Message(),
|
||||
m_mbeRate(mbeRate),
|
||||
m_volumeIndex(volumeIndex),
|
||||
m_channels(channels),
|
||||
m_useHP(useHP),
|
||||
m_upSample48k(upSample48k),
|
||||
m_upsampling(upsampling),
|
||||
m_audioFifo(audioFifo)
|
||||
{
|
||||
memcpy((void *) m_mbeFrame, (const void *) mbeFrame, SerialDV::DVController::getNbMbeBytes(m_mbeRate));
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
int mbeVolumeIndex,
|
||||
unsigned char channels,
|
||||
bool useHP,
|
||||
bool upSample48k,
|
||||
int upsampling,
|
||||
AudioFifo *audioFifo);
|
||||
|
||||
bool open(const std::string& serialDevice);
|
||||
@@ -136,6 +136,7 @@ public slots:
|
||||
private:
|
||||
//void upsample6(short *in, short *out, int nbSamplesIn);
|
||||
void upsample6(short *in, int nbSamplesIn, unsigned char channels);
|
||||
void upsample(int upsampling, short *in, int nbSamplesIn, unsigned char channels);
|
||||
void noUpsample(short *in, int nbSamplesIn, unsigned char channels);
|
||||
|
||||
SerialDV::DVController m_dvController;
|
||||
|
||||
Reference in New Issue
Block a user