Skip to content

kpe/zerotune

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zeroTune - a pi zero turer

Could run on a Pi Zero W with a ReSpeaker 2-Mics Pi HAT to capture 48kHz 2 channel audio and process it with the McLeod's WSNAC pitch detection algorithm, thus implementing a low latency tuner and intonation monitor.

N.B. it should run on your Linux too.

How it works

Tha audio samples are captured using ALSA and than processed with the SNAC algorithm in a tiny C backend.

Using the rawrtc implementation of the WebRTC DataChannel, the pitch data could then be sent to a web application for visualization.

The WSNAC implementation uses currently multiple FFTs of size 2048 for processing an audio frame captured every 1024/48kHz seconds. Using the kiss_fft on the Zero Pi needs less than 40% CPU, and with GPU_FFT it comes down to 18% CPU.

How to run it

First make sure you have CMake 3.2+ and the ALSA dev libs:

sudo apt-get install cmake libasound2-dev

To build and install (locally with a prefix under ./bulid/prefix):

export PKG_CONFIG_PATH=${PWD}/build/prefix/lib/pkgconfig
cd build
cmake -DCMAKE_INSTALL_PREFIX=${PWD}/prefix ..
make install

N.B. You might want to

sudo apt-get install libssl-dev

before doing ./make-dependencies.sh on the Zero Pi, as compliling openssl from sources would take quite some time.

To check if it works:

export LD_LIBRARY_PATH=${PWD}/prefix/lib/:${LD_LIBRARY_PATH}
./build/prefix/bin/zerotune-test hw:1,0

N.B. When using GPU_FFT you might have to run it with sudo.

References

Raspberry Pi Zero W

ReSpeaker 2-Mics Pi HAT

McLeod, Philip - Fast, Accurate Pitch Detection Tools for Music Analysis, 2008.

Kiss FFT

Accelerating Fourier Transforms using the GPU

hello_fft at RaspberryPi Firmware.