VOR single channel: reworked as single channel and simple GUI

pull/743/head
f4exb 2020-11-28 07:14:06 +01:00
rodzic 97154a3896
commit efcc46a747
26 zmienionych plików z 462 dodań i 2409 usunięć

Wyświetl plik

@ -3,8 +3,8 @@ project(demod)
if (Qt5Quick_FOUND AND Qt5QuickWidgets_FOUND AND Qt5Positioning_FOUND)
add_subdirectory(demodadsb)
add_subdirectory(demodvor)
add_subdirectory(demodvorsc)
endif()
add_subdirectory(demodam)
add_subdirectory(demodbfm)
add_subdirectory(demodnfm)
@ -15,6 +15,7 @@ add_subdirectory(localsink)
add_subdirectory(filesink)
add_subdirectory(freqtracker)
add_subdirectory(demodchirpchat)
add_subdirectory(demodvorsc)
if(LIBDSDCC_FOUND AND LIBMBE_FOUND)
add_subdirectory(demoddsd)

Wyświetl plik

@ -20,7 +20,6 @@ set(vorsc_HEADERS
vordemodscreport.h
)
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
)
@ -30,18 +29,14 @@ if(NOT SERVER_MODE)
${vorsc_SOURCES}
vordemodscgui.cpp
vordemodscgui.ui
map.qrc
icons.qrc
)
set(vorsc_HEADERS
${vorsc_HEADERS}
vordemodscgui.h
navaid.h
../demodadsb/csv.h
)
set(TARGET_NAME demodvorsc)
set(TARGET_LIB "Qt5::Widgets" Qt5::Quick Qt5::QuickWidgets Qt5::Positioning)
set(TARGET_LIB "Qt5::Widgets")
set(TARGET_LIB_GUI "sdrgui")
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
else()

Wyświetl plik

@ -1,6 +0,0 @@
<RCC>
<qresource prefix="/demodvor/">
<file>icons/compass.png</file>
<file>icons/vor.png</file>
</qresource>
</RCC>

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 547 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 365 B

Wyświetl plik

@ -1,10 +0,0 @@
<RCC>
<qresource prefix="/demodvor/">
<file>map/map.qml</file>
<file>map/MapStation.qml</file>
<file>map/antenna.png</file>
<file>map/VOR.png</file>
<file>map/VOR-DME.png</file>
<file>map/VORTAC.png</file>
</qresource>
</RCC>

Wyświetl plik

@ -1,40 +0,0 @@
import QtQuick 2.12
import QtLocation 5.12
import QtPositioning 5.12
MapQuickItem {
id: station
property string stationName // Name of the station, E.g. Home
coordinate: QtPositioning.coordinate(51.5, 0.125) // Location of the antenna (QTH) - London
zoomLevel: 11
anchorPoint.x: image.width/2
anchorPoint.y: image.height/2
sourceItem: Grid {
columns: 1
Grid {
horizontalItemAlignment: Grid.AlignHCenter
layer.enabled: true
layer.smooth: true
Image {
id: image
source: "antenna.png"
}
Rectangle {
id: bubble
color: "lightblue"
border.width: 1
width: text.width * 1.3
height: text.height * 1.3
radius: 5
Text {
id: text
anchors.centerIn: parent
text: stationName
}
}
}
}
}

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 652 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 415 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 847 B

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.3 KiB

Wyświetl plik

@ -1,115 +0,0 @@
import QtQuick 2.12
import QtQuick.Window 2.12
import QtLocation 5.12
import QtPositioning 5.12
Item {
id: qmlMap
property int vorZoomLevel: 11
Plugin {
id: mapPlugin
name: "osm"
}
Map {
id: map
objectName: "map"
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(51.5, 0.125) // London
zoomLevel: 10
MapItemView {
model: vorModel
delegate: vorRadialComponent
}
MapStation {
id: station
objectName: "station"
stationName: "Home"
coordinate: QtPositioning.coordinate(51.5, 0.125)
}
MapItemView {
model: vorModel
delegate: vorComponent
}
onZoomLevelChanged: {
if (zoomLevel > 11) {
station.zoomLevel = zoomLevel
vorZoomLevel = zoomLevel
} else {
station.zoomLevel = 11
vorZoomLevel = 11
}
}
}
Component {
id: vorRadialComponent
MapPolyline {
line.width: 2
line.color: 'gray'
path: vorRadial
}
}
Component {
id: vorComponent
MapQuickItem {
id: vor
anchorPoint.x: image.width/2
anchorPoint.y: bubble.height/2
coordinate: position
zoomLevel: vorZoomLevel
sourceItem: Grid {
columns: 1
Grid {
horizontalItemAlignment: Grid.AlignHCenter
verticalItemAlignment: Grid.AlignVCenter
columnSpacing: 5
layer.enabled: true
layer.smooth: true
Image {
id: image
source: vorImage
MouseArea {
anchors.fill: parent
hoverEnabled: true
onDoubleClicked: (mouse) => {
selected = !selected
}
}
}
Rectangle {
id: bubble
color: bubbleColour
border.width: 1
width: text.width + 5
height: text.height + 5
radius: 5
Text {
id: text
anchors.centerIn: parent
text: vorData
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onDoubleClicked: (mouse) => {
selected = !selected
}
}
}
}
}
}
}
}

Wyświetl plik

@ -1,368 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_NAVAID_H
#define INCLUDE_NAVAID_H
#include <QString>
#include <QFile>
#include <QByteArray>
#include <QHash>
#include <QList>
#include <QDebug>
#include <QXmlStreamReader>
#include <stdio.h>
#include <string.h>
#include "util/units.h"
#include "../demodadsb/csv.h"
#define OURAIRPORTS_NAVAIDS_URL "https://ourairports.com/data/navaids.csv"
#define OPENAIP_NAVAIDS_URL "https://www.openaip.net/customer_export_akfshb9237tgwiuvb4tgiwbf/%1_nav.aip"
struct NavAid {
int m_id;
QString m_ident; // 2 or 3 character ident
QString m_type; // VOR, VOR-DME or VORTAC
QString m_name;
float m_latitude;
float m_longitude;
float m_elevation;
int m_frequencykHz;
QString m_channel;
int m_range; // Nautical miles
float m_magneticDeclination;
bool m_alignedTrueNorth; // Is the VOR aligned to true North, rather than magnetic (may be the case at high latitudes)
static QString trimQuotes(const QString s)
{
if (s.startsWith('\"') && s.endsWith('\"'))
return s.mid(1, s.size() - 2);
else
return s;
}
int getRangeMetres()
{
return Units::nauticalMilesToIntegerMetres((float)m_range);
}
// OpenAIP XML file
static void readNavAidsXML(QHash<int, NavAid *> *navAidInfo, const QString &filename)
{
QFile file(filename);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QXmlStreamReader xmlReader(&file);
while(!xmlReader.atEnd() && !xmlReader.hasError())
{
if (xmlReader.readNextStartElement())
{
if (xmlReader.name() == "NAVAID")
{
QStringRef typeRef = xmlReader.attributes().value("TYPE");
if ((typeRef == QLatin1String("VOR"))
|| (typeRef== QLatin1String("VOR-DME"))
|| (typeRef == QLatin1String("VORTAC")))
{
QString type = typeRef.toString();
int identifier = 0;
QString name;
QString id;
float lat = 0.0f;
float lon = 0.0f;
float elevation = 0.0f;
int frequency = 0;
QString channel;
int range = 25;
float declination = 0.0f;
bool alignedTrueNorth = false;
while(xmlReader.readNextStartElement())
{
if (xmlReader.name() == QLatin1String("IDENTIFIER"))
identifier = xmlReader.readElementText().toInt();
else if (xmlReader.name() == QLatin1String("NAME"))
name = xmlReader.readElementText();
else if (xmlReader.name() == QLatin1String("ID"))
id = xmlReader.readElementText();
else if (xmlReader.name() == QLatin1String("GEOLOCATION"))
{
while(xmlReader.readNextStartElement())
{
if (xmlReader.name() == QLatin1String("LAT"))
lat = xmlReader.readElementText().toFloat();
else if (xmlReader.name() == QLatin1String("LON"))
lon = xmlReader.readElementText().toFloat();
else if (xmlReader.name() == QLatin1String("ELEV"))
elevation = xmlReader.readElementText().toFloat();
else
xmlReader.skipCurrentElement();
}
}
else if (xmlReader.name() == QLatin1String("RADIO"))
{
while(xmlReader.readNextStartElement())
{
if (xmlReader.name() == QLatin1String("FREQUENCY"))
frequency = (int)(xmlReader.readElementText().toFloat() * 1000);
else if (xmlReader.name() == QLatin1String("CHANNEL"))
channel = xmlReader.readElementText();
else
xmlReader.skipCurrentElement();
}
}
else if (xmlReader.name() == QLatin1String("PARAMS"))
{
while(xmlReader.readNextStartElement())
{
if (xmlReader.name() == QLatin1String("RANGE"))
range = xmlReader.readElementText().toInt();
else if (xmlReader.name() == QLatin1String("DECLINATION"))
declination = xmlReader.readElementText().toFloat();
else if (xmlReader.name() == QLatin1String("ALIGNEDTOTRUENORTH"))
alignedTrueNorth = xmlReader.readElementText() == "TRUE";
else
xmlReader.skipCurrentElement();
}
}
else
xmlReader.skipCurrentElement();
}
NavAid *vor = new NavAid();
vor->m_id = identifier;
vor->m_ident = id;
// Check idents conform to our filtering rules
if (vor->m_ident.size() < 2)
qDebug() << "Warning: VOR Ident less than 2 characters: " << vor->m_ident;
else if (vor->m_ident.size() > 3)
qDebug() << "Warning: VOR Ident greater than 3 characters: " << vor->m_ident;
vor->m_type = type;
vor->m_name = name;
vor->m_frequencykHz = frequency;
vor->m_channel = channel;
vor->m_latitude = lat;
vor->m_longitude = lon;
vor->m_elevation = elevation;
vor->m_range = range;
vor->m_magneticDeclination = declination;
vor->m_alignedTrueNorth = alignedTrueNorth;
navAidInfo->insert(identifier, vor);
}
}
}
}
file.close();
}
else
qDebug() << "NavAid::readNavAidsXML: Could not open " << filename << " for reading.";
}
// Read OurAirport's NavAids CSV file
// See comments for readOSNDB
static QHash<int, NavAid *> *readNavAidsDB(const QString &filename)
{
int cnt = 0;
QHash<int, NavAid *> *navAidInfo = nullptr;
// Column numbers used for the data as of 2020/10/28
int idCol = 0;
int identCol = 2;
int typeCol = 4;
int nameCol = 3;
int frequencyCol = 5;
int latitudeCol = 6;
int longitudeCol = 7;
int elevationCol = 8;
int powerCol = 18;
qDebug() << "NavAid::readNavAidsDB: " << filename;
FILE *file;
QByteArray utfFilename = filename.toUtf8();
if ((file = fopen(utfFilename.constData(), "r")) != NULL)
{
char row[2048];
if (fgets(row, sizeof(row), file))
{
navAidInfo = new QHash<int, NavAid *>();
navAidInfo->reserve(15000);
// Read header
int idx = 0;
char *p = strtok(row, ",");
while (p != NULL)
{
if (!strcmp(p, "id"))
idCol = idx;
else if (!strcmp(p, "ident"))
identCol = idx;
else if (!strcmp(p, "type"))
typeCol = idx;
else if (!strcmp(p, "name"))
nameCol = idx;
else if (!strcmp(p, "frequency_khz"))
frequencyCol = idx;
else if (!strcmp(p, "latitude_deg"))
latitudeCol = idx;
else if (!strcmp(p, "longitude_deg"))
longitudeCol = idx;
else if (!strcmp(p, "elevation_ft"))
elevationCol = idx;
else if (!strcmp(p, "power"))
powerCol = idx;
p = strtok(NULL, ",");
idx++;
}
// Read data
while (fgets(row, sizeof(row), file))
{
int id = 0;
char *idString = NULL;
char *ident = NULL;
size_t identLen = 0;
char *type = NULL;
size_t typeLen = 0;
char *name = NULL;
size_t nameLen = 0;
char *frequencyString = NULL;
int frequency;
float latitude = 0.0f;
char *latitudeString = NULL;
size_t latitudeLen = 0;
float longitude = 0.0f;
char *longitudeString = NULL;
size_t longitudeLen = 0;
float elevation = 0.0f;
char *elevationString = NULL;
size_t elevationLen = 0;
char *power = NULL;
size_t powerLen = 0;
char *q = row;
idx = 0;
while ((p = csvNext(&q)) != nullptr)
{
// Read strings, stripping quotes
if (idx == idCol)
{
idString = p;
idString[strlen(idString)] = '\0';
id = strtol(idString, NULL, 10);
}
else if ((idx == identCol) && (p[0] == '\"'))
{
ident = p+1;
identLen = strlen(ident)-1;
ident[identLen] = '\0';
}
else if ((idx == typeCol) && (p[0] == '\"'))
{
type = p+1;
typeLen = strlen(type)-1;
type[typeLen] = '\0';
}
else if ((idx == nameCol) && (p[0] == '\"'))
{
name = p+1;
nameLen = strlen(name)-1;
name[nameLen] = '\0';
}
if (idx == frequencyCol)
{
frequencyString = p;
frequencyString[strlen(frequencyString)] = '\0';
frequency = strtol(frequencyString, NULL, 10);
}
else if (idx == latitudeCol)
{
latitudeString = p;
latitudeLen = strlen(latitudeString)-1;
latitudeString[latitudeLen] = '\0';
latitude = atof(latitudeString);
}
else if (idx == longitudeCol)
{
longitudeString = p;
longitudeLen = strlen(longitudeString)-1;
longitudeString[longitudeLen] = '\0';
longitude = atof(longitudeString);
}
else if (idx == elevationCol)
{
elevationString = p;
elevationLen = strlen(elevationString)-1;
elevationString[elevationLen] = '\0';
elevation = atof(elevationString);
}
else if ((idx == powerCol) && (p[0] == '\"'))
{
power = p+1;
powerLen = strlen(power)-1;
power[powerLen] = '\0';
}
idx++;
}
// For now, we only want VORs
if (type && !strncmp(type, "VOR", 3))
{
NavAid *vor = new NavAid();
vor->m_id = id;
vor->m_ident = QString(ident);
// Check idents conform to our filtering rules
if (vor->m_ident.size() < 2)
qDebug() << "Warning: VOR Ident less than 2 characters: " << vor->m_ident;
else if (vor->m_ident.size() > 3)
qDebug() << "Warning: VOR Ident greater than 3 characters: " << vor->m_ident;
vor->m_type = QString(type);
vor->m_name = QString(name);
vor->m_frequencykHz = frequency;
vor->m_latitude = latitude;
vor->m_longitude = longitude;
vor->m_elevation = elevation;
if (power && !strcmp(power, "HIGH"))
vor->m_range = 100;
else if (power && !strcmp(power, "MEDIUM"))
vor->m_range = 40;
else
vor->m_range = 25;
vor->m_magneticDeclination = 0.0f;
vor->m_alignedTrueNorth = false;
navAidInfo->insert(id, vor);
cnt++;
}
}
}
fclose(file);
}
else
qDebug() << "NavAid::readNavAidsDB: Failed to open " << filename;
qDebug() << "NavAid::readNavAidsDB: Read " << cnt << " VORs";
return navAidInfo;
}
};
#endif // INCLUDE_NAVAID_H

Wyświetl plik

@ -1,4 +1,4 @@
<h1>VOR demodulator plugin</h1>
<h1>VOR demodulator plugin - Single channel version</h1>
<h2>Introduction</h2>
@ -10,10 +10,12 @@ VORs also transmit a Morse code ident signal at a 1020Hz offset. This is a 2 or
Some VORs also transmit an AM voice identification or information signal between 300-3kHz.
This plugin can demodulate all four signals from multiple VORs simultaneously, allowing your position to be determined and plotted on a map. It can also demodulate the Morse code ident signal and and check they are correct for each VOR. The Morse code ident and any voice signal will also be heard as audio.
Note that for aircraft, there is typically a direct line-of-sight to the VOR. This is unlikely to be the case when using an SDR on the ground. To get good results, ideally you want to be on a nice high hill or close to the VOR.
<h2>Using it for localization</h2>
Several instances of this plugin can be created to monitor multiple VORs and collate information in the VOR Localizer feature plugin. The VOR Localizer can also perform a round robin on multiple VORs with just one VOR demodulator. Please refer to ... for more information about this feature plugin
<h2>Interface</h2>
![VOR Demodulator plugin GUI](../../../doc/img/VORDemod_plugin.png)
@ -34,14 +36,6 @@ Left click on this button to toggle audio mute for this channel. The button will
If you right click on it it will open a dialog to select the audio output device. See [audio management documentation](../../../sdrgui/audio.md) for details.
<h3>4: Download VOR Database</h3>
Pressing this button downloads the OpenAIP.net Navaid database, which contains the details (position, frequencies, name and ident) for each VOR. This needs to be performed at least once.
<h3>5: Draw Radials Adjusted for Magnetic Declination</h3>
When checked, radials on the map will drawn adjusted for magnetic declination. For example, if a VOR has a magnetic declination of 5 degrees, and the radial is calculated at 0 degrees, the radial will be drawn to magnetic North, i.e. -5 degress from true North. If not checked, the same radial would be drawn to true North (i.e 0 degrees), which may result in a less accurate position estimate.
<h3>6: Morse ident threshold</h3>
This is the Morse code ident threshold, expressed as a linear signal to noise (SNR) ratio. This is effectively the signal level required for the Morse demodulator to detect a dot or dash. Setting this to low values will allow the Morse demodulator to detect weak signals, but it also increases the likelyhood that noise will incorrectly be interpreted as a signal, resulting in invalid idents being reported.
@ -53,37 +47,3 @@ This is the squelch threshold in dB. The average total power received in the sig
<h3>8: Volume</h3>
This is the volume of the audio signal from 0.0 (mute) to 10.0 (maximum). It can be varied continuously in 0.1 steps using the dial button.
<h3>VOR Table</h3>
The VOR table displays information about selected VORs. To select or deselect a VOR, double click it on the map. The information displayed includes:
![VOR Demodulator Table](../../../doc/img/VORDemod_plugin_table.png)
* Name - The name of the VOR. For example: 'LONDON'.
* Freq (MHz) - The center frequency the VOR transmits on in MHz.
* Offset (kHz) - This is the current difference between the VOR's center frequency and SDRangle's device center frequency. If displayed in red, the VOR is out of range and it's signal will not be able to be received.
* Ident - A 2 or 3 character identifier for the VOR. For example: 'LON'.
* Morse - The Morse code identifier for the VOR. For example: '.-.. --- -.'
* RX Ident - This contains the demodulated ident. If it matches the expected ident, it will be displayed in green, if not, it will be displayed in red. If an ident is received that is not 2 or 3 characters, it will not be displayed, but the last received ident will be displayed in yellow.
* RX Morse - This contains the demodulated Morse code ident. Colour coding is as for RX Ident.
* Radial - This contains the demodulated radial direction in degrees (unadjusted for magnetic declination). If there is a low confidence the value is correct (due to a weak signal), it will be displayed in red.
* Ref (dB) - This displays the magnitude of the received 30Hz FM reference signal in dB.
* Var (dB) - This displays the mangitude of the received 30Hz AM variable signal in dB.
* Mute - This button allows you to mute or unmute the audio from the corresponding VOR.
<h3>Map</h3>
The map displays the locations of each VOR, with an information box containing the information about the VOR, such as it's name, frequency, ident (in text and Morse), range and magnetic declination.
To initialise the VORs on the map, first set your position using the Preferences > My position menu, then open the VOR Demodulator channel (close and reopen it, if already open). Then press the Download VOR Database button (This only needs to be performed once). The map should then display VORs in your vicinity.
Double clicking on a VOR will select and add it to the list of VORs to demodulate. It will be added to the VOR table and will be highlighted green. Double clicking a selected VOR, will remove it from the list of VORs to demodulate and it will be removed from the VOR table.
When a signal from a VOR is correctly being demodulated, a radial line will be drawn on the map, at the angle corresponding to the phase difference between the AM and FM 30Hz signals. Your receiver should be somewhere along this radial line. The length of the radial line is set according to the range of the VOR as recorded in the database, which is valid for aircraft at altitude. Range on the ground will be considerably less. An approximate position for the receiver is where the radial lines from two or more VORs intersect.
![VOR Demodulator Map](../../../doc/img/VORDemod_plugin_map.png)
<h2>Attribution</h2>
Icons by Denelson83 and mamayer, via Wikimedia Commons and RULI from the Noun Project https://thenounproject.com/

Wyświetl plik

@ -196,10 +196,6 @@ void VORDemodSC::applySettings(const VORDemodSCSettings& settings, bool force)
reverseAPIKeys.append("identThreshold");
}
if ((m_settings.m_magDecAdjust != settings.m_magDecAdjust) || force) {
reverseAPIKeys.append("magDecAdjust");
}
VORDemodSCBaseband::MsgConfigureVORDemodBaseband *msg = VORDemodSCBaseband::MsgConfigureVORDemodBaseband::create(settings, force);
m_basebandSink->getInputMessageQueue()->push(msg);
@ -323,9 +319,6 @@ void VORDemodSC::webapiUpdateChannelSettings(
if (channelSettingsKeys.contains("identThreshold")) {
settings.m_identThreshold = response.getVorDemodSettings()->getIdentThreshold();
}
if (channelSettingsKeys.contains("magDecAdjust")) {
settings.m_magDecAdjust = response.getVorDemodSettings()->getMagDecAdjust() != 0;
}
}
int VORDemodSC::webapiReportGet(
@ -372,7 +365,6 @@ void VORDemodSC::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& re
response.getVorDemodSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
response.getVorDemodSettings()->setIdentThreshold(settings.m_identThreshold);
response.getVorDemodSettings()->setMagDecAdjust(settings.m_magDecAdjust ? 1 : 0);
}
void VORDemodSC::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
@ -479,9 +471,6 @@ void VORDemodSC::webapiFormatChannelSettings(
if (channelSettingsKeys.contains("identThreshold") || force) {
swgVORDemodSettings->setAudioMute(settings.m_identThreshold);
}
if (channelSettingsKeys.contains("magDecAdjust") || force) {
swgVORDemodSettings->setAudioMute(settings.m_magDecAdjust ? 1 : 0);
}
}
void VORDemodSC::networkManagerFinished(QNetworkReply *reply)

Wyświetl plik

@ -28,36 +28,23 @@
MESSAGE_CLASS_DEFINITION(VORDemodSCBaseband::MsgConfigureVORDemodBaseband, Message)
VORDemodSCBaseband::VORDemodSCBaseband() :
m_running(false),
m_mutex(QMutex::Recursive),
m_messageQueueToGUI(nullptr),
m_basebandSampleRate(0)
m_running(false),
m_mutex(QMutex::Recursive)
{
qDebug("VORDemodSCBaseband::VORDemodSCBaseband");
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000));
m_channelizer = new DownChannelizer(&m_sink);
// FIXME: If we remove this audio stops working when this demod is closed
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(&m_audioFifoBug, getInputMessageQueue());
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue());
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
}
VORDemodSCBaseband::~VORDemodSCBaseband()
{
m_inputMessageQueue.clear();
for (int i = 0; i < m_sinks.size(); i++)
{
DSPEngine::instance()->getAudioDeviceManager()->removeAudioSink(m_sinks[i]->getAudioFifo());
delete m_sinks[i];
}
m_sinks.clear();
// FIXME: If we remove this audio stops working when this demod is closed
DSPEngine::instance()->getAudioDeviceManager()->removeAudioSink(&m_audioFifoBug);
for (int i = 0; i < m_channelizers.size(); i++)
delete m_channelizers[i];
m_channelizers.clear();
DSPEngine::instance()->getAudioDeviceManager()->removeAudioSink(m_sink.getAudioFifo());
delete m_channelizer;
}
void VORDemodSCBaseband::reset()
@ -114,14 +101,12 @@ void VORDemodSCBaseband::handleData()
// first part of FIFO data
if (part1begin != part1end) {
for (int i = 0; i < m_channelizers.size(); i++)
m_channelizers[i]->feed(part1begin, part1end);
m_channelizer->feed(part1begin, part1end);
}
// second part of FIFO data (used when block wraps around)
if(part2begin != part2end) {
for (int i = 0; i < m_channelizers.size(); i++)
m_channelizers[i]->feed(part2begin, part2end);
m_channelizer->feed(part2begin, part2end);
}
m_sampleFifo.readCommit((unsigned int) count);
@ -157,9 +142,10 @@ bool VORDemodSCBaseband::handleMessage(const Message& cmd)
QMutexLocker mutexLocker(&m_mutex);
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
qDebug() << "VORDemodSCBaseband::handleMessage: DSPSignalNotification: basebandSampleRate: " << notif.getSampleRate() << " centerFrequency: " << notif.getCenterFrequency();
m_centerFrequency = notif.getCenterFrequency();
setBasebandSampleRate(notif.getSampleRate());
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(m_basebandSampleRate));
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
return true;
}
@ -169,114 +155,33 @@ bool VORDemodSCBaseband::handleMessage(const Message& cmd)
}
}
// Calculate offset of VOR center frequency from sample source center frequency
void VORDemodSCBaseband::calculateOffset(VORDemodSCSink *sink)
{
int frequencyOffset = sink->m_vorFrequencyHz - m_centerFrequency;
bool outOfBand = std::abs(frequencyOffset)+VORDEMOD_CHANNEL_BANDWIDTH > (m_basebandSampleRate/2);
if (m_messageQueueToGUI != nullptr)
{
VORDemodSCReport::MsgReportFreqOffset *msg = VORDemodSCReport::MsgReportFreqOffset::create(sink->m_subChannelId, frequencyOffset, outOfBand);
m_messageQueueToGUI->push(msg);
}
sink->m_frequencyOffset = frequencyOffset;
sink->m_outOfBand = outOfBand;
}
void VORDemodSCBaseband::applySettings(const VORDemodSCSettings& settings, bool force)
{
// Remove sub-channels no longer needed
for (int i = 0; i < m_sinks.size(); i++)
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force)
{
if (!settings.m_subChannelSettings.contains(m_sinks[i]->m_subChannelId))
{
qDebug() << "VORDemodSCBaseband::applySettings: Removing sink " << m_sinks[i]->m_subChannelId;
VORDemodSCSink *sink = m_sinks[i];
DSPEngine::instance()->getAudioDeviceManager()->removeAudioSink(m_sinks[i]->getAudioFifo());
m_sinks.removeAt(i);
delete sink;
DownChannelizer *channelizer = m_channelizers[i];
m_channelizers.removeAt(i);
delete channelizer;
}
}
// Add new sub channels
QHash<int, VORDemodSubChannelSettings *>::const_iterator itr = settings.m_subChannelSettings.begin();
while (itr != settings.m_subChannelSettings.end())
{
VORDemodSubChannelSettings *subChannelSettings = itr.value();
int j;
for (j = 0; j < m_sinks.size(); j++)
{
if (subChannelSettings->m_id == m_sinks[j]->m_subChannelId)
break;
}
if (j == m_sinks.size())
{
// Add a sub-channel sink
qDebug() << "VORDemodSCBaseband::applySettings: Adding sink " << subChannelSettings->m_id;
VORDemodSCSink *sink = new VORDemodSCSink(settings, subChannelSettings->m_id, m_messageQueueToGUI);
DownChannelizer *channelizer = new DownChannelizer(sink);
channelizer->setBasebandSampleRate(m_basebandSampleRate);
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(sink->getAudioFifo(), getInputMessageQueue());
sink->applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_sinks.append(sink);
m_channelizers.append(channelizer);
calculateOffset(sink);
channelizer->setChannelization(VORDEMOD_CHANNEL_SAMPLE_RATE, sink->m_frequencyOffset);
sink->applyChannelSettings(channelizer->getChannelSampleRate(), channelizer->getChannelFrequencyOffset(), true);
sink->applyAudioSampleRate(sink->getAudioSampleRate());
}
++itr;
}
if (force)
{
for (int i = 0; i < m_sinks.size(); i++)
{
m_channelizers[i]->setChannelization(VORDEMOD_CHANNEL_SAMPLE_RATE, m_sinks[i]->m_frequencyOffset);
m_sinks[i]->applyChannelSettings(m_channelizers[i]->getChannelSampleRate(), m_channelizers[i]->getChannelFrequencyOffset());
m_sinks[i]->applyAudioSampleRate(m_sinks[i]->getAudioSampleRate()); // reapply in case of channel sample rate change
}
m_channelizer->setChannelization(m_sink.getAudioSampleRate(), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
{
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
int audioDeviceIndex = audioDeviceManager->getOutputDeviceIndex(settings.m_audioDeviceName);
for (int i = 0; i < m_sinks.size(); i++)
{
audioDeviceManager->removeAudioSink(m_sinks[i]->getAudioFifo());
audioDeviceManager->addAudioSink(m_sinks[i]->getAudioFifo(), getInputMessageQueue(), audioDeviceIndex);
int audioSampleRate = audioDeviceManager->getOutputSampleRate(audioDeviceIndex);
//qDebug("AMDemod::applySettings: audioDeviceName: %s audioDeviceIndex: %d", qPrintable(settings.m_audioDeviceName), audioDeviceIndex);
audioDeviceManager->removeAudioSink(m_sink.getAudioFifo());
audioDeviceManager->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue(), audioDeviceIndex);
int audioSampleRate = audioDeviceManager->getOutputSampleRate(audioDeviceIndex);
if (m_sinks[i]->getAudioSampleRate() != audioSampleRate)
{
m_sinks[i]->applyAudioSampleRate(audioSampleRate);
}
if (m_sink.getAudioSampleRate() != audioSampleRate)
{
m_channelizer->setChannelization(audioSampleRate, settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(audioSampleRate);
}
}
for (int i = 0; i < m_sinks.size(); i++)
m_sinks[i]->applySettings(settings, force);
m_sink.applySettings(settings, force);
m_settings = settings;
}
void VORDemodSCBaseband::setBasebandSampleRate(int sampleRate)
{
m_basebandSampleRate = sampleRate;
for (int i = 0; i < m_sinks.size(); i++)
{
m_channelizers[i]->setBasebandSampleRate(sampleRate);
calculateOffset(m_sinks[i]);
m_sinks[i]->applyChannelSettings(m_channelizers[i]->getChannelSampleRate(), m_channelizers[i]->getChannelFrequencyOffset());
m_sinks[i]->applyAudioSampleRate(m_sinks[i]->getAudioSampleRate()); // reapply in case of channel sample rate change
}
}

Wyświetl plik

@ -64,68 +64,24 @@ public:
void stopWork();
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
void getMagSqLevels(double& avg, double& peak, int& nbSamples) {
avg = 0.0;
peak = 0.0;
nbSamples = 0;
for (int i = 0; i < m_sinks.size(); i++)
{
double avg1, peak1;
int nbSamples1;
m_sinks[i]->getMagSqLevels(avg1, peak1, nbSamples1);
if (avg1 > avg)
{
avg = avg1;
nbSamples = nbSamples1;
}
avg += avg1;
if (peak1 > peak)
peak = peak1;
}
}
void setMessageQueueToGUI(MessageQueue *messageQueue) {
m_messageQueueToGUI = messageQueue;
for (int i = 0; i < m_sinks.size(); i++)
m_sinks[i]->setMessageQueueToGUI(messageQueue);
}
bool getSquelchOpen() const {
for (int i = 0; i < m_sinks.size(); i++)
{
if (m_sinks[i]->getSquelchOpen())
return true;
}
return false;
}
int getAudioSampleRate() const {
if (m_sinks.size() > 0)
return m_sinks[0]->getAudioSampleRate();
else
return 48000;
}
void setBasebandSampleRate(int sampleRate);
double getMagSq() const {
if (m_sinks.size() > 0)
return m_sinks[0]->getMagSq();
else
return 0.0;
}
void getMagSqLevels(double& avg, double& peak, int& nbSamples) { m_sink.getMagSqLevels(avg, peak, nbSamples); }
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_sink.setMessageQueueToGUI(messageQueue); }
bool getSquelchOpen() const { return m_sink.getSquelchOpen(); }
int getAudioSampleRate() const { return m_sink.getAudioSampleRate(); }
double getMagSq() const { return m_sink.getMagSq(); }
bool isRunning() const { return m_running; }
private:
SampleSinkFifo m_sampleFifo;
QList<DownChannelizer *> m_channelizers;
QList<VORDemodSCSink *> m_sinks;
AudioFifo m_audioFifoBug; // FIXME: Removing this results in audio stopping when demod is closed
DownChannelizer * m_channelizer;
VORDemodSCSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
VORDemodSCSettings m_settings;
MessageQueue *m_messageQueueToGUI;
bool m_running;
QMutex m_mutex;
MessageQueue *m_messageQueueToGUI;
int m_basebandSampleRate;
int m_centerFrequency;
bool handleMessage(const Message& cmd);
void calculateOffset(VORDemodSCSink *sink);
void applySettings(const VORDemodSCSettings& settings, bool force = false);
private slots:

Wyświetl plik

@ -19,26 +19,11 @@
#ifndef INCLUDE_VORDEMODSCGUI_H
#define INCLUDE_VORDEMODSCGUI_H
#include <QIcon>
#include <QAbstractListModel>
#include <QModelIndex>
#include <QProgressDialog>
#include <QGeoLocation>
#include <QGeoCoordinate>
#include <QTableWidgetItem>
#include <QPushButton>
#include <QToolButton>
#include <QHBoxLayout>
#include <QMenu>
#include "channel/channelgui.h"
#include "dsp/channelmarker.h"
#include "dsp/movingaverage.h"
#include "util/messagequeue.h"
#include "util/httpdownloadmanager.h"
#include "util/azel.h"
#include "vordemodscsettings.h"
#include "navaid.h"
class PluginAPI;
class DeviceUISet;
@ -51,151 +36,6 @@ namespace Ui {
}
class VORDemodSCGUI;
// Table items for each VOR
class VORGUI : public QObject {
Q_OBJECT
public:
NavAid *m_navAid;
QVariantList m_coordinates;
VORDemodSCGUI *m_gui;
QTableWidgetItem *m_nameItem;
QTableWidgetItem *m_frequencyItem;
QTableWidgetItem *m_offsetItem;
QTableWidgetItem *m_identItem;
QTableWidgetItem *m_morseItem;
QTableWidgetItem *m_radialItem;
QTableWidgetItem *m_rxIdentItem;
QTableWidgetItem *m_rxMorseItem;
QTableWidgetItem *m_varMagItem;
QTableWidgetItem *m_refMagItem;
QWidget *m_muteItem;
QToolButton *m_muteButton;
VORGUI(NavAid *navAid, VORDemodSCGUI *gui);
private slots:
void on_audioMute_toggled(bool checked);
};
// VOR model used for each VOR on the map
class VORModel : public QAbstractListModel {
Q_OBJECT
public:
using QAbstractListModel::QAbstractListModel;
enum MarkerRoles{
positionRole = Qt::UserRole + 1,
vorDataRole = Qt::UserRole + 2,
vorImageRole = Qt::UserRole + 3,
vorRadialRole = Qt::UserRole + 4,
bubbleColourRole = Qt::UserRole + 5,
selectedRole = Qt::UserRole + 6
};
VORModel(VORDemodSCGUI *gui) :
m_gui(gui),
m_radialsVisible(true)
{
}
Q_INVOKABLE void addVOR(NavAid *vor) {
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_vors.append(vor);
m_selected.append(false);
m_radials.append(-1.0f);
m_vorGUIs.append(nullptr);
endInsertRows();
}
int rowCount(const QModelIndex &parent = QModelIndex()) const override {
Q_UNUSED(parent)
return m_vors.count();
}
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant& value, int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex &index) const override {
(void) index;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
}
void allVORUpdated() {
for (int i = 0; i < m_vors.count(); i++)
{
QModelIndex idx = index(i);
emit dataChanged(idx, idx);
}
}
void removeVOR(NavAid *vor) {
int row = m_vors.indexOf(vor);
if (row >= 0)
{
beginRemoveRows(QModelIndex(), row, row);
m_vors.removeAt(row);
m_selected.removeAt(row);
m_radials.removeAt(row);
m_vorGUIs.removeAt(row);
endRemoveRows();
}
}
void removeAllVORs() {
beginRemoveRows(QModelIndex(), 0, m_vors.count());
m_vors.clear();
m_selected.clear();
m_radials.clear();
m_vorGUIs.clear();
endRemoveRows();
}
QHash<int, QByteArray> roleNames() const {
QHash<int, QByteArray> roles;
roles[positionRole] = "position";
roles[vorDataRole] = "vorData";
roles[vorImageRole] = "vorImage";
roles[vorRadialRole] = "vorRadial";
roles[bubbleColourRole] = "bubbleColour";
roles[selectedRole] = "selected";
return roles;
}
void setRadialsVisible(bool radialsVisible)
{
m_radialsVisible = radialsVisible;
allVORUpdated();
}
void setRadial(int id, bool valid, Real radial)
{
for (int i = 0; i < m_vors.count(); i++)
{
if (m_vors[i]->m_id == id)
{
if (valid)
m_radials[i] = radial;
else
m_radials[i] = -1; // -1 to indicate invalid
QModelIndex idx = index(i);
emit dataChanged(idx, idx);
break;
}
}
}
bool findIntersection(float &lat, float &lon);
private:
VORDemodSCGUI *m_gui;
bool m_radialsVisible;
QList<NavAid *> m_vors;
QList<bool> m_selected;
QList<Real> m_radials;
QList<VORGUI *> m_vorGUIs;
};
class VORDemodSCGUI : public ChannelGUI {
Q_OBJECT
@ -207,16 +47,12 @@ public:
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
void selectVOR(VORGUI *vorGUI, bool selected);
public slots:
void channelMarkerChangedByCursor();
void channelMarkerHighlightedByCursor();
private:
friend class VORGUI;
friend class VORModel;
Ui::VORDemodSCGUI* ui;
PluginAPI* m_pluginAPI;
DeviceUISet* m_deviceUISet;
@ -230,16 +66,6 @@ private:
uint32_t m_tickCount;
MessageQueue m_inputMessageQueue;
QMenu *menu; // Column select context menu
HttpDownloadManager m_dlm;
QProgressDialog *m_progressDialog;
int m_countryIndex;
VORModel m_vorModel;
QHash<int, NavAid *> *m_vors;
QHash<int, VORGUI *> m_selectedVORs;
AzEl m_azEl; // Position of station
QIcon m_muteIcon;
explicit VORDemodSCGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent = 0);
virtual ~VORDemodSCGUI();
@ -252,37 +78,14 @@ private:
void leaveEvent(QEvent*);
void enterEvent(QEvent*);
void resizeTable();
QAction *createCheckableItem(QString& text, int idx, bool checked);
void calculateFreqOffset(VORGUI *vorGUI);
void calculateFreqOffsets();
void updateVORs();
QString getOpenAIPVORDBURL(int i);
QString getOpenAIPVORDBFilename(int i);
QString getVORDBFilename();
void readNavAids();
// Move to util
QString getDataDir();
qint64 fileAgeInDays(QString filename);
bool confirmDownload(QString filename);
private slots:
void on_deltaFrequency_changed(qint64 value);
void on_thresh_valueChanged(int value);
void on_volume_valueChanged(int value);
void on_squelch_valueChanged(int value);
void on_audioMute_toggled(bool checked);
void on_getOurAirportsVORDB_clicked(bool checked = false);
void on_getOpenAIPVORDB_clicked(bool checked = false);
void on_magDecAdjust_clicked(bool checked = false);
void vorData_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
void vorData_sectionResized(int logicalIndex, int oldSize, int newSize);
void columnSelectMenu(QPoint pos);
void columnSelectMenuChecked(bool checked = false);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void updateDownloadProgress(qint64 bytesRead, qint64 totalBytes);
void downloadFinished(const QString& filename, bool success);
void handleInputMessages();
void audioSelect();
void tick();

Wyświetl plik

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>398</width>
<height>893</height>
<width>402</width>
<height>189</height>
</rect>
</property>
<property name="sizePolicy">
@ -19,7 +19,7 @@
<property name="minimumSize">
<size>
<width>352</width>
<height>0</height>
<height>110</height>
</size>
</property>
<property name="font">
@ -43,7 +43,7 @@
<x>0</x>
<y>0</y>
<width>390</width>
<height>61</height>
<height>131</height>
</rect>
</property>
<property name="minimumSize">
@ -71,6 +71,105 @@
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="deltaFreqPowLayout">
<property name="topMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="deltaFreqiencyLayout">
<item>
<widget class="QLabel" name="deltaFrequencyLabel">
<property name="minimumSize">
<size>
<width>16</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Df</string>
</property>
</widget>
</item>
<item>
<widget class="ValueDialZ" name="deltaFrequency" 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>Liberation Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Hz </string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="channelPowerLayout_2">
<item>
<widget class="QLabel" name="channelPower_2">
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>0.0</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="channelPowerUnits_2">
<property name="text">
<string> dB</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="powLayout">
<property name="topMargin">
@ -123,6 +222,12 @@
<layout class="QHBoxLayout" name="channelPowerLayout">
<item>
<widget class="QLabel" name="channelPower">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Channel power</string>
</property>
@ -130,7 +235,10 @@
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>0.0</string>
<string>-100.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -165,70 +273,6 @@
</item>
<item>
<layout class="QHBoxLayout" name="buttonLayout">
<item>
<widget class="QPushButton" name="getOurAirportsVORDB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Download OurAirports VOR database</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/demodvor/icons/vor.png</normaloff>:/demodvor/icons/vor.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="getOpenAIPVORDB">
<property name="toolTip">
<string>Download OpenAIP VOR database</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/demodvor/icons/vor.png</normaloff>:/demodvor/icons/vor.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="magDecAdjust">
<property name="toolTip">
<string>Draw radials adjusted for magnetic declination</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/demodvor/icons/compass.png</normaloff>:/demodvor/icons/compass.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="threshLabel">
<property name="minimumSize">
@ -287,11 +331,17 @@
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
@ -386,209 +436,201 @@
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="dataContainer" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>110</y>
<width>391</width>
<height>140</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>VORs</string>
</property>
<layout class="QVBoxLayout" name="verticalLayoutTable">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QTableWidget" name="vorData">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<column>
<property name="text">
<string>Name</string>
</property>
<property name="toolTip">
<string>Name of the VOR</string>
</property>
</column>
<column>
<property name="text">
<string>Freq (MHz)</string>
</property>
<property name="toolTip">
<string>Frequency of the VOR in MHz</string>
</property>
</column>
<column>
<property name="text">
<string>Offset (kHz)</string>
</property>
<property name="toolTip">
<string>Offset of the VOR's frequency from the current center frequency. Red indicates out of range.</string>
</property>
</column>
<column>
<property name="text">
<string>Ident</string>
</property>
<property name="toolTip">
<string>Ident for the VOR</string>
</property>
</column>
<column>
<property name="text">
<string>Morse</string>
</property>
<property name="toolTip">
<string>Morse code ident for the VOR</string>
</property>
</column>
<column>
<property name="text">
<string>RX Ident</string>
</property>
<property name="toolTip">
<string>Received ident</string>
</property>
</column>
<column>
<property name="text">
<string>RX Morse</string>
</property>
<property name="toolTip">
<string>Received Morse code ident</string>
</property>
</column>
<column>
<property name="text">
<string>Radial (°)</string>
</property>
<property name="toolTip">
<string>Calculated radial from the VOR</string>
</property>
</column>
<column>
<property name="text">
<string>Ref (dB)</string>
</property>
<property name="toolTip">
<string>Magnitude of received reference signal in dB</string>
</property>
</column>
<column>
<property name="text">
<string>Var (dB)</string>
</property>
<property name="toolTip">
<string>Magnitude of received variable signal in dB</string>
</property>
</column>
<column>
<property name="text">
<string>Mute</string>
</property>
<property name="toolTip">
<string>Mute/unmute audio from selected VORs</string>
</property>
</column>
</widget>
<layout class="QHBoxLayout" name="radialLayout">
<item>
<widget class="QLabel" name="radialLabel">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Rad</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="radialText">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Radial direction (degrees) red if low confidence</string>
</property>
<property name="text">
<string>359d</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="refLabel">
<property name="text">
<string>Ref</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="refText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Magnitude of the received 30Hz FM reference signal in dB</string>
</property>
<property name="text">
<string>-100 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="varLabel">
<property name="text">
<string>Var</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="varText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Magnitude of the received 30Hz AM variable signal in dB</string>
</property>
<property name="text">
<string>-100 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="mapContainer" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>260</y>
<width>391</width>
<height>581</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Map</string>
</property>
<layout class="QVBoxLayout" name="verticalLayoutMap" stretch="0">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QQuickWidget" name="map">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>500</height>
</size>
</property>
<property name="toolTip">
<string>VOR map</string>
</property>
<property name="resizeMode">
<enum>QQuickWidget::SizeRootObjectToView</enum>
</property>
<property name="source">
<url>
<string/>
</url>
</property>
</widget>
<layout class="QHBoxLayout" name="identLayout">
<item>
<widget class="QLabel" name="identLabel">
<property name="text">
<string>Ident</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="identText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Decoded identity code yellow if not matching rules</string>
</property>
<property name="text">
<string>XXX</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_13">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="morseLabel">
<property name="text">
<string>Morse</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="morseText">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Morse identity decoded yellow if not matching rules</string>
</property>
<property name="text">
<string>--- --- ---</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QQuickWidget</class>
<extends>QWidget</extends>
<header location="global">QtQuickWidgets/QQuickWidget</header>
</customwidget>
<customwidget>
<class>RollupWidget</class>
<extends>QWidget</extends>
@ -601,12 +643,15 @@
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>audioMute</tabstop>
<tabstop>getOurAirportsVORDB</tabstop>
<tabstop>vorData</tabstop>
<tabstop>map</tabstop>
</tabstops>
<resources>
<include location="../../../sdrgui/resources/res.qrc"/>

Wyświetl plik

@ -17,6 +17,5 @@
#include "vordemodscreport.h"
MESSAGE_CLASS_DEFINITION(VORDemodSCReport::MsgReportFreqOffset, Message)
MESSAGE_CLASS_DEFINITION(VORDemodSCReport::MsgReportRadial, Message)
MESSAGE_CLASS_DEFINITION(VORDemodSCReport::MsgReportIdent, Message)

Wyświetl plik

@ -31,25 +31,21 @@ public:
MESSAGE_CLASS_DECLARATION
public:
int getSubChannelId() const { return m_subChannelId; }
float getRadial() const { return m_radial; }
float getRefMag() const { return m_refMag; }
float getVarMag() const { return m_varMag; }
static MsgReportRadial* create(int subChannelId, float radial, float refMag, float varMag)
{
return new MsgReportRadial(subChannelId, radial, refMag, varMag);
static MsgReportRadial* create(float radial, float refMag, float varMag) {
return new MsgReportRadial(radial, refMag, varMag);
}
private:
int m_subChannelId;
float m_radial;
float m_refMag;
float m_varMag;
MsgReportRadial(int subChannelId, float radial, float refMag, float varMag) :
MsgReportRadial(float radial, float refMag, float varMag) :
Message(),
m_subChannelId(subChannelId),
m_radial(radial),
m_refMag(refMag),
m_varMag(varMag)
@ -57,52 +53,22 @@ public:
}
};
class MsgReportFreqOffset : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getSubChannelId() const { return m_subChannelId; }
int getFreqOffset() const { return m_freqOffset; }
bool getOutOfBand() const { return m_outOfBand; }
static MsgReportFreqOffset* create(int subChannelId, int freqOffset, bool outOfBand)
{
return new MsgReportFreqOffset(subChannelId, freqOffset, outOfBand);
}
private:
int m_subChannelId;
int m_freqOffset;
bool m_outOfBand;
MsgReportFreqOffset(int subChannelId, int freqOffset, bool outOfBand) :
Message(),
m_subChannelId(subChannelId),
m_freqOffset(freqOffset),
m_outOfBand(outOfBand)
{
}
};
class MsgReportIdent : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getSubChannelId() const { return m_subChannelId; }
QString getIdent() const { return m_ident; }
static MsgReportIdent* create(int subChannelId, QString ident)
static MsgReportIdent* create(QString ident)
{
return new MsgReportIdent(subChannelId, ident);
return new MsgReportIdent(ident);
}
private:
int m_subChannelId;
QString m_ident;
MsgReportIdent(int subChannelId, QString ident) :
MsgReportIdent(QString ident) :
Message(),
m_subChannelId(subChannelId),
m_ident(ident)
{
}

Wyświetl plik

@ -31,6 +31,7 @@ VORDemodSCSettings::VORDemodSCSettings() :
void VORDemodSCSettings::resetToDefaults()
{
m_inputFrequencyOffset = 0;
m_squelch = -60.0;
m_volume = 2.0;
m_audioMute = false;
@ -47,18 +48,12 @@ void VORDemodSCSettings::resetToDefaults()
m_identThreshold = 2.0;
m_refThresholdDB = -45.0;
m_varThresholdDB = -90.0;
m_magDecAdjust = true;
for (int i = 0; i < VORDEMOD_COLUMNS; i++)
{
m_columnIndexes[i] = i;
m_columnSizes[i] = -1; // Autosize
}
}
QByteArray VORDemodSCSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_inputFrequencyOffset);
s.writeS32(3, m_streamIndex);
s.writeS32(4, m_volume*10);
s.writeS32(5, m_squelch);
@ -79,12 +74,6 @@ QByteArray VORDemodSCSettings::serialize() const
s.writeReal(20, m_identThreshold);
s.writeReal(21, m_refThresholdDB);
s.writeReal(22, m_varThresholdDB);
s.writeBool(23, m_magDecAdjust);
for (int i = 0; i < VORDEMOD_COLUMNS; i++)
s.writeS32(100 + i, m_columnIndexes[i]);
for (int i = 0; i < VORDEMOD_COLUMNS; i++)
s.writeS32(200 + i, m_columnSizes[i]);
return s.final();
}
@ -106,6 +95,7 @@ bool VORDemodSCSettings::deserialize(const QByteArray& data)
uint32_t utmp;
QString strtmp;
d.readS32(1, &m_inputFrequencyOffset, 0);
d.readS32(3, &m_streamIndex, 0);
d.readS32(4, &tmp, 20);
m_volume = tmp * 0.1;
@ -138,12 +128,6 @@ bool VORDemodSCSettings::deserialize(const QByteArray& data)
d.readReal(20, &m_identThreshold, 2.0);
d.readReal(21, &m_refThresholdDB, -45.0);
d.readReal(22, &m_varThresholdDB, -90.0);
d.readBool(23, &m_magDecAdjust, true);
for (int i = 0; i < VORDEMOD_COLUMNS; i++)
d.readS32(100 + i, &m_columnIndexes[i], i);
for (int i = 0; i < VORDEMOD_COLUMNS; i++)
d.readS32(200 + i, &m_columnSizes[i], -1);
return true;
}

Wyświetl plik

@ -24,17 +24,9 @@
class Serializable;
// Number of columns in the table
#define VORDEMOD_COLUMNS 11
struct VORDemodSubChannelSettings {
int m_id; //!< Unique VOR identifier (from database)
int m_frequency; //!< Frequency the VOR is on
bool m_audioMute; //!< Mute the audio from this VOR
};
struct VORDemodSCSettings
{
qint32 m_inputFrequencyOffset;
Real m_squelch;
Real m_volume;
bool m_audioMute;
@ -52,12 +44,14 @@ struct VORDemodSCSettings
Real m_identThreshold; //!< Linear SNR threshold for Morse demodulator
Real m_refThresholdDB; //!< Threshold in dB for valid VOR reference signal
Real m_varThresholdDB; //!< Threshold in dB for valid VOR variable signal
bool m_magDecAdjust; //!< Adjust for magnetic declination when drawing radials on the map
int m_columnIndexes[VORDEMOD_COLUMNS];//!< How the columns are ordered in the table
int m_columnSizes[VORDEMOD_COLUMNS]; //!< Size of the coumns in the table
QHash<int, VORDemodSubChannelSettings *> m_subChannelSettings;
// Highest frequency is the FM subcarrier at up to ~11kHz
// However, old VORs can have 0.005% frequency offset, which is 6kHz
static const int VORDEMOD_CHANNEL_BANDWIDTH = 18000;
// Sample rate needs to be at least twice the above
// Also need to consider impact frequency resolution of Goertzel filters
// May as well make it a common audio rate, to possibly avoid decimation
static const int VORDEMOD_CHANNEL_SAMPLE_RATE = 48000;
VORDemodSCSettings();
void resetToDefaults();

Wyświetl plik

@ -27,14 +27,13 @@
#include "util/morse.h"
#include "util/units.h"
#include "vordemodscsink.h"
#include "vordemodscreport.h"
#include "vordemodscsettings.h"
#include "vordemodscsink.h"
VORDemodSCSink::VORDemodSCSink(const VORDemodSCSettings& settings, int subChannel,
MessageQueue *messageQueueToGUI) :
VORDemodSCSink::VORDemodSCSink() :
m_channelFrequencyOffset(0),
m_outOfBand(true),
m_channelSampleRate(VORDEMOD_CHANNEL_SAMPLE_RATE),
m_channelSampleRate(VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE),
m_audioSampleRate(48000),
m_squelchCount(0),
m_squelchOpen(false),
@ -42,29 +41,22 @@ VORDemodSCSink::VORDemodSCSink(const VORDemodSCSettings& settings, int subChanne
m_magsqSum(0.0f),
m_magsqPeak(0.0f),
m_magsqCount(0),
m_messageQueueToGUI(messageQueueToGUI),
m_volumeAGC(0.003),
m_audioFifo(48000),
m_refPrev(0.0f),
m_movingAverageIdent(5000),
m_prevBit(0),
m_bitTime(0),
m_varGoertzel(30, VORDEMOD_CHANNEL_SAMPLE_RATE),
m_refGoertzel(30, VORDEMOD_CHANNEL_SAMPLE_RATE)
m_varGoertzel(30, VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE),
m_refGoertzel(30, VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE)
{
m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0;
m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0;
m_magsq = 0.0;
m_magsq = 0.0;
qDebug() << "Sink " << subChannel;
if (subChannel >= 0)
{
m_subChannelId = subChannel;
m_vorFrequencyHz = settings.m_subChannelSettings[subChannel]->m_frequency;
applySettings(settings, true);
}
applySettings(m_settings, true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
}
VORDemodSCSink::~VORDemodSCSink()
@ -75,9 +67,6 @@ void VORDemodSCSink::feed(const SampleVector::const_iterator& begin, const Sampl
{
Complex ci;
if (m_outOfBand)
return;
for (SampleVector::const_iterator it = begin; it != end; ++it)
{
Complex c(it->real(), it->imag());
@ -148,7 +137,7 @@ void VORDemodSCSink::processOneAudioSample(Complex &ci)
m_squelchOpen = (m_squelchCount >= (unsigned int)m_audioSampleRate / 20);
if (m_squelchOpen && !m_settings.m_audioMute && !m_settings.m_subChannelSettings.value(m_subChannelId)->m_audioMute)
if (m_squelchOpen && !m_settings.m_audioMute)
{
Real demod;
@ -219,7 +208,7 @@ void VORDemodSCSink::processOneSample(Complex &ci)
// Calculate phase of 30Hz variable AM signal
double varPhase;
double varMag;
if (m_varGoertzel.size() == VORDEMOD_CHANNEL_SAMPLE_RATE - 1)
if (m_varGoertzel.size() == VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE - 1)
{
m_varGoertzel.goertzel(mag);
varPhase = Units::radiansToDegress(m_varGoertzel.phase());
@ -242,13 +231,13 @@ void VORDemodSCSink::processOneSample(Complex &ci)
m_refPrev = fmfilt;
// Calculate phase of 30Hz reference FM signal
if (m_refGoertzel.size() == VORDEMOD_CHANNEL_SAMPLE_RATE - 1)
if (m_refGoertzel.size() == VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE - 1)
{
m_refGoertzel.goertzel(phi);
float phaseDeg = Units::radiansToDegress(m_refGoertzel.phase());
double refMag = m_refGoertzel.mag();
int groupDelay = (301-1)/2;
float filterPhaseShift = 360.0*30.0*groupDelay/VORDEMOD_CHANNEL_SAMPLE_RATE;
float filterPhaseShift = 360.0*30.0*groupDelay/VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE;
float shiftedPhase = phaseDeg + filterPhaseShift;
// Calculate difference in phase, which is the radial
@ -262,7 +251,7 @@ void VORDemodSCSink::processOneSample(Complex &ci)
if (getMessageQueueToGUI())
{
VORDemodSCReport::MsgReportRadial *msg = VORDemodSCReport::MsgReportRadial::create(m_subChannelId, phaseDifference, refMag, varMag);
VORDemodSCReport::MsgReportRadial *msg = VORDemodSCReport::MsgReportRadial::create(phaseDifference, refMag, varMag);
getMessageQueueToGUI()->push(msg);
}
@ -316,7 +305,7 @@ void VORDemodSCSink::processOneSample(Complex &ci)
qDebug() << m_ident << " " << Morse::toString(m_ident);
if (getMessageQueueToGUI())
{
VORDemodSCReport::MsgReportIdent *msg = VORDemodSCReport::MsgReportIdent::create(m_subChannelId, m_ident);
VORDemodSCReport::MsgReportIdent *msg = VORDemodSCReport::MsgReportIdent::create(m_ident);
getMessageQueueToGUI()->push(msg);
}
m_ident = "";
@ -355,7 +344,7 @@ void VORDemodSCSink::processOneSample(Complex &ci)
qDebug() << m_ident << " " << Morse::toString(m_ident);
if (getMessageQueueToGUI())
{
VORDemodSCReport::MsgReportIdent *msg = VORDemodSCReport::MsgReportIdent::create(m_subChannelId, m_ident);
VORDemodSCReport::MsgReportIdent *msg = VORDemodSCReport::MsgReportIdent::create(m_ident);
getMessageQueueToGUI()->push(msg);
}
m_ident = "";
@ -380,17 +369,17 @@ void VORDemodSCSink::applyChannelSettings(int channelSampleRate, int channelFreq
if ((m_channelSampleRate != channelSampleRate) || force)
{
m_interpolator.create(16, channelSampleRate, VORDEMOD_CHANNEL_BANDWIDTH);
m_interpolator.create(16, channelSampleRate, VORDemodSCSettings::VORDEMOD_CHANNEL_BANDWIDTH);
m_interpolatorDistanceRemain = 0;
m_interpolatorDistance = (Real) channelSampleRate / (Real) VORDEMOD_CHANNEL_SAMPLE_RATE;
m_interpolatorDistance = (Real) channelSampleRate / (Real) VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE;
m_samplesPerDot7wpm = VORDEMOD_CHANNEL_SAMPLE_RATE*60/(50*7);
m_samplesPerDot10wpm = VORDEMOD_CHANNEL_SAMPLE_RATE*60/(50*10);
m_samplesPerDot7wpm = VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE*60/(50*7);
m_samplesPerDot10wpm = VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE*60/(50*10);
m_ncoIdent.setFreq(-1020, VORDEMOD_CHANNEL_SAMPLE_RATE); // +-50Hz source offset allowed
m_ncoRef.setFreq(-9960, VORDEMOD_CHANNEL_SAMPLE_RATE);
m_lowpassIdent.create(301, VORDEMOD_CHANNEL_SAMPLE_RATE, 100.0f);
m_lowpassRef.create(301, VORDEMOD_CHANNEL_SAMPLE_RATE, 600.0f); // Max deviation is 480Hz
m_ncoIdent.setFreq(-1020, VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE); // +-50Hz source offset allowed
m_ncoRef.setFreq(-9960, VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE);
m_lowpassIdent.create(301, VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE, 100.0f);
m_lowpassRef.create(301, VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE, 600.0f); // Max deviation is 480Hz
m_movingAverageIdent.resize(m_samplesPerDot10wpm/5); // Needs to be short enough for noise floor calculation
m_binSampleCnt = 0;
@ -433,9 +422,9 @@ void VORDemodSCSink::applyAudioSampleRate(int sampleRate)
qDebug("VORDemodSCSink::applyAudioSampleRate: sampleRate: %d m_channelSampleRate: %d", sampleRate, m_channelSampleRate);
// (ICAO Annex 10 3.3.6.3) - Optional voice audio is 300Hz to 3kHz
m_audioInterpolator.create(16, VORDEMOD_CHANNEL_SAMPLE_RATE, 3000.0f);
m_audioInterpolator.create(16, VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE, 3000.0f);
m_audioInterpolatorDistanceRemain = 0;
m_audioInterpolatorDistance = (Real) VORDEMOD_CHANNEL_SAMPLE_RATE / (Real) sampleRate;
m_audioInterpolatorDistance = (Real) VORDemodSCSettings::VORDEMOD_CHANNEL_SAMPLE_RATE / (Real) sampleRate;
m_bandpass.create(301, sampleRate, 300.0f, 3000.0f);
m_audioFifo.setSize(sampleRate);
m_squelchDelayLine.resize(sampleRate/5);

Wyświetl plik

@ -34,18 +34,9 @@
#include <vector>
// Highest frequency is the FM subcarrier at up to ~11kHz
// However, old VORs can have 0.005% frequency offset, which is 6kHz
#define VORDEMOD_CHANNEL_BANDWIDTH 18000
// Sample rate needs to be at least twice the above
// Also need to consider impact frequency resolution of Goertzel filters
// May as well make it a common audio rate, to possibly avoid decimation
#define VORDEMOD_CHANNEL_SAMPLE_RATE 48000
class VORDemodSCSink : public ChannelSampleSink {
public:
VORDemodSCSink(const VORDemodSCSettings& settings, int subChannel,
MessageQueue *messageQueueToGUI);
VORDemodSCSink();
~VORDemodSCSink();
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
@ -78,11 +69,7 @@ public:
m_magsqCount = 0;
}
int m_subChannelId; // The id for the VOR this demod sink was created for
int m_vorFrequencyHz; // The VORs frequency
int m_frequencyOffset; // Different between sample source center frequeny and VOR center frequency
int m_channelFrequencyOffset;
bool m_outOfBand;
private:
struct MagSqLevelsStore