summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rtlfmradiotunercontrol.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/rtlfmradiotunercontrol.cpp b/rtlfmradiotunercontrol.cpp
index 83096b6..863cb06 100644
--- a/rtlfmradiotunercontrol.cpp
+++ b/rtlfmradiotunercontrol.cpp
@@ -48,11 +48,11 @@ private:
};
QMap<int, QString> fmFrequenciesTokyo = {
- { 76100, QString::fromUtf8("Inter FM") }
- , { 77100, QString::fromUtf8("The Open University of Japan") }
- , { 80000, QString::fromUtf8("TOKYO FM") }
- , { 81300, QString::fromUtf8("J-WAVE") }
- , { 82500, QString::fromUtf8("NHK FM Tokyo") }
+ { 76100000, QString::fromUtf8("Inter FM") }
+ , { 77100000, QString::fromUtf8("The Open University of Japan") }
+ , { 80000000, QString::fromUtf8("TOKYO FM") }
+ , { 81300000, QString::fromUtf8("J-WAVE") }
+ , { 82500000, QString::fromUtf8("NHK FM Tokyo") }
};
};
@@ -71,7 +71,6 @@ RtlFmRadioTunerControl::Private::Private(RtlFmRadioTunerControl *parent)
, step(0)
{
connect(q, &RtlFmRadioTunerControl::stationFound, [this](int frequency, const QString &name) {
- qDebug() << frequency << name;
if (rtlFm.state() != QProcess::NotRunning)
q->start();
});
@@ -89,11 +88,12 @@ RtlFmRadioTunerControl::Private::Private(RtlFmRadioTunerControl *parent)
break;
}
if (knownBands.contains(frequency)) {
- emit q->stationFound(frequency, knownBands.value(frequency));
+ QMetaObject::invokeMethod(q, "stationFound", Qt::QueuedConnection, Q_ARG(int, frequency), Q_ARG(QString, knownBands.value(frequency)));
if (timer.isActive() && searchOne)
timer.stop();
}
});
+
connect(&timer, &QTimer::timeout, [this]() {
q->setFrequency(frequency + step);
});
@@ -167,7 +167,7 @@ int RtlFmRadioTunerControl::frequencyStep(QRadioTuner::Band band) const
ret = 1000; // 1kHz
break;
case QRadioTuner::FM:
- ret = 100; // 100Hz
+ ret = 100000; // 0.1 MHz
break;
default:
break;
@@ -180,10 +180,10 @@ QPair<int,int> RtlFmRadioTunerControl::frequencyRange(QRadioTuner::Band band) co
QPair<int,int> ret;
switch (band) {
case QRadioTuner::AM:
- ret = qMakePair<int,int>(594000, 1242000);
+ ret = qMakePair<int,int>(531000, 1602000);
break;
case QRadioTuner::FM:
- ret = qMakePair<int,int>(76100, 82500);
+ ret = qMakePair<int,int>(76000000, 107900000);
break;
default:
break;
@@ -313,7 +313,19 @@ void RtlFmRadioTunerControl::start()
d->aplay.start(QStringLiteral("aplay"), QStringList() << QStringLiteral("-r") << QStringLiteral("48000") << QStringLiteral("-f") << QStringLiteral("S16_LE"));
d->aplay.waitForStarted();
// d->rtlFm.start(QStringLiteral("sudo"), QStringList() << QStringLiteral("rtl_fm -f %1 -M wbfm -s 200000 -r 48000").arg(d->frequency * 1000).split(" "));
- d->rtlFm.start(QStringLiteral("rtl_fm"), QStringList() << QStringLiteral("-f %1 -M wbfm -s 200000 -r 48000").arg(d->frequency * 1000).split(" "));
+ QString modulation;
+ switch (d->band) {
+ case QRadioTuner::AM:
+ modulation = QStringLiteral("-M wbfm");
+ break;
+ case QRadioTuner::FM:
+ modulation = QStringLiteral("-M am");
+ break;
+ default:
+ break;
+ }
+
+ d->rtlFm.start(QStringLiteral("rtl_fm"), QStringLiteral("-f %1 %2 -s 200000 -r 48000").arg(d->frequency).arg(modulation).split(" "));
d->rtlFm.waitForStarted();
d->state = QRadioTuner::ActiveState;
}