Skip to content

Commit

Permalink
IQ Tool: add sampling rate and frequency inputs to add ability to pla…
Browse files Browse the repository at this point in the history
…yback arbitrary named files correctly
  • Loading branch information
vladisslav2011 committed Dec 31, 2021
1 parent ee3f480 commit f54060e
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/qtgui/iq_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ CIqTool::CIqTool(QWidget *parent) :
is_playing = false;
bytes_per_sample = 8;
sample_rate = 192000;
playback_sample_rate = 192000;
rec_len = 0;
center_freq = 1e8;

//ui->recDirEdit->setText(QDir::currentPath());
ui->sampleRateSpinBox->setValue(playback_sample_rate);
ui->centerFreqSpinBox->setValue(center_freq);

recdir = new QDir(QDir::homePath(), "*.raw");

Expand All @@ -74,6 +77,8 @@ CIqTool::~CIqTool()
void CIqTool::setSampleRate(qint64 sr)
{
sample_rate = sr;
playback_sample_rate = sr;
ui->sampleRateSpinBox->setValue(sr / 1000.0);

if (!current_file.isEmpty())
{
Expand All @@ -84,7 +89,6 @@ void CIqTool::setSampleRate(qint64 sr)
}
}


/*! \brief Slot activated when the user selects a file. */
void CIqTool::on_listWidget_currentTextChanged(const QString &currentText)
{
Expand All @@ -93,7 +97,7 @@ void CIqTool::on_listWidget_currentTextChanged(const QString &currentText)
QFileInfo info(*recdir, current_file);

parseFileName(currentText);
rec_len = (int)(info.size() / (sample_rate * bytes_per_sample));
rec_len = (int)(info.size() / (playback_sample_rate * bytes_per_sample));

// Get duration of selected recording and update label
refreshTimeWidgets();
Expand Down Expand Up @@ -128,7 +132,7 @@ void CIqTool::on_playButton_clicked(bool checked)
ui->listWidget->setEnabled(false);
ui->recButton->setEnabled(false);
emit startPlayback(recdir->absoluteFilePath(current_file),
(float)sample_rate, center_freq);
(float)playback_sample_rate, center_freq);
}
}
else
Expand Down Expand Up @@ -160,7 +164,7 @@ void CIqTool::on_slider_valueChanged(int value)
{
refreshTimeWidgets();

qint64 seek_pos = (qint64)(value)*sample_rate;
qint64 seek_pos = (qint64)(value)*playback_sample_rate;
emit seek(seek_pos);
}

Expand Down Expand Up @@ -278,6 +282,16 @@ void CIqTool::on_recDirButton_clicked()
ui->recDirEdit->setText(dir);
}

void CIqTool::on_centerFreqSpinBox_valueChanged(double value)
{
center_freq = value * 1000.0;
}

void CIqTool::on_sampleRateSpinBox_valueChanged(double value)
{
playback_sample_rate = value * 1000.0;
}

void CIqTool::timeoutFunction(void)
{
refreshDir();
Expand Down Expand Up @@ -373,7 +387,7 @@ void CIqTool::parseFileName(const QString &filename)
center = list.at(3).toLongLong(&center_ok);

if (sr_ok)
sample_rate = sr;
ui->sampleRateSpinBox->setValue(sr / 1000.0);
if (center_ok)
center_freq = center;
ui->centerFreqSpinBox->setValue(center / 1000.0);
}
3 changes: 3 additions & 0 deletions src/qtgui/iq_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ private slots:
void on_playButton_clicked(bool checked);
void on_slider_valueChanged(int value);
void on_listWidget_currentTextChanged(const QString &currentText);
void on_centerFreqSpinBox_valueChanged(double value);
void on_sampleRateSpinBox_valueChanged(double value);
void timeoutFunction(void);

private:
Expand All @@ -98,6 +100,7 @@ private slots:
bool is_recording;
bool is_playing;
int bytes_per_sample; /*!< Bytes per sample (fc = 4) */
int playback_sample_rate; /*!< Playback sample rate. */
int sample_rate; /*!< Current sample rate. */
qint64 center_freq; /*!< Center frequency. */
int rec_len; /*!< Length of a recording in seconds */
Expand Down
76 changes: 75 additions & 1 deletion src/qtgui/iq_tool.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<width>499</width>
<height>327</height>
</rect>
</property>
Expand Down Expand Up @@ -209,6 +209,80 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="sampleRateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Sample Rate, ksps</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sampleRateSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>999999.989999999990687</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="Frequency">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Frequency, kHz</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="centerFreqSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>99999999.989999994635582</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
Expand Down

0 comments on commit f54060e

Please sign in to comment.