Skip to content
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

Version 20240107-0 release #68

Merged
merged 35 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
968a755
README.md: remove readerwriterqueue
jj1bdx Dec 27, 2023
2fdd667
Merge branch 'main' into dev
jj1bdx Dec 27, 2023
c1dbf72
Use averaging on pilot level threshold detection
jj1bdx Jan 4, 2024
1979762
Raise pilot_level_threshold to 0.02
jj1bdx Jan 4, 2024
ac1c5dc
Merge pull request #60 from jj1bdx/dev-pilot-avg
jj1bdx Jan 5, 2024
c25d3ab
Add cmake-git-version-tracking
jj1bdx Jan 5, 2024
421c3bd
Ignore .cache/ and build/ contents
jj1bdx Jan 5, 2024
b5c2803
Add old softfm code sincfilter3.py
jj1bdx Jan 5, 2024
d90eba0
Merge branch 'dev' into dev-version-tracking
jj1bdx Jan 5, 2024
b8e6602
Merge pull request #61 from jj1bdx/dev-version-tracking
jj1bdx Jan 5, 2024
5e4050c
Stop using PilotState::Detected
jj1bdx Jan 5, 2024
be0c665
CMakeLists.txt: add compile_commands.json support
jj1bdx Jan 5, 2024
6d19839
main.cpp: remove pilot_level_threshold
jj1bdx Jan 5, 2024
3668c9e
Merge pull request #63 from jj1bdx/dev-pilot-remove-announce
jj1bdx Jan 6, 2024
5dec3a3
Merge pull request #62 from jj1bdx/dev-cmake-compile-commands
jj1bdx Jan 6, 2024
75f4707
Airspy{HF}Source.h: add thread header
jj1bdx Jan 6, 2024
c4ab3c2
Remove unused include directives
jj1bdx Jan 6, 2024
702d048
AirspyHFSource: use Utility::parse_int() instead of atoi()
jj1bdx Jan 6, 2024
7bdb406
AirspyHFSource: initialize Utility::parse_int() result variables
jj1bdx Jan 6, 2024
8cd659e
FileSource: use Utility::parse_int() instead of atoi()
jj1bdx Jan 6, 2024
6dceb8e
FileSource: show parsed integers during configuration
jj1bdx Jan 6, 2024
6a2d1b7
main.cpp: check pull_end_reached() in the main loop
jj1bdx Jan 6, 2024
48e7358
fix: clang-format
jj1bdx Jan 6, 2024
5d1794a
AirspySource: use Utility::parse_int() instead of atoi()
jj1bdx Jan 6, 2024
18e063d
RtlSdrSource: use Utility::parse_int() instead of atoi()
jj1bdx Jan 6, 2024
c41bf1e
AudioOutput.cpp: remove offensive and unused _FILE_OFFSET_BITS
jj1bdx Jan 6, 2024
a43ed93
main.cpp: set stop_flag when pull_end_reached()
jj1bdx Jan 6, 2024
dd06cf2
Merge pull request #64 from jj1bdx/dev-clang-warning-fix
jj1bdx Jan 7, 2024
7ce223b
Set RtlSdrSource::default_block_length to 16384
jj1bdx Jan 7, 2024
30e16fb
main.cpp: calculate main.cpp in practical way
jj1bdx Jan 7, 2024
773709e
Merge pull request #66 from jj1bdx/dev-rtlsdr-fix
jj1bdx Jan 7, 2024
1c347c4
Documentation change for 20240107-0
jj1bdx Jan 7, 2024
01e9683
CHANGES.md: fix cmake-git-version-tracking URL
jj1bdx Jan 7, 2024
7c83f75
README.md: fix on URL and obsolete master branch
jj1bdx Jan 7, 2024
b0157dd
Merge pull request #67 from jj1bdx/dev-20240107-0
jj1bdx Jan 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,11 @@ _deps
*-prefix/

# End of https://www.toptal.com/developers/gitignore/api/cmake

# clangd

.cache/

# working directory

build/
Expand Down
21 changes: 21 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The following submodule is required:

* [r8brain-free-src](https://github.com/avaneev/r8brain-free-src)

## External version control code required

The following Git repository is required:

* [jj1bdx's fork of cmake-git-version-tracking](https://github.com/jj1bdx/cmake-git-version-tracking)

## Platforms tested

* Mac mini 2023 Apple Silicon (M2 Pro), macOS 14.2.1, Xcode 15.1 Command Line Tools
Expand All @@ -30,6 +36,21 @@ Intel Mac hardware is no longer supported by airspy-fmradion, although the autho

## Changes (including requirement changes)

* 20240107-0: Made the following changes:
- For broadcasting FM, show stereo 19kHz pilot signal level when detected.
- Remove displaying whether FM stereo pilot signal level is stable or unstable.
- Add Git info into the binary program built, with [cmake-git-version-tracking](https://github.com/andrew-hardin/cmake-git-version-tracking.git) (using jj1bdx's fork).
- Add compile command database support on CMakeLists.txt.
- Cleaned up old documents.
- Fixed the following bugs detected by clang-tidy:
* [ERR34-C. Detect errors when converting a string to a number](https://wiki.sei.cmu.edu/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number)
- Use `Utility::parse_int()` instead of raw `atoi()`
* [DCL51-CPP. Do not declare or define a reserved identifier](https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL51-CPP.+Do+not+declare+or+define+a+reserved+identifier)
- Remove unused `_FILE_OFFSET_BITS`
- Fixed the bug of FileSource playback: the code did not terminate after the end of playback.
- main.cpp: add checking pull_end_reached() in the main loop.
- Set RtlSdrSource's default_block_length from 65536 to 16384, to prevent popping cracking sound (observed on Mac mini 2023).
- stat_rate calculation is redesigned by observation of actual SDR units (:i.e., Airspy HF+, Airspy R2, and RTL-SDR).
* 20231227-0: Made the following changes:
- Split class PilotPhaseLock from FmDecode.
- Removed submodule readerwriterqueue.
Expand Down
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
# CMake definitions for airspy-fmradion

cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.18)
project(airspy-fmradion)

# Workaround for the compilation warning
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

# Enable compile_commands.json as default
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Use cmake-git-version-tracking
include(FetchContent)
FetchContent_Declare(cmake_git_version_tracking
GIT_REPOSITORY https://github.com/jj1bdx/cmake-git-version-tracking.git
GIT_TAG 9b5fc5088b4089ff2adc20d607976b9923e3d737
)
FetchContent_MakeAvailable(cmake_git_version_tracking)
# EXPORT_COMPILE_COMMANDS is supported for CMake version 3.20 or later only
if (CMAKE_VERSION VERSION_LESS 3.20.0)
message(STATUS "No EXPORT_COMPILE_COMMANDS available")
message(STATUS "Use compdb for proper compile_commands.json handling")
else()
set_target_properties(cmake_git_version_tracking
PROPERTIES EXPORT_COMPILE_COMMANDS OFF)
endif()

# Use pkg-config
include(FindPkgConfig)

# Find Threads package
find_package(Threads)

# Find Volk library.
Expand Down Expand Up @@ -205,6 +225,7 @@ set(sfmbase_HEADERS
include/FineTuner.h
include/FmDecode.h
include/FourthConverterIQ.h
include/git.h
include/IfResampler.h
include/IfSimpleAgc.h
include/MovingAverage.h
Expand Down Expand Up @@ -272,6 +293,7 @@ target_link_libraries(airspy-fmradion
${PORTAUDIO_LINK_LIBRARIES}
${VOLK_LIBRARY}
${EXTRA_LIBS}
cmake_git_version_tracking
)

target_link_libraries(sfmbase
Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# airspy-fmradion

* Version 20231227-0
* Version 20240107-0
* For macOS (Apple Silicon) and Linux

## Contributing
Expand Down Expand Up @@ -53,14 +53,14 @@ airspy-fmradion -m am -t airspyhf -q \
- [RTL-SDR library](http://sdr.osmocom.org/trac/wiki/rtl-sdr)
- [sndfile](https://github.com/erikd/libsndfile)
- [r8brain-free-src](https://github.com/avaneev/r8brain-free-src), a sample rate converter designed by Aleksey Vaneev of Voxengo
- [readerwriterqueue](https://github.com/cameron314/readerwriterqueue)
- [VOLK](https://www.libvolk.org/)
- [PortAudio](http://www.portaudio.com)
- [jj1bdx's fork of cmake-git-version-tracking](https://github.com/jj1bdx/cmake-git-version-tracking)
- Tested: Airspy R2, Airspy Mini, Airspy HF+ Dual Port, RTL-SDR V3
- Fast computer
- Medium-to-strong radio signals

For the latest version, see https://github.com/jj1bdx/airspy-fmradion
For the latest version, see <https://github.com/jj1bdx/airspy-fmradion>

### Recommended utilities

Expand All @@ -72,7 +72,6 @@ For the latest version, see https://github.com/jj1bdx/airspy-fmradion
- _main_ is the "production" branch with the most stable release (often ahead of the latest release though)
- _dev_ is the development branch that contains current developments that will be eventually released in the main branch
- Other branches are experimental (and presumably abandoned)
- The `master` branch is deprecated and to be deleted. Use _main_ branch.

## Prerequisites

Expand Down Expand Up @@ -136,7 +135,7 @@ Use the latest HEAD version.

#### git submodules

r8brain-free-src and readerwriterqueue are the submodules of this repository. Download the submodule repositories by the following git procedure:
r8brain-free-src is the submodule of this repository. Download the submodule repositories by the following git procedure:

- `git submodule update --init --recursive`

Expand All @@ -147,7 +146,7 @@ r8brain-free-src and readerwriterqueue are the submodules of this repository. Do
```shell
/bin/rm -rf build
git submodule update --init --recursive
cmake -S . -B build # -DCMAKE_EXPORT_COMPILE_COMMANDS=ON (if needed)
cmake -S . -B build
cmake --build build --target all
```

Expand Down Expand Up @@ -175,14 +174,20 @@ cmake .. \
PKG_CONFIG_PATH=/path/to/airspy/lib/pkgconfig cmake ..
```

For using static analyzers such as [OCLint](https://oclint.org) and [Clangd](https://clangd.llvm.org), run the following commands:
### Static analysis of the code

For using static analyzers such as [OCLint](https://oclint.org) and [Clangd](https://clangd.llvm.org), use the `compile_commands.json` file built in `build/` directory, with the following commands:

```
cd build
ln -s `pwd`/compile_commands.json ..
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
```

The following limitation is applicable:

* For *CMake 3.20 or later*, cmake-git-version-tracking code is intentionally removed from the compile command database. This is not applicable for the older CMake.
* Use [compdb](https://github.com/Sarcasm/compdb.git) for a more precise analysis including all the header files, with the following command: `compdb -p build/ list > compile_commands.json`

### Compile and install

- `make -j4` (for machines with 4 CPUs)
Expand Down Expand Up @@ -454,13 +459,11 @@ install -o user -m 0700 -c -s build/airspy-fmradion $(HOME)/bin
* [Takeru Ohta](https://github.com/sile), for his [Rust implementation](https://github.com/sile/dagc) of [Tisserand-Berviller AGC algorithm](https://hal.univ-lorraine.fr/hal-01397371/document)
* [Cameron Desrochers](https://github.com/cameron314), for his [readerwriterqueue](https://github.com/cameron314/readerwriterqueue) implementation of a single-producer-single-consumer lock-free queue for C++
* [Clayton Smith](https://github.com/argilo), for [a bugfix pull request to airspy-fmradion to find an uninitialized variable](https://github.com/jj1bdx/airspy-fmradion/pull/43) and his help during [bug tracking in VOLK](https://github.com/gnuradio/volk/pull/695).
* [Andrew Hardin](https://github.com/andrew-hardin), for [cmake-git-version-tracking](https://github.com/andrew-hardin/cmake-git-version-tracking.git)

## License

* As a whole package: GPLv3 (and later). See [LICENSE](LICENSE).
* [csdr](https://github.com/simonyiszk/csdr) AGC code: BSD license.
* Some source code files are stating GPL "v2 and later" license.

## Repository history
* Some source code files are stating GPL "v2 and later" license, and the MIT License.

* This repository is forked from [ngsoftfm-jj1bdx](https://github.com/jj1bdx/ngsoftfm-jj1bdx) 0.1.14 and merged with [airspfhf-fmradion](https://github.com/jj1bdx/airspyhf-fmradion).
46 changes: 46 additions & 0 deletions doc/txt-ngsoftfm-jj1bdx/sincfilter3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
# Curve-fitting calculation script for sinc compensation

import math
import csv

def aperture(x):
if x == 0.0:
return 1.0
else:
return 2.0 / x * math.sin(x/2.0)

def mov1(x):
y = math.sin(x/4.0);
if y == 0.0:
return 0.0
else:
return 0.5 * math.sin(x/2.0) / math.sin (x/4.0)

# filter model:
# mov1: moving-average filter (stage number: 1)
# mov1[n] = (input[n-1] + input[n]) / 2.0
# final output: gain-controlled sum of the above two filters
# output[n] = staticgain * input[n] - fitfactor * mov1[n]

maxfreq = 192000
staticgain = 1.47112063
fitfactor = 0.48567701

with open('sincfilter3.csv', mode='w') as output_file:
fieldnames = ['freq', 'compensate', 'fitlevel', 'logratio']
output_writer = csv.DictWriter(output_file, fieldnames=fieldnames)

output_writer.writeheader()

for freq in range(50,53100,1000):
theta = 2 * math.pi * freq / maxfreq;
compensate = 1.0 / aperture(theta)
fitlevel = staticgain - (fitfactor * mov1(2 * theta))
logratio = math.log10(compensate / fitlevel)
output_writer.writerow({
'freq': freq,
'compensate': compensate,
'fitlevel': fitlevel,
'logratio': logratio
})
1 change: 1 addition & 0 deletions include/AirspyHFSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "libairspyhf/airspyhf.h"
#include <cstdint>
#include <string>
#include <thread>
#include <vector>

#include "Source.h"
Expand Down
1 change: 1 addition & 0 deletions include/AirspySource.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "libairspy/airspy.h"
#include <cstdint>
#include <string>
#include <thread>
#include <vector>

#include "Source.h"
Expand Down
2 changes: 0 additions & 2 deletions include/AmDecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
#define INCLUDE_AMDECODE_H

#include "AfSimpleAgc.h"
#include "AudioResampler.h"
#include "Filter.h"
#include "FilterParameters.h"
#include "FineTuner.h"
#include "FourthConverterIQ.h"
#include "IfResampler.h"
#include "IfSimpleAgc.h"
#include "SoftFM.h"
Expand Down
1 change: 0 additions & 1 deletion include/AudioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#ifndef INCLUDE_AUDIOOUTPUT_H
#define INCLUDE_AUDIOOUTPUT_H

#include <cstdio>
#include <string>

#include "SoftFM.h"
Expand Down
1 change: 0 additions & 1 deletion include/MovingAverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#ifndef INCLUDE_MOVINGAVERAGE_H
#define INCLUDE_MOVINGAVERAGE_H

#include <stdint.h>
#include <vector>

template <class Type> class MovingAverage {
Expand Down
3 changes: 0 additions & 3 deletions include/NbfmDecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
#ifndef INCLUDE_NBFMDECODE_H
#define INCLUDE_NBFMDECODE_H

#include <cstdint>

#include "AudioResampler.h"
#include "Filter.h"
#include "FilterParameters.h"
#include "IfSimpleAgc.h"
Expand Down
5 changes: 0 additions & 5 deletions include/PilotPhaseLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
#ifndef INCLUDE_PILOTPHASELOCK_H
#define INCLUDE_PILOTPHASELOCK_H

#include "AudioResampler.h"
#include "Filter.h"
#include "FilterParameters.h"
#include "IfSimpleAgc.h"
#include "MultipathFilter.h"
#include "PhaseDiscriminator.h"
#include "SoftFM.h"

// Phase-locked loop for stereo pilot.
Expand Down
2 changes: 1 addition & 1 deletion include/RtlSdrSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class RtlSdrSource : public Source {
public:
static constexpr int default_block_length = 65536;
static constexpr int default_block_length = 16384;

/** Open RTL-SDR device. */
RtlSdrSource(int dev_index);
Expand Down
2 changes: 1 addition & 1 deletion include/SoftFM.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ enum class OutputMode {
WAV_FLOAT32,
PORTAUDIO
};
enum class PilotState { NotDetected, Detected, Stabilized };
enum class PilotState { NotDetected, Detected };

#endif
1 change: 0 additions & 1 deletion include/Source.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#define INCLUDE_SOURCE_H

#include <atomic>
#include <memory>
#include <string>

#include "DataBuffer.h"
Expand Down
Loading