If you hum quietly just before a loud noise, it won't be as painful.
The two smallest muscles in the body are the stapedius muscle and the tensor tympani muscle. They hold together the three smallest bones in the body - the hammer, anvil and stirrup - within the middle ear. The two muscles can contract, reducing the amplification abilities of the three bones, though the reaction time of the muscles is too slow for unexpected loud noises. But these muscles (and muscles around the eardrum) automatically tense whenever we make a noise, such as a sneeze or a spoken word. These sounds rattle around inside our head as well as outside, so they could overwhelm our hearing mechanisms if this safetyguard wasn't in place. Humming or singing automatically sets the muscles, so the hearing system is protected when the loud noise occurs. But you can't start the humming too far in advance of the loud noise. The muscles are very weak, so they cannot maintain the protective stance for very long.
Update: I must stress that purposely exposing yourself to very loud noises is not a good thing to do. You can cause permanent hearing loss, something which should be anathema to anyone who reads this blog. If you absolutely have to crash that cymbol, then use the hum. But otherwise, lay off the percussion, people!