(Last updated October 2019)
As the Cirrus Logic Audio Card is no longer available, options for recording ultrasound with the Raspberry Pi are unfortunately limited. There is a relatively new sound card available which is specifically designed to record ultrasound with a maximum sample rate of 192kHz: Audio Injector Ultra 2 from Flatmax Studios.
Instructions for setting up this card for use with a Raspberry Pi can be found here.
The card defaults to line input, so a simple bash script is needed to set up recording from the on-board microphones (Knowles SPU0410LR5H Ultrasonic MEMS microphones).
amixer cset name='ADC Mux' 0 amixer cset name='PGA Volume' 40 amixer cset name='ADC HPF Switch' 0 amixer cset name='ADC Soft Ramp Switch' 0 amixer cset name='Loopback Switch' 1
This can be saved as a bash script (e.g. record_from_mic.sh) and set to run at startup by adding the following line to /etc/rc.local just before exit zero (instructions on how to do this are here).
sh /home/pi/record_from_mic.sh &
Here’s the Ultra 2 Sound Card attached to a Raspberry Pi 3B+. I’m only using the base card that comes with the AudioInjector sound card package, with a separate MEMS ultrasound microphone attached:
SoX can be used for sound-activated recording:
rec -G -c1 -r 192000 -b 16 -V2 /home/pi/temp.wav sinc 10k silence 1 0.01 1% -1 1.0 1% trim 2.0 3.0
These are spectrograms of bat calls from recordings made with the Ultra 2 sound card:
I create a plot of the number of bat calls recorded each night, overlaid onto a map, showing the number of calls in the last 14 nights:
Between sunset and sunrise, the map displays a bar chart:
More details and results with this sound card will be added during 2019.