According to the Cruise Vessel Security and Safety Act, cruise ships are required to have "acoustic hailing and warning devices" in certain high risk areas. These devices emit a high pitched noise that is directed toward approaching vessels and causes intense pain to the ears of the vessel's occupants.
The reason for this law is is to protect passengers and crew members from pirate attacks by repelling pirate skiffs from approaching and trying to board vessels on the high seas. You can read accounts of pirates attacking cruise ships here to see that the risk of such an attack is foreseeable.
Unfortunately, some cruise lines are not in compliance with this new law which was passed in 2010.