# Central Pattern Generators to Synthesize Birdsongs

Songbirds are among the most interesting creatures of nature. Out of 10,000 bird species, around 4,000 are songbirds. They sing for many reasons including territorial ownership and mating. The young birds learn their songs by listening to a tutor. This makes it an attractive research area for those who are interested in understanding how humans learn to speak.

The study of dynamical systems has proven to be an invaluable tool for understanding how songbirds sing. A very simple nonlinear oscillator model that is similar to a spring-mass system can shed a light onto the physics of the avian vocal organ, the syrinx. The neuronal control mechanisms that generate the songs can be modeled as a central pattern generator, which is a special kind of connectionist model. Furthermore, dynamic variation of the system parameters via temporal hierarchy gives rise to highly precise modeling of birdsongs.

This article briefly explains one such dynamical systems model from the literature  and provides a Matlab implementation that generates a synthetic version of the white-crowned sparrow song.

Structure of a Birdsong

A birdsong is a hierarchical structure consisting of syllables and motifs such as the following Chingolo song:

Here is how this waveform plot is generated in Matlab:

`[y,fs] = wavread('e:\\recordedbird.wav');t=[1/fs:1/fs:length(y)/fs];plot(t,y)`

And here is how the Chingolo’s song sounds like:

What is in a Syllable?
A syllable can contain multiple dynamic tones with up sweeps and down sweeps. The frequency range in a typical birdsong is generally between 2–7Khz . The richness in dynamics makes this an interesting topic for dynamic systems modeling. The following sonogram/spectogram shows how the frequency changes within syllables:

Songbird Anatomy
So, how do birds generate songs? The following figure shows the vocal organs of a songbird.

Located between the lungs and the vocal tract, the syrinx is the sound-producing organ (source) of a songbird. Similar to the larynx in humans, the syrinx contains vibrating membranes that are called labia which oscillate when the air from lungs exerts force on them. The sound waves generated by the syrinx then travel through the vocal tract which serves as the filtering mechanism for producing the vocalizations .

What controls the singing is the songbird’s brain. Two distinct forebrain regions were identified as being highly active during birdsong generation. The HVC (high vocal center) projects to the region RA (robust nucleus of the archistriatum) which in turn projects to the brainstem regions that control the syrinx and the respiratory systems.

Based on the observations of the songbird brain activity during singing, it has been proposed that there is a temporal hierarchical organization that controls the bird-song generation. Namely, the HVC neurons were observed to be on a slower timescale than the RA neurons .

The final piece of the puzzle is the control of the muscles that actually govern the syrinx. It was proposed that there were 7 muscles controlling the vocal organs, however this meant a 7-dimensional problem for mathematical modeling of song generation. Through experiments, it was deduced that song generation in songbirds could be mathematically modeled with respect to two variables: the stiffness of the labia (the portion of the syrinx that oscillates) and the air pressure generated by the air-flow from the lungs to the vocal tract .

(image from )

Mathematical Modeling of the Syrinx
Sound is created by periodic airflow fluctuations (oscillations). A baseline model for the syrinx was proposed as a very basic spring-mass nonlinear oscillator model which turns out to be a slight variation of (see references for details).

Here is the simplest mathematical model of the syrinx that is supported by experimental evidence. In this scheme, x represents the mid-point of the labia, k is the labia stiffness and p is the air-flow pressure. Note here that these two variables (k and p) are time-varying.

Mathematical Modeling of the Songbird Brain
Here, I look at the model proposed in  that models a population of RA neurons using a central pattern generator.

(image from )

Here, xk and xp are the neurons that control the syringial and respiratory muscles respectively. The neuron y is the inter-neuron governing the co-ordination between xp and xk. The output of this network controls the two parameters for birdsong generation: the labia elasticity (k) and the air pressure (p). The rho values represent the excitatory connections from the HVC area. In their paper, the authors define paths in the p-k parameter space based on the excitatory input rho2 which creates a different syllable for each value.

Here is the actual mathematical model, where S is the sigmoid function.

In their paper, the authors show that they were able to closely replicate a recorded birdsong using this central pattern generator. The following is my attempt to replicate their result in Matlab using the same model and parameter values from their paper.

Creating Synthetic Birdsongs
Here is how to create a synthetic version of the white-crowned sparrow song shown in  using Matlab.

Model for the syrinx (syrinx.m):

`%The bird syrinx model used in%From Laje and Mindlin(2002), Diversity within a Birdsong, Physical Review%Letters%pt = interlabial air pressure%k:labia elasticityfunction yprime = syrinx(t,y,flag,tra,p,k)b=1000;  %(dissipation-friction coefficient) parameter taken from the paperd=power(10,8);  %(nonlinear dissipation coefficent for bounded motion) parameter taken from the paperyprime(1) = y(2) ;pt=interp1(tra,p,t,'spline');kt=interp1(tra,k,t,'spline');yprime(2) = (pt-b)*y(2) - kt*y(1) - d*(power(y(1),2)*y(2));yprime = yprime';`

Model for the Songbird brain (birdBrain.m, the Central Pattern Generator):

`% %The CPG (Central Pattern Generator) Neural Network%Modeling the RA brain region of a songbird%From Laje and Mindlin(2002), Diversity within a Birdsong, Physical Review%Letters%the parameter rho2 is varied where all other parameters are fixed in%generating birdsong syllablesfunction yprime = birdBrain(t,y,flag,rho2)rho1=0;rho3=6;A=10;B=10;C=10;D=-2;E=4;alpha=2;beta=20;%xpyprime(1) = 30 * ( — y(1) + ( 1 / ( 1 + exp(-1 * (rho1 + A * y(1) — B *y(2)))) )) ;%yyprime(2) = 30 * ( — y(2) + ( 1 / ( 1 + exp (-1 * ( rho2 + C * y(1) — D*y(2) + alpha * y(3))))));%xkyprime(3) = 120 * ( -y(3) + ( 1 / ( 1 + exp ( -1 * (rho3 + E* y(3) — beta*y(2))))));yprime = yprime’;`

Singing a syllable (singSyllable.m):

`function [t,song] = singSyllable(rho2)Fs = 22050; %samplingt = 0:1/Fs:0.24;[t1 y] = ode15s(‘birdBrain’,t,[0.01 0.01 0.01],[],rho2);kt=1.4*power(10,9)*y(:,3) + 4.8 * power(10,8);pt=7000*y(:,1) — 2200;[m z1] = ode15s(‘syrinx’,t,[0.01 0.01],[],t,pt,kt);song=z1(:,1);`

Creating a whole song of syllables a-b-c-c (createSong.m)

`clear all;Fs = 22050; %sampling%syllable adisp(‘Generating Syllable a (rho2=-11)’);[m1 s1]=singSyllable(-11.0);disp(‘Syllable a generated’);%play the syllablesound(s1(:,1),Fs);%syllable bdisp(‘Generating Syllable b (rho2=-11.8)’);[m2 s2]=singSyllable(-11.8);disp(‘Syllable c generated’);%play the syllablesound(s2(:,1),Fs);%syllable cdisp(‘Generating Syllable c (rho2=-7.1)’);[m3 s3] = singSyllable(-7.1);disp(‘Syllable c generated’);%play the syllablesound(s3(:,1),Fs);%stich the song updisp(‘Stiching the song up a-b-c-c’);song = [ s1(:,1) ;s2(:,1) ;s3(:,1); s3(:,1)]; disp(‘Saving wav file’);wavwrite(song,Fs,’mindlin2002_song.wav’);disp(‘Playing wav file’);sound(song,Fs);`

Here is how this synthetic birdsong sounds:

Note
This material was prepared for a graduate level course in Advanced Ordinary Differential Equations. The technical report can be found and Matlab source code can be found on Github .

References
 Gabriel B. Mindlin and Rodrigo Laje. The Physics of Birdsong. Series in Biological and Medical Physics,Biomedical Engineering. Springer, 2005.

Rodrigo Laje, Timothy J. Gardner, and Gabriel B. Mindlin. Neuromuscular control of vocalizations in birdsong: A model. Physical Review E: Statistical,Nonlinear, and Soft Matter Physics,65:051921–8:051921–8, 2002.

Fernando Nottebohm. Birdsong’s clockwork. Nature Neuroscience, 5:925–926, 2002.

Rodrigo Laje and Gabriel B. Mindlin. . Physical Review Letters, 89:288101–1:288102–4, 2002.

Written by

Written by