Synthesizing and Synchronizing Snowy Tree Crickets

V. Hunter Adams (


Synchronizaton events are remarkably common in biological systems. Many of these events take place in hard-to-see places (e.g. pacemaker cells of hearts, inside the hippcampus, and in insulin-secreting cells in the pancreas) [1]. Some, however, are spectacularly apparent. One example is firefly synchronization, which happens for a few weeks each year at a few places around the world. Another is snowy tree cricket chirp synchronization, which occurs for much of the year right here in Ithaca and across the United States! Go outside on many evenings and you'll hear it happening.

A snowy tree cricket

The snowy tree cricket is interesting for a number of reasons. In addition to synchronizing their chirps, these crickets change the frequency and speed of their chirps as a function of the ambient temperature. For this reason, they are nicknamed the "thermometer cricket." Here on the east coast, you can estimate the temperature outside (in Fahrenheit) by adding 40 to the number of chirps that you count in 15 seconds. In other parts of the country the linear relationship is slightly different, so it's a good idea to calibrate your crickets before taking any measurements. Fascinatingly, this relationship between temperature and chirp-rate has a name (Dolbear's Law). Even if you grew up in a part of the world without snowy tree crickets, you may still recognize their sound! Snowy tree crickets are often dubbed into soundtracks for movies and television to help depict summer evenings.

In this laboratory exercise, you will synthesize two artificial crickets - one on each of the dual-core processors in the RP2040 microcontroller. These crickets will be synthesized using Direct Digital Synthesis and sound shockingly real. You will then use a microphone to detect cricket chirps. This will involve calculating an FFT and looking for power at the chirp frequency. Finally, you will implement a synchronization algorithm so that your two crickets synchronize. Once everyone proves that their own crickets synchronize, we will turn on all of the crickets in the class to attempt class-wide synchronization of over 100 synthesized snowy tree crickets. Will it work? I don't know! But it will be fun to try.


I've embedded a demo below of the system that you will build. Note: watch the demo with headphones. One cricket is synthesized into the left ear, and the other is synthesized into the right ear.


Experience shows that students prefer these webpages short. For that reason, please find the reading and background materials on the webpages linked below. Please note that the information in these readings will be critical for completing the lab.

Mathematical background

  • Direct Digital Synthesis: This is the algorithm that we will use for sound production. This is a powerful algorithm, a good one to understand deeply.
  • Cricket synthesis: This webpage describes how to use Direct Digital Synthesis (see above) to create a cricket call.
  • Fast Fourier Transforms: You will compute an FFT (Cooley-Tukey FFT) of audio samples gathered from a microphone. You will detect a cricket by looking for power at the chirp frequency. This webpage describes how to implement an FFT, and derives Cooley-Tukey from the sine-cosine series.
  • Synchronization algorithm: This links to a webpage that describes the algorithm in "Synchronization of Pulse-Coupled Biological Oscillators" by Mirollo and Strogatz (1990). This is the algorithm that you will implement to synchronize your crickets. In class, we will discuss implementation strategies on the microcontroller.
  • Fixed-point arithmetic: Sound synthesis requires meeting strict timing deadlines, which means you may not have time to do your computation in floating point. Fixed-point arithmetic allows for you to use integer arithmetic (which is way faster than floating point, on this architecture) while maintaining fractional resolution.

Engineering background

Weekly checkpoints

Week 1

  • Solder your Raspberry Pi Pico
  • In this example code, direct digital synthesis is used to generate two pure sine wave "beeps" of different frequencies - one from each core. Connect the DAC to the Pico per the #define statements at the top of the source code.
  • Confirm that waveforms are being generated by the DAC with the oscilloscope, then solder a 3.5mm audio socket so that you can plug in speakers and listen to the generated beeps.

Week 2

  • Modify the "beep beep" example code such that each core produces a cricket chirp, as described on the cricket synthesis page. I recommend putting the chirp state machine in the interrupt service routine.
  • These chirps must be the correct frequency and must repeat with the correct timing. They must be amplitude-modulated. There should be no audible clicks or pops. In particular:
    • 8 syllables
    • Syllable frequency = 2300 Hz
    • Syllable length = 17 ms
    • Syllable repeat interval = 2 ms
    • Chirp repeat interval = 260 ms
  • Prove, with the oscilloscope, that the above specifications are being met.
  • Add two buttons so that you can pause/play either cricket.
  • Please make these parameters easy to change in your code! For class-wide synchronization, we may want a longer chirp repeat interval.

Week 3

  • In this example code, the ADC is used to sample audio and then the RP2040 calculates/visualizes an FFT.
  • Run this demo code while sampling the microphone. Confirm functionality with a tone generator. The demo code uses analog input 0. Adjust the gain potentiometer on the back until you get good response at the chirp frequency.
  • Modify this code such that it detects one (and only one!) chirp each time a cricket chirps. Print out "Chirp!" to a serial terminal each time you hear one. You can test with the synthesized crickets on the cricket synthesis webpage linked above.
  • Merge this code with your cricket synthesis code. Your system should produce a cricket chirp from each core. Each core should detect the other core's chirps but not it's own chirps.

Week 4

  • Implement the synchronization algorithm described in the link above so that each cricket adjusts its time to fire when it hears the other cricket. Over time, your two crickets should synchronize and remain sychronized.

Once all groups have demonstrated synchronization between their two crickets, we will attempt class-wide synchronization.