This is a well-known effect in psychoacoustics: your earbuds muffled the sound, and the pitch of a sound varies with its intensity. Generally, low frequencies sound lower in pitch when louder, while high frequencies sound higher in pitch, with the turnaround region about 3 kHz. You can play with an example here.
Unfortunately, it's not a pure physics phenomenon, but a rather more complicated biological thing. Furthermore, even though this effect has been documented for almost a century, there doesn't seem to be any agreement today over why it happens. From the psychoacoustics textbook An Introduction to the Psychology of Hearing:
It has sometimes been argued that pitch shifts with level are inconsistent
with the temporal theory of pitch; neural inter-spike intervals (ISls) are hardly
affected by changes in sound level over a wide range. However, changes in
pitch with level could be explained by the place theory, if shifts in level were
accompanied by shifts in the position of maximum excitation on the BM. On
closer examination, these arguments turn out to be rather weak. Although the
temporal theory is based on the assumption that pitch depends on the
temporal pattern of nerve spikes, it is also assumed that the temporal
information is "decoded" at some level in the auditory system. In other words,
the time intervals between neural spikes are measured and transformed into
another representation. It is quite possible that the mechanism that does this
is affected by which neurons are active and by the spike rates in those
neurons; these in turn depend on sound level.
The argument favoring the place mechanism is also weak. The results of
physiological experiments using animals and forward-masking experiments
using human subjects (see Chapter 3, Section 9) suggest that the peak in the
excitation pattern evoked by medium- and high-frequency tones shifts
towards the base of the cochlea with increasing sound level (Moore et al. ,
2002). The base is tuned to higher frequencies, so the basal-ward shift should
correspond to hearing an increase in pitch. At high sound levels, the basalward shift corresponds to a shift in frequency of one-half octave or more.
Thus, the place theory predicts that the pitch of a medium- or high-frequency
tone should increase with increasing sound level, and the shift should
correspond to half an octave or more at high sound levels. In fact, the shift in
pitch is always much less than half an octave. Another problem for an
explanation in terms of place theory comes from the observation of Thurlow
(1943) that the pitch of a tone presented to one ear can be changed by
presenting a tone of the same frequency to the other ear, provided that both
tones are of fairly high intensity. The change in pitch is in the same direction
as that produced by a physical increase in intensity. The pitch shift may have
more to do with the loudness of the tone (which depends on information from
both ears) than with the intensity in each ear (which determines the position
of the peak excitation on the BM).
In plainer English, nobody knows whether this effect is due to a difference in how the neural impulses get processed in the brain (the temporal theory), or how the cochlea is excited in the ear (the place theory). It doesn't seem to fit well with either one of these two theories of pitch. The book concludes:
At present, there is no generally accepted explanation for the shifts in pitch
One of the great things about everyday physics is that, using only your own senses, you can go so quickly beyond our knowledge!