Skip to content

Commit a9f724e

Browse files
authored
Merge pull request #68 from jj1bdx/dev
Version 20240107-0 release
2 parents d340c22 + b0157dd commit a9f724e

23 files changed

+382
-108
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,11 @@ _deps
145145
*-prefix/
146146

147147
# End of https://www.toptal.com/developers/gitignore/api/cmake
148+
149+
# clangd
150+
151+
.cache/
152+
153+
# working directory
154+
155+
build/

CHANGES.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ The following submodule is required:
88

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

11+
## External version control code required
12+
13+
The following Git repository is required:
14+
15+
* [jj1bdx's fork of cmake-git-version-tracking](https://github.com/jj1bdx/cmake-git-version-tracking)
16+
1117
## Platforms tested
1218

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

3137
## Changes (including requirement changes)
3238

39+
* 20240107-0: Made the following changes:
40+
- For broadcasting FM, show stereo 19kHz pilot signal level when detected.
41+
- Remove displaying whether FM stereo pilot signal level is stable or unstable.
42+
- 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).
43+
- Add compile command database support on CMakeLists.txt.
44+
- Cleaned up old documents.
45+
- Fixed the following bugs detected by clang-tidy:
46+
* [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)
47+
- Use `Utility::parse_int()` instead of raw `atoi()`
48+
* [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)
49+
- Remove unused `_FILE_OFFSET_BITS`
50+
- Fixed the bug of FileSource playback: the code did not terminate after the end of playback.
51+
- main.cpp: add checking pull_end_reached() in the main loop.
52+
- Set RtlSdrSource's default_block_length from 65536 to 16384, to prevent popping cracking sound (observed on Mac mini 2023).
53+
- stat_rate calculation is redesigned by observation of actual SDR units (:i.e., Airspy HF+, Airspy R2, and RTL-SDR).
3354
* 20231227-0: Made the following changes:
3455
- Split class PilotPhaseLock from FmDecode.
3556
- Removed submodule readerwriterqueue.

CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
11
# CMake definitions for airspy-fmradion
22

3-
cmake_minimum_required(VERSION 3.0.2)
3+
cmake_minimum_required(VERSION 3.18)
44
project(airspy-fmradion)
55

66
# Workaround for the compilation warning
77
if(COMMAND cmake_policy)
88
cmake_policy(SET CMP0003 NEW)
99
endif(COMMAND cmake_policy)
1010

11+
# Enable compile_commands.json as default
12+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
13+
14+
# Use cmake-git-version-tracking
15+
include(FetchContent)
16+
FetchContent_Declare(cmake_git_version_tracking
17+
GIT_REPOSITORY https://github.com/jj1bdx/cmake-git-version-tracking.git
18+
GIT_TAG 9b5fc5088b4089ff2adc20d607976b9923e3d737
19+
)
20+
FetchContent_MakeAvailable(cmake_git_version_tracking)
21+
# EXPORT_COMPILE_COMMANDS is supported for CMake version 3.20 or later only
22+
if (CMAKE_VERSION VERSION_LESS 3.20.0)
23+
message(STATUS "No EXPORT_COMPILE_COMMANDS available")
24+
message(STATUS "Use compdb for proper compile_commands.json handling")
25+
else()
26+
set_target_properties(cmake_git_version_tracking
27+
PROPERTIES EXPORT_COMPILE_COMMANDS OFF)
28+
endif()
29+
1130
# Use pkg-config
1231
include(FindPkgConfig)
1332

33+
# Find Threads package
1434
find_package(Threads)
1535

1636
# Find Volk library.
@@ -205,6 +225,7 @@ set(sfmbase_HEADERS
205225
include/FineTuner.h
206226
include/FmDecode.h
207227
include/FourthConverterIQ.h
228+
include/git.h
208229
include/IfResampler.h
209230
include/IfSimpleAgc.h
210231
include/MovingAverage.h
@@ -272,6 +293,7 @@ target_link_libraries(airspy-fmradion
272293
${PORTAUDIO_LINK_LIBRARIES}
273294
${VOLK_LIBRARY}
274295
${EXTRA_LIBS}
296+
cmake_git_version_tracking
275297
)
276298

277299
target_link_libraries(sfmbase

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# airspy-fmradion
44

5-
* Version 20231227-0
5+
* Version 20240107-0
66
* For macOS (Apple Silicon) and Linux
77

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

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

6565
### Recommended utilities
6666

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

7776
## Prerequisites
7877

@@ -136,7 +135,7 @@ Use the latest HEAD version.
136135

137136
#### git submodules
138137

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

141140
- `git submodule update --init --recursive`
142141

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

@@ -175,14 +174,20 @@ cmake .. \
175174
PKG_CONFIG_PATH=/path/to/airspy/lib/pkgconfig cmake ..
176175
```
177176

178-
For using static analyzers such as [OCLint](https://oclint.org) and [Clangd](https://clangd.llvm.org), run the following commands:
177+
### Static analysis of the code
178+
179+
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:
179180

180181
```
181182
cd build
182183
ln -s `pwd`/compile_commands.json ..
183-
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
184184
```
185185

186+
The following limitation is applicable:
187+
188+
* 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.
189+
* 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`
190+
186191
### Compile and install
187192

188193
- `make -j4` (for machines with 4 CPUs)
@@ -454,13 +459,11 @@ install -o user -m 0700 -c -s build/airspy-fmradion $(HOME)/bin
454459
* [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)
455460
* [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++
456461
* [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).
462+
* [Andrew Hardin](https://github.com/andrew-hardin), for [cmake-git-version-tracking](https://github.com/andrew-hardin/cmake-git-version-tracking.git)
457463

458464
## License
459465

460466
* As a whole package: GPLv3 (and later). See [LICENSE](LICENSE).
461467
* [csdr](https://github.com/simonyiszk/csdr) AGC code: BSD license.
462-
* Some source code files are stating GPL "v2 and later" license.
463-
464-
## Repository history
468+
* Some source code files are stating GPL "v2 and later" license, and the MIT License.
465469

466-
* 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).
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
# Curve-fitting calculation script for sinc compensation
3+
4+
import math
5+
import csv
6+
7+
def aperture(x):
8+
if x == 0.0:
9+
return 1.0
10+
else:
11+
return 2.0 / x * math.sin(x/2.0)
12+
13+
def mov1(x):
14+
y = math.sin(x/4.0);
15+
if y == 0.0:
16+
return 0.0
17+
else:
18+
return 0.5 * math.sin(x/2.0) / math.sin (x/4.0)
19+
20+
# filter model:
21+
# mov1: moving-average filter (stage number: 1)
22+
# mov1[n] = (input[n-1] + input[n]) / 2.0
23+
# final output: gain-controlled sum of the above two filters
24+
# output[n] = staticgain * input[n] - fitfactor * mov1[n]
25+
26+
maxfreq = 192000
27+
staticgain = 1.47112063
28+
fitfactor = 0.48567701
29+
30+
with open('sincfilter3.csv', mode='w') as output_file:
31+
fieldnames = ['freq', 'compensate', 'fitlevel', 'logratio']
32+
output_writer = csv.DictWriter(output_file, fieldnames=fieldnames)
33+
34+
output_writer.writeheader()
35+
36+
for freq in range(50,53100,1000):
37+
theta = 2 * math.pi * freq / maxfreq;
38+
compensate = 1.0 / aperture(theta)
39+
fitlevel = staticgain - (fitfactor * mov1(2 * theta))
40+
logratio = math.log10(compensate / fitlevel)
41+
output_writer.writerow({
42+
'freq': freq,
43+
'compensate': compensate,
44+
'fitlevel': fitlevel,
45+
'logratio': logratio
46+
})

include/AirspyHFSource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "libairspyhf/airspyhf.h"
2424
#include <cstdint>
2525
#include <string>
26+
#include <thread>
2627
#include <vector>
2728

2829
#include "Source.h"

include/AirspySource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "libairspy/airspy.h"
2424
#include <cstdint>
2525
#include <string>
26+
#include <thread>
2627
#include <vector>
2728

2829
#include "Source.h"

include/AmDecode.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
#define INCLUDE_AMDECODE_H
2222

2323
#include "AfSimpleAgc.h"
24-
#include "AudioResampler.h"
2524
#include "Filter.h"
2625
#include "FilterParameters.h"
2726
#include "FineTuner.h"
28-
#include "FourthConverterIQ.h"
2927
#include "IfResampler.h"
3028
#include "IfSimpleAgc.h"
3129
#include "SoftFM.h"

include/AudioOutput.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#ifndef INCLUDE_AUDIOOUTPUT_H
2121
#define INCLUDE_AUDIOOUTPUT_H
2222

23-
#include <cstdio>
2423
#include <string>
2524

2625
#include "SoftFM.h"

include/MovingAverage.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#ifndef INCLUDE_MOVINGAVERAGE_H
2121
#define INCLUDE_MOVINGAVERAGE_H
2222

23-
#include <stdint.h>
2423
#include <vector>
2524

2625
template <class Type> class MovingAverage {

0 commit comments

Comments
 (0)