Skip to content

Commit

Permalink
Maintainability & housekeeping
Browse files Browse the repository at this point in the history
* use meson for finding deps & building
* remove unmaintained macro-based build options
  * liquid-dsp and sndfile are now actual dependencies
* add .clang-format
* add build check pipeline
  • Loading branch information
windytan committed Jul 12, 2024
1 parent 675d354 commit 2ecb9ee
Show file tree
Hide file tree
Showing 17 changed files with 572 additions and 700 deletions.
18 changes: 18 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
BasedOnStyle: Google
IndentWidth: 2
---
Language: Cpp
Standard: c++14
ColumnLimit: 100
AllowShortIfStatementsOnASingleLine: false
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: Consecutive
AllowShortFunctionsOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AlignConsecutiveDeclarations:
Enabled: true
IncludeBlocks: Preserve
86 changes: 86 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: build

on:
push:
branches: [ master, dev ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]

jobs:
build-ubuntu-22-04:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- name: Install dependencies (apt)
run: sudo apt install python3-pip ninja-build libsndfile1-dev libliquid-dev
- name: Install meson (pip3)
run: pip3 install --user meson
- name: Compile via makefile
run: make
- name: meson setup
run: meson setup -Dwerror=true build
- name: meson compile
run: cd build && meson compile

build-ubuntu-20-04:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4
- name: Install dependencies (apt)
run: sudo apt install python3-pip ninja-build libsndfile1-dev libliquid-dev
- name: Install meson (pip3)
run: pip3 install --user meson
- name: Compile via makefile
run: make
- name: meson setup
run: meson setup -Dwerror=true build
- name: meson compile
run: cd build && meson compile

build-debian-oldoldstable:
runs-on: ubuntu-latest
container: debian:buster

steps:
- uses: actions/checkout@v4
- name: Install dependencies (apt-get)
run: apt-get update && apt-get -y install python3-pip ninja-build build-essential libsndfile1-dev libliquid-dev
- name: Install meson (pip3)
run: pip3 install --user meson
- name: Compile via makefile
run: make
- name: meson setup
run: export PATH=$PATH:$HOME/.local/bin && meson setup -Dwerror=true build
- name: meson compile
run: export PATH=$PATH:$HOME/.local/bin && cd build && meson compile

build-macos:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- name: Install dependencies (brew)
run: brew install meson libsndfile liquid-dsp
- name: Compile via makefile
run: make
- name: meson setup
run: meson setup -Dwerror=true build
- name: meson compile
run: cd build && meson compile

test:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- name: Install dependencies (apt)
run: sudo apt install meson libsndfile1-dev libliquid-dev perl sox
- name: meson setup
run: meson setup -Dwerror=true build
- name: meson compile
run: cd build && meson compile
- name: test
run: cd test && perl test.pl
14 changes: 13 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# deinvert changelog

## 1.0 (2024)

* Maintenance release; no new features
* Long-term maintainability:
* Add basic end-to-end tests, .clang-format, and build check pipelines
* Use meson (instead of autotools - which stopped working for me) to find deps & build
* Remove unmaintained macro-based build options
* liquid-dsp and sndfile are now actual dependencies
* Fixes:
* Default-initialize buffers
* Documentation:
* There is a [wiki](https://github.com/windytan/deinvert/wiki) and more (in-)security reminders

## 0.3 (2018-05-31)

* Reduce artifacts from DC removal filter at startup
Expand All @@ -8,4 +21,3 @@
## 0.2 (2018-01-03)

* Add DC removal filter to fix 'beeping' issues

2 changes: 0 additions & 2 deletions Makefile.am

This file was deleted.

52 changes: 23 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ instructions and examples.

## Prerequisites

By default, deinvert requires liquid-dsp, libsndfile, and GNU autotools. On
Ubuntu, these can be installed like so:
deinvert requires liquid-dsp, libsndfile, and meson.

sudo apt install libsndfile1-dev libliquid-dev automake
On Ubuntu, these can be installed like so:

sudo apt install libsndfile1-dev libliquid-dev meson

On older Debians:

sudo apt-get install python3-pip ninja-build build-essential libsndfile1-dev libliquid-dev
pip3 install --user meson
sudo ldconfig

On macOS I recommend using [homebrew](https://brew.sh/):

xcode-select --install
brew install libsndfile liquid-dsp automake

But deinvert can be compiled without liquid-dsp using the configure
option `--without-liquid`; filtering will be disabled and the result will not
sound as good. It can also be compiled
without libsndfile using the configure option `--without-sndfile`; WAV
support will be disabled, only raw input/output will work.
brew install libsndfile liquid-dsp meson

## Compiling

./autogen.sh
./configure [--without-liquid] [--without-sndfile]
make
meson setup build
cd build
meson compile

## Usage

Expand All @@ -47,19 +47,19 @@ and outputs in the same format via stdout. The inversion carrier defaults to

(De)scrambling a WAV file with setting 4:

./src/deinvert -i input.wav -o output.wav -p 4
./build/deinvert -i input.wav -o output.wav -p 4

### Split-band inversion

(De)scrambling split-band inversion with a bandwidth of 3500 Hz, split at 1200 Hz:

./src/deinvert -i input.wav -o output.wav -f 3500 -s 1200
./build/deinvert -i input.wav -o output.wav -f 3500 -s 1200

### Invert a live signal from RTL-SDR

Descrambling a live FM channel at 27 Megahertz from an RTL-SDR, setting 4:

rtl_fm -M fm -f 27.0M -s 12k -g 50 -l 70 | ./src/deinvert -r 12000 -p 4 |\
rtl_fm -M fm -f 27.0M -s 12k -g 50 -l 70 | ./build/deinvert -r 12000 -p 4 |\
play -r 12k -c 1 -t .s16 -

### Invert a live signal from Gqrx (requires netcat)
Expand All @@ -70,12 +70,12 @@ Descrambling a live FM channel at 27 Megahertz from an RTL-SDR, setting 4:
4. In the Audio window, enable UDP.
5. Run this command in a terminal window:

nc -u -l localhost 12345 | ./src/deinvert -r 48000 | play -r 48k -c 1 -t .s16 -
nc -u -l localhost 12345 | ./build/deinvert -r 48000 | play -r 48k -c 1 -t .s16 -


### Full options

./src/deinvert [OPTIONS]
./build/deinvert [OPTIONS]

-f, --frequency FREQ Frequency of the inversion carrier, in Hertz.

Expand All @@ -86,6 +86,7 @@ Descrambling a live FM channel at 27 Megahertz from an RTL-SDR, setting 4:

-o, --output-file FILE Write output to a WAV file instead of stdout. An
existing file will be overwritten.
The input sample rate will be used.

-p, --preset NUM Scrambler frequency preset (1-8), referring to
the set of common carrier frequencies used by
Expand Down Expand Up @@ -116,18 +117,11 @@ Descrambling a live FM channel at 27 Megahertz from an RTL-SDR, setting 4:

## Troubleshooting

### Can't find liquid-dsp on macOS

If you've installed liquid-dsp yet `configure` can't find it, it's possible that
XCode command line tools aren't installed. Run this command to fix it:
### I can't understand the speech even after deinverting

xcode-select --install

### Can't find liquid-dsp on Linux

Try running this in the terminal:

sudo ldconfig
In this case, the sample is probably not frequency inversion scrambled.
It's very rare to encounter frequency inversion scrambling nowadays. See the
[wiki](https://github.com/windytan/deinvert/wiki) for details.

### I hear a high-pitched beep in the result

Expand Down
2 changes: 0 additions & 2 deletions autogen.sh

This file was deleted.

51 changes: 0 additions & 51 deletions configure.ac

This file was deleted.

65 changes: 65 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
project(
'deinvert',
'cpp',
default_options: ['warning_level=3', 'buildtype=release', 'optimization=3'],
version: '1.0',
)

# Store version number to be compiled in
conf = configuration_data()
conf.set_quoted('VERSION', meson.project_version())
configure_file(output: 'config.h', configuration: conf)

########################
### Compiler options ###
########################

cc = meson.get_compiler('cpp')
add_project_arguments(cc.get_supported_arguments(['-Wno-unknown-pragmas']), language: 'cpp')

# We want to use M_PI on Windows
if build_machine.system() == 'windows'
add_project_arguments('-D_USE_MATH_DEFINES=1', language: 'cpp')
endif

# Explicit GNU extensions on Cygwin
if build_machine.system() == 'cygwin'
add_project_arguments('-std=gnu++14', language: 'cpp')
else
add_project_arguments('-std=c++14', language: 'cpp')
endif

####################
### Dependencies ###
####################

# Find libsndfile
sndfile = dependency('sndfile')

# Find liquid-dsp
if build_machine.system() == 'darwin'
fs = import('fs')
# Homebrew system
if fs.is_dir('/opt/homebrew/lib')
liquid_lib = cc.find_library('liquid', dirs: ['/opt/homebrew/lib'])
liquid_inc = include_directories('/opt/homebrew/include')
# MacPorts system
else
liquid_lib = cc.find_library('liquid', dirs: ['/opt/local/lib'])
liquid_inc = include_directories('/opt/local/include')
endif
liquid = declare_dependency(dependencies: liquid_lib, include_directories: liquid_inc)
else
liquid = cc.find_library('liquid')
endif

############################
### Sources & Executable ###
############################

sources = [
'src/deinvert.cc',
'src/liquid_wrappers.cc',
]

executable('deinvert', sources, dependencies: [liquid, sndfile], install: true)
6 changes: 0 additions & 6 deletions src/Makefile.am

This file was deleted.

Loading

0 comments on commit 2ecb9ee

Please sign in to comment.