mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-22 03:19:25 -04:00
File Sink: implemented arbitrary sample rate selection
This commit is contained in:
parent
66e45e6638
commit
73c9340e4e
plugins/samplesink/filesink
@ -49,15 +49,14 @@ FileSinkGui::FileSinkGui(DeviceSinkAPI *deviceAPI, QWidget* parent) :
|
||||
m_lastEngineState((DSPDeviceSinkEngine::State)-1)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
|
||||
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
|
||||
ui->fileNameText->setText(m_fileName);
|
||||
|
||||
ui->sampleRate->clear();
|
||||
for (int i = 0; i < FileSinkSampleRates::getNbRates(); i++)
|
||||
{
|
||||
ui->sampleRate->addItem(QString::number(FileSinkSampleRates::getRate(i)));
|
||||
}
|
||||
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::ReverseGreenYellow));
|
||||
ui->sampleRate->setValueRange(7, 32000U, 9000000U);
|
||||
|
||||
ui->fileNameText->setText(m_fileName);
|
||||
|
||||
connect(&(m_deviceAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
||||
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
||||
@ -195,8 +194,7 @@ void FileSinkGui::updateSampleRateAndFrequency()
|
||||
void FileSinkGui::displaySettings()
|
||||
{
|
||||
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
|
||||
unsigned int sampleRateIndex = FileSinkSampleRates::getRateIndex(m_settings.m_sampleRate);
|
||||
ui->sampleRate->setCurrentIndex(sampleRateIndex);
|
||||
ui->sampleRate->setValue(m_settings.m_sampleRate);
|
||||
}
|
||||
|
||||
void FileSinkGui::sendSettings()
|
||||
@ -249,10 +247,9 @@ void FileSinkGui::on_centerFrequency_changed(quint64 value)
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void FileSinkGui::on_sampleRate_currentIndexChanged(int index)
|
||||
void FileSinkGui::on_sampleRate_changed(quint64 value)
|
||||
{
|
||||
int newrate = FileSinkSampleRates::getRate(index);
|
||||
m_settings.m_sampleRate = newrate * 1000;
|
||||
m_settings.m_sampleRate = value;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -338,38 +335,3 @@ void FileSinkGui::tick()
|
||||
m_deviceSampleSink->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
const unsigned int FileSinkSampleRates::m_nb_rates = 17;
|
||||
const unsigned int FileSinkSampleRates::m_rates[FileSinkSampleRates::m_nb_rates] = {
|
||||
32, 48, 64, 72, 128, 192, 256, 288, 300, 384, 512, 1000, 2000, 3000, 4000, 5000, 6000};
|
||||
|
||||
unsigned int FileSinkSampleRates::getRate(unsigned int rate_index)
|
||||
{
|
||||
if (rate_index < m_nb_rates)
|
||||
{
|
||||
return m_rates[rate_index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_rates[0];
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int FileSinkSampleRates::getRateIndex(unsigned int rate)
|
||||
{
|
||||
for (unsigned int i=0; i < m_nb_rates; i++)
|
||||
{
|
||||
if (rate/1000 == m_rates[i])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int FileSinkSampleRates::getNbRates()
|
||||
{
|
||||
return FileSinkSampleRates::m_nb_rates;
|
||||
}
|
||||
|
||||
|
@ -78,22 +78,13 @@ private slots:
|
||||
void handleDSPMessages();
|
||||
void handleSinkMessages();
|
||||
void on_centerFrequency_changed(quint64 value);
|
||||
void on_sampleRate_changed(quint64 value);
|
||||
void on_startStop_toggled(bool checked);
|
||||
void on_showFileDialog_clicked(bool checked);
|
||||
void on_interp_currentIndexChanged(int index);
|
||||
void on_sampleRate_currentIndexChanged(int index);
|
||||
void updateHardware();
|
||||
void updateStatus();
|
||||
void tick();
|
||||
};
|
||||
|
||||
class FileSinkSampleRates {
|
||||
public:
|
||||
static unsigned int getRate(unsigned int rate_index);
|
||||
static unsigned int getRateIndex(unsigned int rate);
|
||||
static unsigned int getNbRates();
|
||||
static const unsigned int m_nb_rates;
|
||||
static const unsigned int m_rates[];
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FILESINKGUI_H
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>246</width>
|
||||
<width>315</width>
|
||||
<height>190</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -35,7 +35,16 @@
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -274,16 +283,31 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="sampleRate">
|
||||
<property name="toolTip">
|
||||
<string>Sample rate selection (kS/s)</string>
|
||||
<widget class="ValueDial" name="sampleRate" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>DejaVu Sans Mono</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="sampleRateUnit">
|
||||
<property name="text">
|
||||
<string>kS/s</string>
|
||||
<string>S/s</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -365,6 +389,33 @@
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
<include location="../../../sdrbase/resources/res.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -33,7 +33,7 @@ QByteArray FileSinkSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
|
||||
s.writeS32(1, m_sampleRate);
|
||||
s.writeU64(1, m_sampleRate);
|
||||
s.writeU32(2, m_log2Interp);
|
||||
|
||||
return s.final();
|
||||
@ -52,7 +52,7 @@ bool FileSinkSettings::deserialize(const QByteArray& data)
|
||||
if (d.getVersion() == 1)
|
||||
{
|
||||
int intval;
|
||||
d.readS32(1, &m_sampleRate, 48000);
|
||||
d.readU64(1, &m_sampleRate, 48000);
|
||||
d.readU32(2, &m_log2Interp, 0);
|
||||
return true;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
struct FileSinkSettings {
|
||||
quint64 m_centerFrequency;
|
||||
qint32 m_sampleRate;
|
||||
quint64 m_sampleRate;
|
||||
quint32 m_log2Interp;
|
||||
|
||||
FileSinkSettings();
|
||||
|
Loading…
Reference in New Issue
Block a user