“And now my head shall be lifted up above my enemies all around me, and I will offer in his tent sacrifices with shouts of joy; I will sing and make melody to the Lord.” -Psalm 27:6
David’s response to God’s faithfulness over his enemies and goodness in lifting his head up above his enemies (literally, confidence in the safekeeping of the Lord) was to shout for joy and sing a melody unto the Lord.This is fitting for David’s proclivities.
Perhaps the occasion for this Psalm was when David brought the ark of God up from the house of Obed-Edom after Israel’s defeat of the Philistines when it had be secured there for three months (2 Samuel 6).
“And David danced before the Lord with all his might. And David was wearing a linen ephod. So David and all the house of Israel brought up the ark of the Lord with shouting and with the sound of the horn.” -2 Samuel 6:14–15.
If we take anything from this, let it be that when, not if, God saves us from our enemies (Romans 10:13 cf. 1 Peter 5:8), we rejoice with voices uplifted in song to the Lord (Ephesians 5:18-20 cf. Colossians 3:16-17).