mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 01:18:38 -05:00
48kHz.
This commit is contained in:
parent
c813639df7
commit
280346e39b
@ -36,9 +36,9 @@ NFMDemod::NFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
||||
|
||||
m_nco.setFreq(m_frequency, m_sampleRate);
|
||||
m_interpolator.create(16, m_sampleRate, 12500);
|
||||
m_sampleDistanceRemain = (Real)m_sampleRate / 44100.0;
|
||||
m_sampleDistanceRemain = (Real)m_sampleRate / 48000.0;
|
||||
|
||||
m_lowpass.create(21, 44100, 3000);
|
||||
m_lowpass.create(21, 48000, 3000);
|
||||
|
||||
m_audioBuffer.resize(256);
|
||||
m_audioBufferFill = 0;
|
||||
@ -96,7 +96,7 @@ void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
||||
}
|
||||
}
|
||||
|
||||
m_sampleDistanceRemain += (Real)m_sampleRate / 44100.0;
|
||||
m_sampleDistanceRemain += (Real)m_sampleRate / 48000.0;
|
||||
}
|
||||
}
|
||||
if(m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 0) != m_audioBufferFill)
|
||||
@ -125,7 +125,7 @@ bool NFMDemod::handleMessage(Message* cmd)
|
||||
m_sampleRate = signal->getSampleRate();
|
||||
m_nco.setFreq(-signal->getFrequencyOffset(), m_sampleRate);
|
||||
m_interpolator.create(16, m_sampleRate, m_rfBandwidth / 2.1);
|
||||
m_sampleDistanceRemain = m_sampleRate / 44100.0;
|
||||
m_sampleDistanceRemain = m_sampleRate / 48000.0;
|
||||
m_squelchState = 0;
|
||||
cmd->completed();
|
||||
return true;
|
||||
@ -133,7 +133,7 @@ bool NFMDemod::handleMessage(Message* cmd)
|
||||
MsgConfigureNFMDemod* cfg = (MsgConfigureNFMDemod*)cmd;
|
||||
m_rfBandwidth = cfg->getRFBandwidth();
|
||||
m_interpolator.create(16, m_sampleRate, m_rfBandwidth / 2.1);
|
||||
m_lowpass.create(21, 44100, cfg->getAFBandwidth());
|
||||
m_lowpass.create(21, 48000, cfg->getAFBandwidth());
|
||||
m_squelchLevel = pow(10.0, cfg->getSquelch() / 20.0);
|
||||
m_squelchLevel *= m_squelchLevel;
|
||||
m_volume = cfg->getVolume();
|
||||
|
@ -155,7 +155,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
||||
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
||||
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
||||
|
||||
m_audioFifo = new AudioFifo(4, 44100 / 4);
|
||||
m_audioFifo = new AudioFifo(4, 48000 / 4);
|
||||
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
||||
m_nfmDemod = new NFMDemod(m_audioFifo, m_spectrumVis);
|
||||
m_channelizer = new Channelizer(m_nfmDemod);
|
||||
@ -164,7 +164,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
||||
m_pluginAPI->addSampleSink(m_threadedSampleSink);
|
||||
|
||||
ui->glSpectrum->setCenterFrequency(0);
|
||||
ui->glSpectrum->setSampleRate(44100);
|
||||
ui->glSpectrum->setSampleRate(48000);
|
||||
ui->glSpectrum->setDisplayWaterfall(true);
|
||||
ui->glSpectrum->setDisplayMaxHold(true);
|
||||
m_spectrumVis->configure(m_threadedSampleSink->getMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
|
||||
@ -200,7 +200,7 @@ void NFMDemodGUI::applySettings()
|
||||
{
|
||||
setTitleColor(m_channelMarker->getColor());
|
||||
m_channelizer->configure(m_threadedSampleSink->getMessageQueue(),
|
||||
44100,
|
||||
48000,
|
||||
m_channelMarker->getCenterFrequency());
|
||||
m_nfmDemod->configure(m_threadedSampleSink->getMessageQueue(),
|
||||
m_rfBW[ui->rfBW->value()],
|
||||
|
@ -173,8 +173,6 @@ void Channelizer::freeFilterChain()
|
||||
m_filterStages.clear();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
||||
// written by Christian Daniel //
|
||||
@ -191,138 +189,3 @@ void Channelizer::freeFilterChain()
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QTime>
|
||||
#include <stdio.h>
|
||||
#include "channelizer.h"
|
||||
#include "hardware/audiooutput.h"
|
||||
|
||||
Channelizer::Channelizer()
|
||||
{
|
||||
#if 0
|
||||
m_spectrum.configure(128 , 25, FFTWindow::Bartlett);
|
||||
m_buffer.resize(2048);
|
||||
m_bufferFill = 0;
|
||||
m_nco.setFreq(-100000, 500000);
|
||||
m_interpolator.create(51, 32, 32 * 500000, 150000 / 2);
|
||||
m_distance = 500000.0 / 176400.0;
|
||||
|
||||
m_interpolator2.create(19, 8, 8 * 176400, 15000 / 2);
|
||||
m_distance2 = 4;
|
||||
|
||||
m_audioFifo.setSize(4, 44100 / 2 * 4);
|
||||
m_audioOutput = new AudioOutput;
|
||||
m_audioOutput->start(0, 44100, &m_audioFifo);
|
||||
m_resampler = 1.0;
|
||||
|
||||
m_resamplerCtrl.setup(0.00001, 0, -0.00001);
|
||||
#endif
|
||||
}
|
||||
|
||||
Channelizer::~Channelizer()
|
||||
{
|
||||
#if 0
|
||||
m_audioOutput->stop();
|
||||
delete m_audioOutput;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
void Channelizer::setGLSpectrum(GLSpectrum* glSpectrum)
|
||||
{
|
||||
m_spectrum.setGLSpectrum(glSpectrum);
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t Channelizer::workUnitSize()
|
||||
{
|
||||
#if 0
|
||||
return m_buffer.size();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t Channelizer::work(SampleVector::const_iterator begin, SampleVector::const_iterator end)
|
||||
{
|
||||
#if 0
|
||||
int buffered = m_audioOutput->bufferedSamples();
|
||||
|
||||
if(m_audioFifo.fill() < (m_audioFifo.size() / 6)) {
|
||||
while(m_audioFifo.fill() < (m_audioFifo.size() / 2)) {
|
||||
quint32 d = 0;
|
||||
m_audioFifo.write((quint8*)&d, 4);
|
||||
}
|
||||
qDebug("underflow - fill %d (vs %d)", m_audioFifo.fill(), m_audioFifo.size() / 4 / 2);
|
||||
}
|
||||
|
||||
buffered = m_audioOutput->bufferedSamples();
|
||||
int fill = m_audioFifo.fill() / 4 + buffered;
|
||||
float err = (float)fill / ((m_audioFifo.size() / 4) / 2);
|
||||
|
||||
float ctrl = m_resamplerCtrl.feed(err);
|
||||
//float resamplerRate = (ctrl / 1.0);
|
||||
float resamplerRate = err;
|
||||
|
||||
if(resamplerRate < 0.9999)
|
||||
resamplerRate = 0.9999;
|
||||
else if(resamplerRate > 1.0001)
|
||||
resamplerRate = 1.0001;
|
||||
m_resampler = m_resampler * 0.99 + resamplerRate * 0.01;
|
||||
//m_resampler = resamplerRate;
|
||||
|
||||
if(m_resampler < 0.995)
|
||||
m_resampler = 0.995;
|
||||
else if(m_resampler > 1.005)
|
||||
m_resampler = 1.005;
|
||||
|
||||
//qDebug("%lld %5d %f %f %f", QDateTime::currentMSecsSinceEpoch(), fill, ctrl, m_resampler, err);
|
||||
|
||||
struct AudioSample {
|
||||
qint16 l;
|
||||
qint16 r;
|
||||
};
|
||||
|
||||
size_t count = end - begin;
|
||||
Complex ci;
|
||||
bool consumed;
|
||||
bool consumed2;
|
||||
|
||||
for(SampleVector::const_iterator it = begin; it < end; it++) {
|
||||
Complex c(it->real() / 32768.0, it->imag() / 32768.0);
|
||||
c *= m_nco.nextIQ();
|
||||
|
||||
consumed = false;
|
||||
if(m_interpolator.interpolate(&m_distance, c, &consumed, &ci)) {
|
||||
|
||||
Complex d = ci * conj(m_lastSample);
|
||||
m_lastSample = ci;
|
||||
//Complex demod(atan2(d.imag(), d.real()) * 0.5, 0);
|
||||
Real demod = atan2(d.imag(), d.real()) / M_PI;
|
||||
|
||||
consumed2 = false;
|
||||
c = Complex(demod, 0);
|
||||
while(!consumed2) {
|
||||
if(m_interpolator2.interpolate(&m_distance2, c, &consumed2, &ci)) {
|
||||
m_buffer[m_bufferFill++] = Sample(ci.real() * 32767.0, 0.0);
|
||||
|
||||
AudioSample s;
|
||||
s.l = ci.real() * 32767.0;
|
||||
s.r = s.l;
|
||||
m_audioFifo.write((quint8*)&s, 4, 1);
|
||||
|
||||
if(m_bufferFill >= m_buffer.size()) {
|
||||
m_spectrum.feed(m_buffer.begin(), m_buffer.end());
|
||||
m_bufferFill = 0;
|
||||
}
|
||||
m_distance2 += 4.0 * m_resampler;
|
||||
}
|
||||
}
|
||||
m_distance += 500000 / 176400.0;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -301,7 +301,7 @@ DSPEngine::State DSPEngine::gotoRunning()
|
||||
return gotoError("Could not start sample source");
|
||||
m_deviceDescription = m_sampleSource->getDeviceDescription();
|
||||
|
||||
m_audioOutput.start(0, 44100);
|
||||
m_audioOutput.start(0, 48000);
|
||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||
(*it)->start();
|
||||
m_sampleRate = 0; // make sure, report is sent
|
||||
|
Loading…
Reference in New Issue
Block a user