• Stars
    star
    571
  • Rank 78,127 (Top 2 %)
  • Language
    C++
  • License
    MIT License
  • Created over 9 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

autocorrelation-based O(NlogN) pitch detection

Pitch detection algorithms

Autocorrelation-based C++ pitch detection algorithms with O(nlogn) or lower running time:

*: SWIPE' appears to be O(n) but with an enormous constant factor. The implementation complexity is much higher than MPM and YIN and it brings in additional dependencies (BLAS + LAPACK).

**: There's a parallel version of SWIPE, Aud-SWIPE-P.

Suggested usage of this library can be seen in the utility wav_analyzer, which divides a wav file into chunks of 0.01s and checks the pitch of each chunk. Sample output of wav_analyzer:

At t: 0.5
        mpm: 162.529
        yin: 162.543
        swipe: 162.183
        pmpm: 162.529
        pyin: 162.543

Degraded audio tests

All testing files are here - the progressive degradations are described by the respective numbered JSON file, generated using audio-degradation-toolbox. The original clip is a Viola playing E3 from the University of Iowa MIS.

The results come from parsing the output of wav_analyzer to count how many 0.1s slices of the input clip were in the ballpark of the expected value of 164.81 - I considered anything 160-169 to be acceptable:

Degradation level MPM # correct YIN # correct SWIPE' # correct
0 26 22 5
1 23 21 13
2 19 21 9
3 18 19 7
4 19 19 6
5 18 19 5

Build and install

Using this project should be as easy as make && sudo make install on Linux with a modern GCC - I don't officially support other platforms.

This project depends on ffts, BLAS/LAPACK, and mlpack. To run the tests, you need googletest, and run make -C test/ && ./test/test. To run the bench, you need google benchmark, and run make -C test/ bench && ./test/bench.

Build and install pitch_detection, run the tests, and build the sample application, wav_analyzer:

# build libpitch_detection.so
make clean all

# build tests and benches
make -C test clean all

# run tests and benches 
./test/test
./test/bench

# install the library and headers to `/usr/local/lib` and `/usr/local/include`
sudo make install

# build and run C++ sample
make -C wav_analyzer clean all
./wav_analyzer/wav_analyzer

Docker

To simplify the setup, there's a Dockerfile that sets up a Ubuntu container with all the dependencies for compiling the library and running the included tests and benchmarks. You can build the image or pull it from DockerHub (esimkowitz/pitchdetection):

# build
$ docker build --rm --pull -f "Dockerfile" -t pitchdetection:latest "."
$ docker run --rm --init -it pitchdetection:latest

# pull
$ docker pull esimkowitz/pitchdetection:latest
$ docker run --rm --init -it esimkowitz/pitchdetection:latest

Once you're in the container, run the tests and benches:

./test/test
./test/bench

Usage

Read the header and sample wav_analyzer.

The namespaces are pitch and pitch_alloc. The functions and classes are templated for <double> and <float> support.

The pitch namespace functions perform automatic buffer allocation, while pitch_alloc::{Yin, Mpm} give you a reusable object (useful for computing pitch for multiple uniformly-sized buffers):

#include <pitch_detection.h>

std::vector<double> audio_buffer(8192);

double pitch_yin = pitch::yin<double>(audio_buffer, 48000);
double pitch_mpm = pitch::mpm<double>(audio_buffer, 48000);
double pitch_pyin = pitch::pyin<double>(audio_buffer, 48000);
double pitch_pmpm = pitch::pmpm<double>(audio_buffer, 48000);
double pitch_swipe = pitch::swipe<double>(audio_buffer, 48000);

pitch_alloc::Mpm<double> ma(8192);
pitch_alloc::Yin<double> ya(8192);

for (int i = 0; i < 10000; ++i) {
        auto pitch_yin = ya.pitch(audio_buffer, 48000);
        auto pitch_mpm = ma.pitch(audio_buffer, 48000);
        auto pitch_pyin = ya.probabilistic_pitch(audio_buffer, 48000);
        auto pitch_pmpm = ma.probabilistic_pitch(audio_buffer, 48000);
}

More Repositories

1

freemusicdemixer.com

free website for client-side music demixing with Demucs + WebAssembly
JavaScript
330
star
2

pq

a command-line Protobuf parser with Kafka support and JSON output
Rust
166
star
3

chord-detection

DSP algorithms for chord detection + key estimation
Python
109
star
4

demucs.cpp

C++17 port of Demucs v3 (hybrid) and v4 (hybrid transformer) models with ggml and Eigen3
C++
84
star
5

wireshark-dissector-rs

write wireshark dissectors in Rust via C FFI
Rust
47
star
6

audio-degradation-toolbox

easy-to-use implementation of the ISMIR 2013 Audio Degradation Toolbox
Python
46
star
7

umx.cpp

C++17 port of Open-Unmix-PyTorch with streaming LSTM inference, ggml, quantization, and Eigen
C++
33
star
8

OnAir-Music-Dataset

🎵 a new stem dataset for Music Demixing research, from the OnAir royalty-free music project
33
star
9

goat

AWS EBS-EC2 attach utility. UNMAINTAINED, SEE FORK ->
Go
28
star
10

xumx-sliCQ

music demixing with the sliCQ Transform and PyTorch
Python
26
star
11

Zen

optimized realtime harmonic/percussive source separation using the GPU (NVIDIA CUDA) and CPU (Intel IPP)
Cuda
20
star
12

Real-Time-HPSS

MATLAB + Python implementations of real-time median-filtering Harmonic-Percussive Source Separation
MATLAB
19
star
13

ape

XDP-based packet manipulation tool with Prometheus metrics
C
12
star
14

jitters

RTP jitter buffer implementation written in Rust with example sender and receiver programs
Rust
10
star
15

Music-Separation-TF

Music source separation testbench with various offline and realtime DSP and machine learning algorithms using the STFT, CQT, NSGT, sliCQT, WMDCT, and TFJigsaw
MATLAB
8
star
16

MiXiN

Music Xtraction with Nonstationary Gabor Transforms and Convolutional Denoising Autoencoders
Python
8
star
17

ElectroPARTYogram

⚡ 🎉 native C++ Android beat visualizer with BTrack, Oboe, Ne10, SFML
C++
8
star
18

transcribe

simplistic pitch-detection-based music transcriber
Python
7
star
19

xumx-sliCQ-V2

better music demixing with PyTorch and the sliCQT + interactive live GUI with ONNXRuntime
Python
7
star
20

surge

mpv + youtube-dl command line music player in Rust
Rust
7
star
21

libmetro

create custom metronomes - compound/simple/odd time signatures, polyrhythms, etc.
C++
6
star
22

headbang.py

consensus beat tracking and visualization in mixed metal songs, and headbanging motion analysis with 2D pose estimation
Python
5
star
23

warped-linear-prediction

perceptual audio codec/file format based on WLPC in a FLAC container
Python
4
star
24

music-demixing-challenge-ismir-2021

working repo for my xumx-sliCQ submissions to the ISMIR 2021 MDX
Python
4
star
25

multiband-transient-shaper

Bark frequency filterbank + SPL differential envelope follower transient shaper
MATLAB
4
star
26

Pitcha

the original pitch detection app for Android; see https://github.com/pitch-detection instead
Java
3
star
27

raft-badgerdb

Hashicorp Raft LogStore + StableStore backed by dgraph-io's BadgerDB
Go
3
star
28

quadtree-compression

lossy image compression with quadtrees and protobuf
Go
3
star
29

Scriptorium

OCR reading assistant with opencv, Tesseract, kraken, DAWGs and a splay tree
Python
2
star
30

pitchlite

realtime pitch tracking in WebAssembly with AudioWorklet
C++
2
star
31

go-sort

collection of tested Go integer sort algorithms
Go
2
star
32

sevagh

this is also houses the giscus discussions for sevag.xyz
2
star
33

beamer-presentation

my template for LaTeX/beamer presentations (for both academia and industry)
TeX
1
star
34

drum_machine

create click tracks from harmonixset annotations on the fly with libmetro, libsoundio, and stk
Go
1
star
35

MIR-presentations

grad school presentations on the topic of Music Information Retrieval
TeX
1
star
36

top-bar-clocks

top bar clocks extension in Gnome 3
JavaScript
1
star
37

xnetwork

simple graph library with slotmaps
Rust
1
star
38

xumx_slicq_extra

extra files for xumx-sliCQ
Python
1
star
39

mss-oracle-experiments

music source separation experiments with oracle performance and different spectrograms
Python
1
star