Imitating Nature Ep.1 – The Cuckoo (sound synthesis)

This is the first post about “artisanal” sound synthesis techniques that can be used to imitate (try-to imitate 😉 ) the wonderful sounds of nature. I tried to replicate the chirping of cuckoos that in this period can be heard near my house (North Italy).

I started with a raw and noisy recording of one of them, made with the nice Tascam DR-40 recorder:

Note that the cuckoo is far away and it is barely audible in the recording.

I ampified the wav file using the free (and powerful) tool Audacity: CTRL+A to select all the sound; Effect→ Amplify , set new peak to -3dB. Then the cuckoo is audible (five chirps), though there are another bird chirping, a dog is barking and there are some noises from the road:

First we notice that each chirp is a sequence of two different tones, the second has a lower frequency.

Zooming on each chirp, we can select each tone and using the Analyze→Plot Spectrum tool retrive the exact frequency of the two tones: the first is around 712 Hz, the second is around 573 Hz.

First tone

Second tone

Then we examine the waveform of each tone; with good approximation they seem sine waves:

Finally, in order to  examine the amplitude variation, we apply a sharp Band-Pass filter on 712 Hz and 573 Hz: first apply a Low-Pass filter then a High-Pass filter with a 24db attenuation per octave.

We note that:

  • the shape of the two tones is similar
  • the amplitude of the first tone is slightly greater
  • the duration of the first tone is around 0.12 sec
  • the duration of the second tone is around 0.22 sec

Finally using the audacity selection tool (which can display the length in seconds of the selected area) we measure the time between two chirps and between the two tones of a chirp:

  • time between two chirps → between 0.8 and 1.1 sec
  • time between tones → around 0.12 sec

We can now try to simulate the cuckoo recreating the waveform of its chirp. I used Processing with the standard Sound library and the two object SinOsc (Sine Wave Oscillator) and Env (Envelope generator).

The code is very simple and it simulates a cuckoo flying around and chirping. The parameters used for the simulation are set at the beginning, and the program slightly change their values randomly. The standard Processing sound library is very limited, so we must approximate the amplitude curve using a simple ASD (Attack Sustain Decay) envelope with straight slopes. Furthermore there is no control over the ending of the envelope, so at the beginning of each chirp (tone 1) we must schedule both the execution time for tone 2 and the execution time for the next chirp in the sequence.

This is the final wav:

Source code: the Processing 3 source code can be downloaded here (I also included a funny environment and a bionic-cuckoo image):

I also recorded the whole animation (adding a real soundscape with other birds):

Further improvements: there are several possible improvements, for example:

  • use a more powerful Processing sound library (e.g. minim) and refine the shape of the amplitude envelope;
  • use a better recording and analyze if there are frequency variations during each tone.

1 thought on “Imitating Nature Ep.1 – The Cuckoo (sound synthesis)

  1. Hey. I like what you’re doing here. I’ve got a similar project I’m working on that I think you might like but I would rather not post it as a comment. Shoot me an email if you are interested.

Leave a Reply

Your email address will not be published. Required fields are marked *