Parry Gripp acknowledges that his 2012 hit, “Raining Tacos,” can be obnoxious. He wrote the song with a specific audience in mind: “children and people who like tacos a lot.”

He did not intend for his happy litany about a taco downpour to be weaponized.

The city of West Palm Beach in recent weeks has been blaring Mr. Gripp’s earworm, as well as “Baby Shark,” another maddeningly catchy children’s tune, outside an event center to deter homeless people from sleeping or convening in the area at night.

The approach has drawn criticism from some homeless people and from advocates who are working to get them off the streets. They said that the city should be inviting people in rather than pushing them away, and that the tactic disregarded the root causes of homelessness.