-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iq tool center freq fix #1009
Iq tool center freq fix #1009
Conversation
vladisslav2011
commented
Dec 2, 2021
- Parse the center frequency from IQ file name
- Save center frequency and offset before starting IQ file playback
- Restore center frequency and offset after finishing IQ file playback
Thanks for splitting this off into its own pull request. It's much easier to review this way. I'll have a look at this tonight. |
src/qtgui/iq_tool.cpp
Outdated
@@ -91,7 +91,8 @@ void CIqTool::on_listWidget_currentTextChanged(const QString ¤tText) | |||
QFileInfo info(*recdir, current_file); | |||
|
|||
// Get duration of selected recording and update label | |||
sample_rate = sampleRateFromFileName(currentText); | |||
//sample_rate = sampleRateFromFileName(currentText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed.
src/qtgui/iq_tool.cpp
Outdated
@@ -91,7 +91,8 @@ void CIqTool::on_listWidget_currentTextChanged(const QString ¤tText) | |||
QFileInfo info(*recdir, current_file); | |||
|
|||
// Get duration of selected recording and update label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment looks like it should be above line 96 instead.
src/qtgui/iq_tool.cpp
Outdated
@@ -126,7 +127,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); | |||
(float)sample_rate,center_freq); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(float)sample_rate,center_freq); | |
(float)sample_rate, center_freq); |
src/applications/gqrx/mainwindow.cpp
Outdated
@@ -1658,6 +1663,7 @@ void MainWindow::stopIqPlayback() | |||
|
|||
// restore frequency, gain, etc... | |||
uiDockInputCtl->readSettings(m_settings); | |||
on_plotter_newDemodFreq(backupFreq,backupOffset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on_plotter_newDemodFreq(backupFreq,backupOffset); | |
on_plotter_newDemodFreq(backupFreq, backupOffset); |
src/qtgui/iq_tool.cpp
Outdated
|
||
QStringList list = filename.split('_'); | ||
|
||
if (list.size() < 5) | ||
return sample_rate; | ||
return ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ; | |
return; |
src/applications/gqrx/mainwindow.cpp
Outdated
|
||
auto sri = (int)samprate; | ||
auto devstr = QString("file='%1',rate=%2,throttle=true,repeat=false") | ||
.arg(filename).arg(sri); | ||
auto cf = (long long) center_freq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto cf = (long long) center_freq; | |
auto cf = (long long) center_freq; |
So far the code looks good, I just suggested a few formatting improvements. I'll test this out tonight. |
Thank you for a review. |
I'd suggest to force-push a revised commit. That will keep the commit history clean once this is merged. |
9dc5ecf
to
796a5a8
Compare
Done. |
I noticed a bug. When switching from receive (in this example, with an RTL-SDR) to I/Q playback, the plotter frequency axis updates, but the frequency controls do not. Here's what I see when I start playback of an I/Q file with a center frequency around 390 MHz: The frequency control still shows 929 MHz, and the indicated offset is 0 Hz. If I click to retune, then the correct frequencies are displayed. |
Thank you for reporting this bug. |
src/applications/gqrx/mainwindow.cpp
Outdated
backupFreq = ui->freqCtrl->getFrequency(); | ||
backupOffset = (qint64) rx->get_filter_offset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to add these variables? I expect storeSession()
already saves them in the input/frequency
and receiver/offset
settings, the same way that the sample rate is saved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the "Device dialog" or the "Save settings" button may overwrite settings during IQ playback as both are calling storeSession()
. But using any of these buttons breaks playback too...
OK. Ill switch to reading center/offset from stored settings and add disabling "Save settings" button during playback to #1011.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggestion to use storeSession()
was just for consistency with the current design. I agree that the current design is not ideal, so maybe we should think about changing it (in a future PR, perhaps).
Another minor issue I noticed is that when the I/Q file's center frequency falls outside the hardware limits of the currently selected device, then the frequency is not set correctly. (It's constrained to be within the hardware device's limits.) It looks like this happens because the hardware frequency range is not updated. This change appears to fix the problem: diff --git a/src/applications/gqrx/mainwindow.cpp b/src/applications/gqrx/mainwindow.cpp
index 34a7d5eb6b..a78237d736 100644
--- a/src/applications/gqrx/mainwindow.cpp
+++ b/src/applications/gqrx/mainwindow.cpp
@@ -1609,6 +1609,7 @@ void MainWindow::startIqPlayback(const QString& filename, float samprate, double
qDebug() << __func__ << ":" << devstr;
rx->set_input_device(devstr.toStdString());
+ updateHWFrequencyRange(false);
// sample rate
auto actual_rate = rx->set_input_rate(samprate); |
Thanks again for the pull request, and sorry for the long delay in reviewing this. I've suggested a couple further improvements. When you make those changes, could you also squash your commits into a single one? That will help keep the commit history clean. |
c57412c
to
489af53
Compare
Thanks. Fix confirmed. Included into 489af53.
No problem. Done. |
Another bug: If Line 48 in 49de5f3
gqrx/src/applications/gqrx/mainwindow.cpp Line 617 in 49de5f3
|
489af53
to
08a99c3
Compare
Thanks for more testing. |
08a99c3
to
2d24568
Compare
I forgot to remove debug prints. |
That might be a useful feature, but for now I think it's fine to default to the current sample rate and center frequency, and assume complex floating point samples. |
OK. I'll split this feature into separate PR. Wait some minutes. |
2d24568
to
510c45a
Compare
510c45a
to
4059516
Compare
New GUI controls are moved to #1026 |
Another bug:
In this case, the center frequency will not be adjusted. |
Also, in that same case the wrong file duration will be displayed if the sample rate of the file differs from the sample rate of the currently selected device. I guess both bugs are triggered by the additional code that was added to |
Confirmed. It looks, like getting default sample rate/center frequency from current selected device does not work as expected.
I'll fix both bugs and reopen this PR. |
4059516
to
7877be3
Compare
7877be3
to
ee3f480
Compare
Try to parce center frequncy from a filename and apply it to waterfall. If parcing the file fails, default to last sample rate/center frequency. Restore current tuned frequency and offset after playback ends. My be fixes gqrx-sdr#977 too. Remove unused function Update uiDockRxOpt widgets correctly
ee3f480
to
bae1256
Compare
The code looks good now, and the change appears to be working well. I'll merge once CI passes. |