Whistles are instruments that can be great for use in the background for cheerful music. The PSG square wave channels can make pretty good whistles so let's see how that works.
The instrument (in Echo's PSG format) looks like this:
00 91 FE 02 92 FF
which produces this chart:
The envelope is just a basic PSG instrument (start at the peak, decay a bit, then sustain there). The important part however is in the pitch, expressed as alternating colors here: every 1/60th of a second, it alternates between the original pitch and two semitones lower. This is what gives the whistle sound.
To take it further: the particular base pitch used here is E in the 6th PSG octave in Echo (which means the whistle alternates between E and D). You can pick a different pitch to make a whole melody with whistles, however.
Sonic 1 (8-bit) whistles
Credit where credit is due. The 8-bit ports of Sonic 1 feature bonus stages with a PSG whistle, so the question was brought up on Twitter about how it was made. This is what Yuzo Koshiro replied:
Yuzo Koshiro on Twitter
l128 o6 dededededeみたいな感じだったかと思います。
Yuzo Koshiro on Twitter (translated)
I think it was something like
l128 o6 dedededede.
The "code" there is MML syntax:
l128is the note length (1/128th, which is one frame long at the tempo in use)
o6is the PSG octave (note that this is the 6th octave for the sound driver!)
eare their respective notes
Either way, his memory was correct because that's exactly how it sounds in the game (and mml2esf happened to use the same settings). The PSG whistle instrument explained in this page recreates this behavior, and adds a simple envelope to go on top (in particular, it helps tell apart when you play it twice in a row with the same base pitch).