sudo apt install portaudio19-dev python3-evdev python3-mido python3-rtmidi
It will detect pitches and generate audio.
To run on boot,
/etc/systemd/system/pitch-detect.service should have:
[Unit] Description=Pitch Detection and Synthesis [Service] ExecStart=/home/pi/pitch-detect/zeros-linux /home/pi/pitch-detect/device-index /home/pi/pitch-detect/current-voice Restart=always KillSignal=SIGQUIT Type=simple [Install] WantedBy=multi-user.target
To support changing voices while headless,
/etc/systemd/system/pitch-detect-kbd.service should have:
[Unit] Description=Keyboard Control for Pitch Synthesis [Service] ExecStart=/usr/bin/python3 /home/pi/pitch-detect/kbd.py /home/pi/pitch-detect/device-index /home/pi/pitch-detect/current-voice Restart=always KillSignal=SIGQUIT Type=simple [Install] WantedBy=multi-user.target
sudo systemctl enable pitch-detect,
sudo systemctl enable pitch-detect-kbd and
sudo systemctl daemon-reload.
Put on headphones, use a directional mic, or otherwise avoid letting the output of this program mix with the input.
Run it and whistle:
It will generate audio.
Keys 0-8 on the keypad should select voices. Voices 0 through 6 expect whistling; 7 and 8 singing.
Works best with a directional microphone with a windscreen (vocal mics like the E835 or SM58 have one built in).
I use a Sennheiser E835 with an xlr to 3.5mm adapter into a USB sound card. This isn't how the microphone is designed to be used (it wants a pre-amp) but it works well enough and it's nice not to have another piece of hardware.
You want to be as close to the microphone as you can bear.
Raspberry PI Setup
- Install Raspberry Pi Os Lite (we don't want the desktop environment)
sudo apt-get update && sudo apt-get upgrade
- "Interface Options"
- "Enable SSH"
- "Localisation Options"
- "WLAN Country"
- "System Options"
- "Wireless LAN"
- "Interface Options"
- Add regular public key to
- Change default password (
sudo apt install git emacs
- select sound card "USB Audio Device"
- Set Speaker and Mic to 83% volume
I'm no longer updating the mac-specific code, though it is still in the repo
$ wget http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz $ tar -xvzf pa_stable_v190600_20161030.tgz $ cd portaudio $ ./configure --disable-mac-universal $ make $ sudo make install
It will make a virtual MIDI source (
whistle-pitch), which you can then pipe
into a synthesizer.
There's also a version with its own built-in bass synthesizer, which is a plug-in version for a DAW (like Reaper):
To use with OSC
cd liblo-0.30/ ./configure make sudo make install