mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
DSD demod plugin: DMR refactoring: allow stereo split of TDMA channels. Works with DVSerial too now.
This commit is contained in:
parent
6dfa20db20
commit
f64d078375
@ -201,8 +201,14 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
||||
{
|
||||
if ((m_running.m_slot1On) && m_dsdDecoder.mbeDVReady1())
|
||||
{
|
||||
if (!m_running.m_audioMute) {
|
||||
DSPEngine::instance()->pushMbeFrame(m_dsdDecoder.getMbeDVFrame1(), m_dsdDecoder.getMbeRateIndex(), m_running.m_volume, &m_audioFifo1);
|
||||
if (!m_running.m_audioMute)
|
||||
{
|
||||
DSPEngine::instance()->pushMbeFrame(
|
||||
m_dsdDecoder.getMbeDVFrame1(),
|
||||
m_dsdDecoder.getMbeRateIndex(),
|
||||
m_running.m_volume,
|
||||
m_running.m_tdmaStereo ? 1 : 3, // left or both channels
|
||||
&m_audioFifo1);
|
||||
}
|
||||
|
||||
m_dsdDecoder.resetMbeDV1();
|
||||
@ -210,8 +216,14 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
||||
|
||||
if ((m_running.m_slot2On) && m_dsdDecoder.mbeDVReady2())
|
||||
{
|
||||
if (!m_running.m_audioMute) {
|
||||
DSPEngine::instance()->pushMbeFrame(m_dsdDecoder.getMbeDVFrame2(), m_dsdDecoder.getMbeRateIndex(), m_running.m_volume, &m_audioFifo2);
|
||||
if (!m_running.m_audioMute)
|
||||
{
|
||||
DSPEngine::instance()->pushMbeFrame(
|
||||
m_dsdDecoder.getMbeDVFrame2(),
|
||||
m_dsdDecoder.getMbeRateIndex(),
|
||||
m_running.m_volume,
|
||||
m_running.m_tdmaStereo ? 2 : 3, // right or both channels
|
||||
&m_audioFifo2);
|
||||
}
|
||||
|
||||
m_dsdDecoder.resetMbeDV2();
|
||||
|
@ -76,10 +76,10 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, AudioFifo *audioFifo)
|
||||
void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, unsigned char channels, AudioFifo *audioFifo)
|
||||
{
|
||||
#ifdef DSD_USE_SERIALDV
|
||||
m_dvSerialEngine.pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, audioFifo);
|
||||
m_dvSerialEngine.pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, audioFifo);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ void DVSerialEngine::getDevicesNames(std::vector<std::string>& deviceNames)
|
||||
}
|
||||
}
|
||||
|
||||
void DVSerialEngine::pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, AudioFifo *audioFifo)
|
||||
void DVSerialEngine::pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, unsigned char channels, AudioFifo *audioFifo)
|
||||
{
|
||||
std::vector<DVSerialController>::iterator it = m_controllers.begin();
|
||||
|
||||
@ -252,7 +252,7 @@ void DVSerialEngine::pushMbeFrame(const unsigned char *mbeFrame, int mbeRateInde
|
||||
{
|
||||
if (it->worker->m_inputMessageQueue.size() < 2)
|
||||
{
|
||||
it->worker->m_inputMessageQueue.push(DVSerialWorker::MsgMbeDecode::create(mbeFrame, mbeRateIndex, mbeVolumeIndex, audioFifo));
|
||||
it->worker->m_inputMessageQueue.push(DVSerialWorker::MsgMbeDecode::create(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, audioFifo));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
int getNbDevices() const { return m_controllers.size(); }
|
||||
void getDevicesNames(std::vector<std::string>& devicesNames);
|
||||
|
||||
void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, AudioFifo *audioFifo);
|
||||
void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, unsigned char channels, AudioFifo *audioFifo);
|
||||
|
||||
private:
|
||||
struct DVSerialController
|
||||
|
@ -80,7 +80,7 @@ void DVSerialWorker::handleInputMessages()
|
||||
|
||||
if (m_dvController.decode(m_dvAudioSamples, decodeMsg->getMbeFrame(), decodeMsg->getMbeRate(), dBVolume))
|
||||
{
|
||||
upsample6(m_dvAudioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE, decodeMsg->getAudioFifo());
|
||||
upsample6(m_dvAudioSamples, SerialDV::MBE_AUDIO_BLOCK_SIZE, decodeMsg->getChannels(), 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);
|
||||
}
|
||||
@ -94,7 +94,7 @@ void DVSerialWorker::handleInputMessages()
|
||||
}
|
||||
}
|
||||
|
||||
void DVSerialWorker::upsample6(short *in, int nbSamplesIn, AudioFifo *audioFifo)
|
||||
void DVSerialWorker::upsample6(short *in, int nbSamplesIn, unsigned char channels, AudioFifo *audioFifo)
|
||||
{
|
||||
for (int i = 0; i < nbSamplesIn; i++)
|
||||
{
|
||||
@ -105,8 +105,8 @@ void DVSerialWorker::upsample6(short *in, int nbSamplesIn, AudioFifo *audioFifo)
|
||||
for (int j = 1; j < 7; j++)
|
||||
{
|
||||
upsample = (qint16) ((cur*j + prev*(6-j)) / 6);
|
||||
m_audioBuffer[m_audioBufferFill].l = upsample;
|
||||
m_audioBuffer[m_audioBufferFill].r = upsample;
|
||||
m_audioBuffer[m_audioBufferFill].l = channels & 1 ? upsample : 0;
|
||||
m_audioBuffer[m_audioBufferFill].r = (channels>>1) & 1 ? upsample : 0;
|
||||
++m_audioBufferFill;
|
||||
|
||||
if (m_audioBufferFill >= m_audioBuffer.size())
|
||||
|
@ -49,26 +49,30 @@ public:
|
||||
const unsigned char *getMbeFrame() const { return m_mbeFrame; }
|
||||
SerialDV::DVRate getMbeRate() const { return m_mbeRate; }
|
||||
int getVolumeIndex() const { return m_volumeIndex; }
|
||||
unsigned char getChannels() const { return m_channels % 4; }
|
||||
AudioFifo *getAudioFifo() { return m_audioFifo; }
|
||||
|
||||
static MsgMbeDecode* create(const unsigned char *mbeFrame, int mbeRateIndex, int volumeIndex, AudioFifo *audioFifo)
|
||||
static MsgMbeDecode* create(const unsigned char *mbeFrame, int mbeRateIndex, int volumeIndex, unsigned char channels, AudioFifo *audioFifo)
|
||||
{
|
||||
return new MsgMbeDecode(mbeFrame, (SerialDV::DVRate) mbeRateIndex, volumeIndex, audioFifo);
|
||||
return new MsgMbeDecode(mbeFrame, (SerialDV::DVRate) mbeRateIndex, volumeIndex, channels, audioFifo);
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned char m_mbeFrame[SerialDV::MBE_FRAME_LENGTH_BYTES];
|
||||
SerialDV::DVRate m_mbeRate;
|
||||
int m_volumeIndex;
|
||||
unsigned char m_channels;
|
||||
AudioFifo *m_audioFifo;
|
||||
|
||||
MsgMbeDecode(const unsigned char *mbeFrame,
|
||||
SerialDV::DVRate mbeRate,
|
||||
int volumeIndex,
|
||||
unsigned char channels,
|
||||
AudioFifo *audioFifo) :
|
||||
Message(),
|
||||
m_mbeRate(mbeRate),
|
||||
m_volumeIndex(volumeIndex),
|
||||
m_channels(channels),
|
||||
m_audioFifo(audioFifo)
|
||||
{
|
||||
memcpy((void *) m_mbeFrame, (const void *) mbeFrame, SerialDV::MBE_FRAME_LENGTH_BYTES);
|
||||
@ -107,7 +111,7 @@ private:
|
||||
typedef std::vector<AudioSample> AudioVector;
|
||||
|
||||
void upsample6(short *in, short *out, int nbSamplesIn);
|
||||
void upsample6(short *in, int nbSamplesIn, AudioFifo *audioFifo);
|
||||
void upsample6(short *in, int nbSamplesIn, unsigned char channels, AudioFifo *audioFifo);
|
||||
|
||||
SerialDV::DVController m_dvController;
|
||||
bool m_running;
|
||||
|
Loading…
Reference in New Issue
Block a user