kopia lustrzana https://github.com/f4exb/sdrangel
				
				
				
			Audio Input: handle real signals with new main spectrum feature
							rodzic
							
								
									249cb476c0
								
							
						
					
					
						commit
						d1116b564a
					
				| 
						 | 
				
			
			@ -346,11 +346,9 @@ void AudioInput::applySettings(const AudioInputSettings& settings, QList<QString
 | 
			
		|||
 | 
			
		||||
    if (forwardChange)
 | 
			
		||||
    {
 | 
			
		||||
        qint64 dF =
 | 
			
		||||
            ((m_settings.m_iqMapping == AudioInputSettings::IQMapping::L) ||
 | 
			
		||||
            (m_settings.m_iqMapping == AudioInputSettings::IQMapping::R)) ?
 | 
			
		||||
                m_settings.m_sampleRate / 4 : 0;
 | 
			
		||||
        DSPSignalNotification *notif = new DSPSignalNotification(m_settings.m_sampleRate/(1<<m_settings.m_log2Decim), dF);
 | 
			
		||||
        bool realElseComplex = (m_settings.m_iqMapping == AudioInputSettings::L)
 | 
			
		||||
            || (m_settings.m_iqMapping == AudioInputSettings::R);
 | 
			
		||||
        DSPSignalNotification *notif = new DSPSignalNotification(m_settings.m_sampleRate/(1<<m_settings.m_log2Decim), 0, realElseComplex);
 | 
			
		||||
        m_sampleRate = notif->getSampleRate();
 | 
			
		||||
        m_centerFrequency = notif->getCenterFrequency();
 | 
			
		||||
        m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -104,7 +104,18 @@ bool AudioInputGui::deserialize(const QByteArray& data)
 | 
			
		|||
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -117,6 +128,7 @@ bool AudioInputGui::handleMessage(const Message& message)
 | 
			
		|||
        blockApplySettings(true);
 | 
			
		||||
        displaySettings();
 | 
			
		||||
        blockApplySettings(false);
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    else if (AudioInput::MsgStartStop::match(message))
 | 
			
		||||
| 
						 | 
				
			
			@ -142,23 +154,9 @@ void AudioInputGui::handleInputMessages()
 | 
			
		|||
    {
 | 
			
		||||
        qDebug("AudioInputGui::handleInputMessages: message: %s", message->getIdentifier());
 | 
			
		||||
 | 
			
		||||
        if (DSPSignalNotification::match(*message))
 | 
			
		||||
        {
 | 
			
		||||
            DSPSignalNotification* notif = (DSPSignalNotification*) message;
 | 
			
		||||
            m_sampleRate = notif->getSampleRate();
 | 
			
		||||
            m_centerFrequency = notif->getCenterFrequency();
 | 
			
		||||
            qDebug("AudioInputGui::handleInputMessages: DSPSignalNotification: SampleRate: %d", notif->getSampleRate());
 | 
			
		||||
            updateSampleRateAndFrequency();
 | 
			
		||||
 | 
			
		||||
        if (handleMessage(*message)) {
 | 
			
		||||
            delete message;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            if (handleMessage(*message))
 | 
			
		||||
            {
 | 
			
		||||
                delete message;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -246,6 +244,7 @@ void AudioInputGui::displaySettings()
 | 
			
		|||
	ui->iqImbalance->setChecked(m_settings.m_iqImbalance);
 | 
			
		||||
    refreshSampleRates(ui->device->currentText());
 | 
			
		||||
    displayFcTooltip();
 | 
			
		||||
    updateSpectrum();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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) index;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,6 +66,7 @@ private:
 | 
			
		|||
    void refreshSampleRates(QString deviceName);
 | 
			
		||||
    void displaySettings();
 | 
			
		||||
    void displayFcTooltip();
 | 
			
		||||
    void updateSpectrum();
 | 
			
		||||
    void sendSettings();
 | 
			
		||||
    void updateSampleRateAndFrequency();
 | 
			
		||||
    bool handleMessage(const Message& message);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -386,6 +386,9 @@
 | 
			
		|||
       <property name="maximum">
 | 
			
		||||
        <number>10</number>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="pageStep">
 | 
			
		||||
        <number>1</number>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="value">
 | 
			
		||||
        <number>10</number>
 | 
			
		||||
       </property>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,8 +33,7 @@ AudioInputWorker::AudioInputWorker(SampleSinkFifo* sampleFifo, AudioFifo *fifo,
 | 
			
		|||
    m_log2Decim(0),
 | 
			
		||||
    m_iqMapping(AudioInputSettings::IQMapping::L),
 | 
			
		||||
    m_convertBuffer(m_convBufSamples),
 | 
			
		||||
    m_sampleFifo(sampleFifo),
 | 
			
		||||
    m_quNCOPhase(0)
 | 
			
		||||
    m_sampleFifo(sampleFifo)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -62,31 +61,10 @@ void AudioInputWorker::workIQ(unsigned int nbRead)
 | 
			
		|||
    {
 | 
			
		||||
        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_quNCOPhase == 0) // 0
 | 
			
		||||
            {
 | 
			
		||||
                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
 | 
			
		||||
            if (m_iqMapping == AudioInputSettings::IQMapping::L) {
 | 
			
		||||
                m_buf[i*2+1] = m_buf[i*2];
 | 
			
		||||
            } else {
 | 
			
		||||
                m_buf[i*2] = m_buf[i*2+1];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,7 +53,6 @@ private:
 | 
			
		|||
    SampleVector m_convertBuffer;
 | 
			
		||||
    SampleSinkFifo* m_sampleFifo;
 | 
			
		||||
    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 decimate(qint16 *buf, unsigned int nbRead);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue