Most of the sounds we hear are mixtures of many different frequencies. For example, at any one time, you may be hearing the sounds of voices, traffic, pigeons, wind, machinery, and your own footsteps. Each of these sources itself consists of a range of frequencies.
Pipes of Pan uses the principle of resonance to separate sound into individual frequency components. Any object has a frequency or set of frequencies, called its natural frequencies, at which it “likes” to vibrate. For example, a pendulum swinging by itself, with no pushing, will always oscillate at the same frequency. You can change this natural frequency by changing the length of the pendulum. In fact, an object’s natural frequency, in general, depends on its size: The bigger it is, the more slowly it tends to vibrate.
In this Snack, the “object” that’s vibrating is the air inside the tubes. The longer the column of air in the tube, the more slowly it tends to vibrate. Because each tube has a different length, it selects out a different set of frequencies from the mishmash of background noise, and ignores the other frequencies. When you put your ear to the longest tube, you hear the lowest frequencies; when you listen to the shortest tube, you hear the highest frequencies, and so on.
When you close off one end of the tube with your ear, the resonant frequencies become even lower. The lowest resonant frequency of a tube closed at one end is half that of the same-length tube open at both ends. An explanation of why this is so is beyond the scope of what we can reasonably include here, but it is commonly covered in many high school and college physics texts.