Raspberry Pi Bat Detector

...and how to do so...
User avatar
kryptonaut
KVRian
738 posts since 25 Apr, 2011

Post Thu Sep 26, 2019 12:04 am

This is not really a music project, but it is an audio gadget.

I built a real-time pitch-shifting time-stretching device, using a Raspberry Pi Zero running in 'bare metal' mode (i.e. without any operating system). It's basically a kind of granulator which slows down incoming audio by up to 4 octaves, but works in approximately real-time by overlapping the slowed down sounds as necessary.

Image

I originally designed it for listening to slowed down birdsong, but the mics I used are responsive up to 100KHz so it's turned out to be a rather effective bat detector - it's very cool to hear them chirping as they fly overhead at dusk.

I recorded the output of a session, trimmed out the silences and tidied it up a bit: Pipistrelle bats audio

There is more info on the project here.

User avatar
whyterabbyt
Beware the Quoth
27685 posts since 4 Sep, 2001 from R'lyeh Oceanic Amusement Park and Funfair

Re: Raspberry Pi Bat Detector

Post Thu Sep 26, 2019 2:20 am

What did you use for the high-frequency audio capture?
"The bearer of this signature is a genuine and authorised pope."

User avatar
kryptonaut
KVRian
738 posts since 25 Apr, 2011

Re: Raspberry Pi Bat Detector

Post Thu Sep 26, 2019 3:39 am

The microphone is a PDM device that emits a stream of 1's and 0's that encode the acoustic pressure - the more 1's in a given interval, the higher the pressure. It's clocked at nearly 5 MHz, so it's quite capable of encoding 100KHz audio. You have to do some noise-shaping/filtering on the stream to reconstruct an audio signal, particularly if you're interested in the higher frequencies, but the processor on the Pi has a built-in 'peripheral' that does some of that for you - I did the rest of the job, and stored/added the signal into a circular buffer.

It's working the processor pretty much flat out, I had to cut a few corners to get it to produce an acceptable sound quality, but in the end I was pretty happy with the result.

User avatar
GaryG
KVRAF
5805 posts since 13 Jan, 2003 from Kent, UK

Re: Raspberry Pi Bat Detector

Post Thu Sep 26, 2019 4:57 am

Nice work, fascinating sounds.
()_()
(O.o)
(")(")

User avatar
CrystalWizard
KVRian
881 posts since 10 Jul, 2008 from Orbit Sol III

Re: Raspberry Pi Bat Detector

Post Thu Sep 26, 2019 5:04 am

Good work
gadgets an gizmos...make noise
https://soundcloud.com/crystalawareness

User avatar
vurt
addled muppet weed
53398 posts since 26 Jan, 2003 from through the looking glass

Re: Raspberry Pi Bat Detector

Post Thu Sep 26, 2019 5:29 am

cool.
pipistrelle are cute little critters too.

kvotchin
KVRist
220 posts since 9 Aug, 2018

Re: Raspberry Pi Bat Detector

Post Thu Sep 26, 2019 9:09 am

Love it. Very cool idea.

fairlyclose
KVRist
131 posts since 4 Jul, 2019

Re: Raspberry Pi Bat Detector

Post Wed Nov 06, 2019 12:53 pm

excellent quality sound

SparkySpark
KVRAF
1674 posts since 30 Aug, 2004 from Lancaster, UK

Re: Raspberry Pi Bat Detector

Post Wed Nov 06, 2019 3:51 pm

This is amazing work! Not just tech-wise but also the end result per se. I read in EM back in the days that with a mic that goes up to 60 kHz, you can record insects on/under tree bark. When down-pitched, the sound is supposed to be very cool. (If you try it and it works, then please upload the track, because I have always wanted to know what it sounds like.)

Hmmmm.... just came to think of that we have six or seven unopened boxes of Pis in the office. Hmmmmm...... :wink:
Making music is a nine-to-five job:
From 9 PM to 5 AM.
Go MuLab!

User avatar
kryptonaut
KVRian
738 posts since 25 Apr, 2011

Re: Raspberry Pi Bat Detector

Post Fri Nov 08, 2019 12:47 am

Thanks - the audio file was tidied up a bit, but it pretty much reflects what you hear live. I'll have to try listening to tree bark some time, sounds intriguing!

If you have Pis floating around, have a go - but watch out, it's addictive! I've recently discovered the 'circle' bare-metal environment, which is really very good - it makes things much easier.

SparkySpark
KVRAF
1674 posts since 30 Aug, 2004 from Lancaster, UK

Re: Raspberry Pi Bat Detector

Post Fri Nov 08, 2019 2:52 pm

kryptonaut wrote: ↑
Fri Nov 08, 2019 12:47 am
Thanks - the audio file was tidied up a bit, but it pretty much reflects what you hear live. I'll have to try listening to tree bark some time, sounds intriguing!

If you have Pis floating around, have a go - but watch out, it's addictive! I've recently discovered the 'circle' bare-metal environment, which is really very good - it makes things much easier.
Hi again,

I read the stuff on your web page and also noticed your thoughts on different sounds and communication amongst bats. My brother is a scientist in biology and he asked a colleague about this, in relation to your webpage. Here is the answer (it's a Google translate, so linguistically it's a bit off, but you get the picture):
Yes, bats can have many different sounds, and many of them tend to be species-typical. Each species uses a special sound to orient and find insects, ie. sonar sound. This song has a characteristic rhythm, frequency, etc. Some species alternate between two or more different sonar sounds. Their sonar also varies a bit depending on where and how they fly.

In addition to this, they have a lot of social sounds, the most characteristic of which is usually the male's leprosy when they claim mating revelry. You may have heard gray-skinned bats yourself? It claims mating revelry around the castle and cathedral in Uppsala [Sweden] in October and you can then hear a rhythmic ticking sound without a detector.

The example below [i.e. your MP3 file] with the pipistrell is also a typical social song. Now I do not know what it is for a pipistrell that he has heard, but our usual pipistrell in Sweden, Pipistrellus pymaeus, has a sonar which is at 52 kHz. It also has a species-characteristic swirling sound that can be heard at many different frequencies, down to 20 kHz. In time expansion [i.e. down-pitching] it sounds like a drill.
(Must say Google Translate is actually very good! :o )
Making music is a nine-to-five job:
From 9 PM to 5 AM.
Go MuLab!

User avatar
UltimateOutsider
KVRian
758 posts since 5 Oct, 2009 from Portland, OR

Re: Raspberry Pi Bat Detector

Post Fri Nov 08, 2019 3:09 pm

I love bats and I love this project! Cool!

User avatar
kryptonaut
KVRian
738 posts since 25 Apr, 2011

Re: Raspberry Pi Bat Detector

Post Mon Nov 11, 2019 12:40 am

SparkySpark wrote: ↑
Fri Nov 08, 2019 2:52 pm
I read the stuff on your web page and also noticed your thoughts on different sounds and communication amongst bats. My brother is a scientist in biology and he asked a colleague about this, in relation to your webpage. Here is the answer (it's a Google translate, so linguistically it's a bit off, but you get the picture):
Thank you very much for your interesting post. I haven't been aware of any clicks without using the detector, but I remember as a teenager I used to be able to hear bat calls, presumably pipistrelles, right at the limit of my hearing range. That was around 40 years ago though, and I can no longer hear such things - hence building the detector! :)

SparkySpark
KVRAF
1674 posts since 30 Aug, 2004 from Lancaster, UK

Re: Raspberry Pi Bat Detector

Post Mon Nov 11, 2019 3:46 pm

kryptonaut wrote: ↑
Mon Nov 11, 2019 12:40 am
SparkySpark wrote: ↑
Fri Nov 08, 2019 2:52 pm
I read the stuff on your web page and also noticed your thoughts on different sounds and communication amongst bats. My brother is a scientist in biology and he asked a colleague about this, in relation to your webpage. Here is the answer (it's a Google translate, so linguistically it's a bit off, but you get the picture):
Thank you very much for your interesting post. I haven't been aware of any clicks without using the detector, but I remember as a teenager I used to be able to hear bat calls, presumably pipistrelles, right at the limit of my hearing range. That was around 40 years ago though, and I can no longer hear such things - hence building the detector! :)
:)
You're welcome, it's very interesting actually. I personally wasn't aware bats were communicating with their sounds... but then again, why shouldn't they? Nature is fantastic and I'm glad you get this opportunity to experience it. Let us know if you can hear the insects eating wood!
Making music is a nine-to-five job:
From 9 PM to 5 AM.
Go MuLab!

SparkySpark
KVRAF
1674 posts since 30 Aug, 2004 from Lancaster, UK

Re: Raspberry Pi Bat Detector

Post Mon Nov 11, 2019 3:48 pm

SparkySpark wrote: ↑
Mon Nov 11, 2019 3:46 pm
kryptonaut wrote: ↑
Mon Nov 11, 2019 12:40 am
SparkySpark wrote: ↑
Fri Nov 08, 2019 2:52 pm
I read the stuff on your web page and also noticed your thoughts on different sounds and communication amongst bats. My brother is a scientist in biology and he asked a colleague about this, in relation to your webpage. Here is the answer (it's a Google translate, so linguistically it's a bit off, but you get the picture):
Thank you very much for your interesting post. I haven't been aware of any clicks without using the detector, but I remember as a teenager I used to be able to hear bat calls, presumably pipistrelles, right at the limit of my hearing range. That was around 40 years ago though, and I can no longer hear such things - hence building the detector! :)
:)
You're welcome, it's very interesting actually. I personally wasn't aware bats were communicating with their sounds... but then again, why shouldn't they? I too grew up in Uppsala and remember hearing the bats by the river. Haven't heard them for a while, now that you mention it. Must be because of the --> :phones: :wink:

Anyway, nature is fantastic and I'm glad you get this opportunity to experience it. Let us know if you can hear the insects eating wood!
Making music is a nine-to-five job:
From 9 PM to 5 AM.
Go MuLab!

Return to β€œDIY: Build it and they will come”