Skip to content

Commit

Permalink
Merge pull request #68 from jj1bdx/dev
Browse files Browse the repository at this point in the history
Version 20240107-0 release
  • Loading branch information
jj1bdx authored Jan 7, 2024
2 parents d340c22 + b0157dd commit a9f724e
Show file tree
Hide file tree
Showing 23 changed files with 382 additions and 108 deletions.
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

0 comments on commit a9f724e

Please sign in to comment.