Skip to main content

Sound, digitized

What a recording is, and what the recorder’s settings cost you

NoteCredit

The order of topics here follows the “Sound” tutorial in Marcelo Araya-Salas’s course Bioacoustic analysis in R (OTS, 2025; page, course repository; © 2025 Marcelo Araya-Salas). The text, code, figures and recording on this page are our own. His page goes further than ours (other R sound classes, FLAC export, importing from Xeno-canto) and is worth reading once you have finished this one. For a book-length treatment of sound analysis in R, see Sueur (2018), listed below.

Everything we measure starts as a file of numbers. This page explains what those numbers are, why a call can look different at different sampling rates, and why we only trust some measurements from mp3 files. The next page, Sound in R, shows how to read the same file into R.

Listen first

This is a calling male Eleutherodactylus marnockii recorded at the Brackenridge Field Laboratory (BFL), Travis Co., Austin, Texas, on 13 April 2026. It is 16.5 s long and holds 13 calls.

TipHow to use the players

Press play and a red line follows the sound across both panels, or click the figure to jump to that point. The speed buttons slow the sound down. At ¼× the pitch drops two octaves and each call turns into a rattle you can count. Slowing a sound down does not change the file; the player only plays it at a different rate.

Oscillogram and spectrogram of 16.5 s of an E. marnockii recording from Brackenridge Field Laboratory, Travis County, Texas, 13 April 2026. Thirteen calls, about 1.2 s apart, each get louder from start to end. In the spectrogram each call is a band near 2 kHz, with a harmonic near 4 kHz.

Audio: 13 short trills about 1.2 s apart, each a rapid run of clicks that gets louder, over faint background hiss.

The top panel is the oscillogram, loudness against time. The bottom panel is the spectrogram, which adds pitch: darker means more energy at that frequency. Each call is a short burst near 2 kHz, with fainter copies at about 4 and 6 kHz (harmonics). Calls come about once per second. The vocabulary for what counts as a call, a note and a pulse is on Calls, notes, and pulses.

One call, zoomed in

One E. marnockii call zoomed in to 0.45 s. The oscillogram shows about 17 pulses that grow louder from 3.16 to 3.49 s. In the spectrogram each pulse is a dark spot near 2 kHz, with lighter harmonic spots near 4 and 6.5 kHz.

Audio: one trill, about 0.3 s: a fast string of clicks that grows louder and stops abruptly.

At this scale the call turns out to be a train of pulses about 20 ms apart, or roughly 50 pulses per second, getting louder toward the end. Try the ½× and ¼× buttons here too. Each pulse is a dozen or so cycles of a 2 kHz tone. The oscillogram draws those cycles so close together that they fill the pulse solid black.

A recording is a list of numbers

Zoom in about 150 times further and the black pulse separates into individual waves. The recorder measured the air pressure at the microphone many times per second and wrote down each measurement. Each measurement is a sample, and the number of samples per second is the sampling rate, in hertz (Hz).

A 3 ms stretch of a sound wave, shown with three sampling rates. At 44.1 kHz, 133 samples trace the wave smoothly. At 11.025 kHz, every 4th sample, the dots still follow the wave closely. At 5.5 kHz, every 8th sample, the line joining the dots misses many peaks and troughs and no longer matches the wave.

A 3 ms stretch from the loudest pulse of the call above. Top: every sample of the file (44,100 per second). Below: what is left if every 4th or every 8th sample is kept.

The file you will use stores 44,100 samples per second, so these 3 ms hold 133 numbers, and the whole 16.5 s recording holds 727,650. Keep only every 4th number and the wave is still recognizable. Keep every 8th and each cycle of the 2 kHz tone is described by only two or three points. The picture has changed, and a slower recorder would have stored exactly this.

How fast is fast enough?

The rule is that a recording can hold frequencies up to half its sampling rate. That limit is the Nyquist frequency. A 44.1 kHz file holds everything up to 22.05 kHz, and a 5.5 kHz file holds everything up to about 2.76 kHz.

Spectrograms showing the Nyquist limit, half the sampling rate, as a dashed red line. A: a real call at 44.1 kHz with a 2 kHz band and harmonics near 4 and 6 kHz. B: at 11.025 kHz, Nyquist 5.5 kHz, the 6 kHz harmonic is gone. C: at 5.5 kHz, Nyquist 2.76 kHz, all harmonics are gone but the 2 kHz band survives. D: a rising sweep, filtered before sampling, stops at the limit. E: the same sweep without the filter folds back down at the limit, creating false frequencies.

The same call at lower and lower sampling rates (A to C), and a synthetic sweep showing what happens at the limit (D and E).

Read the figure from the top. At 11.025 kHz (B) the call is fine except that the faint 6 kHz harmonic has disappeared, because 6 kHz is above the 5.5 kHz limit. At 5.5 kHz (C) the 4 kHz harmonic has gone too, and only the 2 kHz band is left. Nothing in the file says that frequencies are missing. A reader who saw only panel C would not know the call had harmonics.

Panels D and E show the second problem. The sweep rises from 0.2 to 8 kHz. In D the sweep was filtered first, so it rises to the limit and stops. In E nobody filtered it, and the part of the sweep above the limit folds back down as a falling line at false frequencies. This is aliasing. A recorder avoids it with a filter ahead of the converter, which is why you rarely meet it in field recordings. You can meet it in R. Both tuneR::downsample() and seewave::resamp() lower a sampling rate by dropping samples, with no filter, so they behave like panel E. If you need a lower rate, filter first (as panel D did with seewave::ffilter()), or resample with a tool that filters for you. We made the clip on this page with av::av_audio_convert() for that reason.

Hear the difference. The files are stored at 44.1 kHz so every browser can play them, but the content in each one is limited as described.

Original 11 kHz 5.5 kHz Sweep, filtered Sweep, aliased

Audio: Original: the trill shown above. 11 kHz: sounds almost the same. 5.5 kHz: duller and muffled, but the trill is still clear. Sweep, filtered: a rising tone that fades out. Sweep, aliased: a tone that rises, falls, then rises again.

The filtered sweep rises and then fades out. The aliased sweep rises, turns around and falls, then rises again. That falling tone does not exist in the signal.

For our frogs the limits are generous. These calls sit near 2 kHz with harmonics under 8 kHz, so 44.1 or 48 kHz leaves a wide margin. The original recording of this clip was made at 96 kHz. Higher rates matter for animals that call at ultrasonic frequencies, and for working with a wide margin above the call.

How many levels per sample?

Each sample is also rounded to one of a fixed number of levels. The number of bits sets how many. Sixteen bits gives 65,536 levels, 24 bits gives over 16 million.

The same 3 ms sound wave rounded to three bit depths. At 3 bits, with only 7 levels per side, the wave becomes a staircase. At 6 bits, with 63 levels, the steps are small. At 16 bits, with 32,767 levels, the rounded wave sits on top of the original.

The same 3 ms, rounded to 3, 6 and 16 bits.

At 3 bits the wave becomes a staircase, and the rounding error is audible as hiss. At 16 bits the red line sits on the original. Each extra bit adds about 6 dB of dynamic range, the gap between the quietest and the loudest sound the file can hold. That makes 16 bits about 96 dB and 24 bits about 144 dB. Field recorders often save 24-bit or 32-bit float files so that setting the gain imperfectly costs little. A recording made with the gain too high clips (the wave flattens at the loudest point) and nothing can repair it afterwards. A recording made with the gain too low still works, because you can make it louder later, though the quiet parts carry more rounding error.

NoteWhere this clip came from

Recorded with a Sound Devices MixPre-3 II and a Sennheiser MKE 600 shotgun microphone with a furry windshield, on input 1. The original file is a 4-channel, 96 kHz, 32-bit float WAV. Its tracks are the left mix (channel 1), inputs 1 to 3 (channels 2 to 4). Channels 1 and 2 are identical and 3 and 4 are empty, because only input 1 was in use. The clip is channel 1, seconds 103.5 to 120.0 of that file, filtered and resampled to 44.1 kHz, 16 bits, and scaled so the loudest sample sits at 90% of full scale. The script is scripts/make-sound-figs.R.

Files and compression

Format What it stores Use for measuring
WAV Every sample, uncompressed Everything
FLAC The same samples, compressed without loss (about half the size) Everything
MP3 An approximation that drops what the encoder judges inaudible Timing and counts only

MP3 is built for listening. The encoder discards detail that a person would not miss, and it can only do that by changing the waveform. Here is our clip after encoding at 64 kbps.

The same E. marnockii call as a WAV file and as a 64 kbps MP3, each shown as an oscillogram and a spectrogram. The two look similar overall. In the MP3, the quiet early pulses are dimmer, there is ringing after the last pulse, and the whole call is shifted about 0.04 s later.

The same call as a WAV and as a 64 kbps MP3.

The quiet pulses at the start are dimmer, there is ringing after the last pulse, and the whole call has moved about 0.04 s later because the decoder adds a delay. Pulse counts, call durations and rates survive this. Amplitude and fine spectral shape do not. That is why, for the older handheld recordings that exist only as mp3, we measure call and note durations, rates, note counts and dominant frequency, and we avoid anything based on amplitude or fine spectral detail. PAM data are WAV and carry no such restriction.

Check yourself

  1. A recording has a sampling rate of 22,050 Hz. What is the highest frequency it can hold?
  2. A teammate shows you a spectrogram that ends at 2.5 kHz and says the call has no harmonics. What would you ask first?
  3. You have only an mp3 of a call. Which of these can you still measure reliably: call duration, peak amplitude, dominant frequency, the shape of the spectrum?
  1. 11,025 Hz, half the sampling rate.
  2. What the sampling rate was. At 5.5 kHz the harmonics at 4 and 6 kHz cannot exist in the file, whether or not the frog produced them.
  3. Call duration and dominant frequency. Peak amplitude and spectrum shape change in the encoder.

Next: Sound in R.

References

Recording by T. J. Devitt. Figures and audio come from scripts/make-sound-figs.R.

Prepared with Claude Code (Claude Sonnet 5.5, Anthropic): figure and audio script, player changes, and a first draft of the text. Figure alt text and audio descriptions added with Claude Opus 5.5.