mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
Audio Input: handle real signals with new main spectrum feature
This commit is contained in:
parent
249cb476c0
commit
d1116b564a
@ -346,11 +346,9 @@ void AudioInput::applySettings(const AudioInputSettings& settings, QList<QString
|
|||||||
|
|
||||||
if (forwardChange)
|
if (forwardChange)
|
||||||
{
|
{
|
||||||
qint64 dF =
|
bool realElseComplex = (m_settings.m_iqMapping == AudioInputSettings::L)
|
||||||
((m_settings.m_iqMapping == AudioInputSettings::IQMapping::L) ||
|
|| (m_settings.m_iqMapping == AudioInputSettings::R);
|
||||||
(m_settings.m_iqMapping == AudioInputSettings::IQMapping::R)) ?
|
DSPSignalNotification *notif = new DSPSignalNotification(m_settings.m_sampleRate/(1<<m_settings.m_log2Decim), 0, realElseComplex);
|
||||||
m_settings.m_sampleRate / 4 : 0;
|
|
||||||
DSPSignalNotification *notif = new DSPSignalNotification(m_settings.m_sampleRate/(1<<m_settings.m_log2Decim), dF);
|
|
||||||
m_sampleRate = notif->getSampleRate();
|
m_sampleRate = notif->getSampleRate();
|
||||||
m_centerFrequency = notif->getCenterFrequency();
|
m_centerFrequency = notif->getCenterFrequency();
|
||||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||||
|
@ -104,7 +104,18 @@ bool AudioInputGui::deserialize(const QByteArray& data)
|
|||||||
|
|
||||||
bool AudioInputGui::handleMessage(const Message& message)
|
bool AudioInputGui::handleMessage(const Message& message)
|
||||||
{
|
{
|
||||||
if (AudioInput::MsgConfigureAudioInput::match(message))
|
if (DSPSignalNotification::match(message))
|
||||||
|
{
|
||||||
|
const DSPSignalNotification& notif = (DSPSignalNotification&) message;
|
||||||
|
m_sampleRate = notif.getSampleRate();
|
||||||
|
m_centerFrequency = notif.getCenterFrequency();
|
||||||
|
qDebug("AudioInputGui::handleInputMessages: DSPSignalNotification: SampleRate: %d", notif.getSampleRate());
|
||||||
|
updateSampleRateAndFrequency();
|
||||||
|
updateSpectrum();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (AudioInput::MsgConfigureAudioInput::match(message))
|
||||||
{
|
{
|
||||||
const AudioInput::MsgConfigureAudioInput& cfg = (AudioInput::MsgConfigureAudioInput&) message;
|
const AudioInput::MsgConfigureAudioInput& cfg = (AudioInput::MsgConfigureAudioInput&) message;
|
||||||
|
|
||||||
@ -117,6 +128,7 @@ bool AudioInputGui::handleMessage(const Message& message)
|
|||||||
blockApplySettings(true);
|
blockApplySettings(true);
|
||||||
displaySettings();
|
displaySettings();
|
||||||
blockApplySettings(false);
|
blockApplySettings(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (AudioInput::MsgStartStop::match(message))
|
else if (AudioInput::MsgStartStop::match(message))
|
||||||
@ -142,23 +154,9 @@ void AudioInputGui::handleInputMessages()
|
|||||||
{
|
{
|
||||||
qDebug("AudioInputGui::handleInputMessages: message: %s", message->getIdentifier());
|
qDebug("AudioInputGui::handleInputMessages: message: %s", message->getIdentifier());
|
||||||
|
|
||||||
if (DSPSignalNotification::match(*message))
|
if (handleMessage(*message)) {
|
||||||
{
|
|
||||||
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
|
||||||
m_sampleRate = notif->getSampleRate();
|
|
||||||
m_centerFrequency = notif->getCenterFrequency();
|
|
||||||
qDebug("AudioInputGui::handleInputMessages: DSPSignalNotification: SampleRate: %d", notif->getSampleRate());
|
|
||||||
updateSampleRateAndFrequency();
|
|
||||||
|
|
||||||
delete message;
|
delete message;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (handleMessage(*message))
|
|
||||||
{
|
|
||||||
delete message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,6 +244,7 @@ void AudioInputGui::displaySettings()
|
|||||||
ui->iqImbalance->setChecked(m_settings.m_iqImbalance);
|
ui->iqImbalance->setChecked(m_settings.m_iqImbalance);
|
||||||
refreshSampleRates(ui->device->currentText());
|
refreshSampleRates(ui->device->currentText());
|
||||||
displayFcTooltip();
|
displayFcTooltip();
|
||||||
|
updateSpectrum();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInputGui::displayFcTooltip()
|
void AudioInputGui::displayFcTooltip()
|
||||||
@ -259,6 +258,15 @@ void AudioInputGui::displayFcTooltip()
|
|||||||
ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number(fShift / 1000.0f, 'g', 5)));
|
ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number(fShift / 1000.0f, 'g', 5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioInputGui::updateSpectrum()
|
||||||
|
{
|
||||||
|
bool realElseComplex = (m_settings.m_iqMapping == AudioInputSettings::L)
|
||||||
|
|| (m_settings.m_iqMapping == AudioInputSettings::R);
|
||||||
|
m_deviceUISet->getSpectrum()->setCenterFrequency(0);
|
||||||
|
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
|
||||||
|
m_deviceUISet->getSpectrum()->setSsbSpectrum(realElseComplex);
|
||||||
|
}
|
||||||
|
|
||||||
void AudioInputGui::on_device_currentIndexChanged(int index)
|
void AudioInputGui::on_device_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
(void) index;
|
(void) index;
|
||||||
|
@ -66,6 +66,7 @@ private:
|
|||||||
void refreshSampleRates(QString deviceName);
|
void refreshSampleRates(QString deviceName);
|
||||||
void displaySettings();
|
void displaySettings();
|
||||||
void displayFcTooltip();
|
void displayFcTooltip();
|
||||||
|
void updateSpectrum();
|
||||||
void sendSettings();
|
void sendSettings();
|
||||||
void updateSampleRateAndFrequency();
|
void updateSampleRateAndFrequency();
|
||||||
bool handleMessage(const Message& message);
|
bool handleMessage(const Message& message);
|
||||||
|
@ -386,6 +386,9 @@
|
|||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="pageStep">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -33,8 +33,7 @@ AudioInputWorker::AudioInputWorker(SampleSinkFifo* sampleFifo, AudioFifo *fifo,
|
|||||||
m_log2Decim(0),
|
m_log2Decim(0),
|
||||||
m_iqMapping(AudioInputSettings::IQMapping::L),
|
m_iqMapping(AudioInputSettings::IQMapping::L),
|
||||||
m_convertBuffer(m_convBufSamples),
|
m_convertBuffer(m_convBufSamples),
|
||||||
m_sampleFifo(sampleFifo),
|
m_sampleFifo(sampleFifo)
|
||||||
m_quNCOPhase(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,31 +61,10 @@ void AudioInputWorker::workIQ(unsigned int nbRead)
|
|||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < nbRead; i++)
|
for (uint32_t i = 0; i < nbRead; i++)
|
||||||
{
|
{
|
||||||
qint16 r = m_buf[i*2 + (m_iqMapping == AudioInputSettings::IQMapping::R ? 1 : 0)]; // real sample
|
if (m_iqMapping == AudioInputSettings::IQMapping::L) {
|
||||||
|
m_buf[i*2+1] = m_buf[i*2];
|
||||||
if (m_quNCOPhase == 0) // 0
|
} else {
|
||||||
{
|
m_buf[i*2] = m_buf[i*2+1];
|
||||||
m_buf[i*2] = r; // 1
|
|
||||||
m_buf[i*2+1] = 0; // 0
|
|
||||||
m_quNCOPhase = 1; // next phase
|
|
||||||
}
|
|
||||||
else if (m_quNCOPhase == 1) // -pi/2
|
|
||||||
{
|
|
||||||
m_buf[i*2] = 0; // 0
|
|
||||||
m_buf[i*2+1] = -r; // -1
|
|
||||||
m_quNCOPhase = 2; // next phase
|
|
||||||
}
|
|
||||||
else if (m_quNCOPhase == 2) // pi or -pi
|
|
||||||
{
|
|
||||||
m_buf[i*2] = -r; // -1
|
|
||||||
m_buf[i*2+1] = 0; // 0
|
|
||||||
m_quNCOPhase = 3; // next phase
|
|
||||||
}
|
|
||||||
else if (m_quNCOPhase == 3) // pi/2
|
|
||||||
{
|
|
||||||
m_buf[i*2] = 0; // 0
|
|
||||||
m_buf[i*2+1] = r; // 1
|
|
||||||
m_quNCOPhase = 0; // next phase
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ private:
|
|||||||
SampleVector m_convertBuffer;
|
SampleVector m_convertBuffer;
|
||||||
SampleSinkFifo* m_sampleFifo;
|
SampleSinkFifo* m_sampleFifo;
|
||||||
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 16, true> m_decimatorsIQ;
|
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 16, true> m_decimatorsIQ;
|
||||||
int m_quNCOPhase; //!< Quarter sample rate pseudo NCO phase index (0, 90, 180, 270)
|
|
||||||
|
|
||||||
void workIQ(unsigned int nbRead);
|
void workIQ(unsigned int nbRead);
|
||||||
void decimate(qint16 *buf, unsigned int nbRead);
|
void decimate(qint16 *buf, unsigned int nbRead);
|
||||||
|
Loading…
Reference in New Issue
Block a user