He appointed certain of the Levites to minister before the ark of Yahweh, and to celebrate and to thank and praise Yahweh, the God of Israel:
So David gave him the lyrics, and these guys started singing and worshipping the Lord with this song or psalm.