Over the years I've talked to people who are depressed - maybe not clinically depressed, but feeling bad, not able to see their way out of a stressful situation.
David truly was in a terrible situation. People were after him - wanting to kill him. That's a very stressful situation to say the least.
"How long, O Lord?" was actually a good question.
David had the key to waiting - the key to contentment in the face of trials.
5 But I trust in your unfailing love; my heart rejoices in your salvation. 6 I will sing to the LORD, for he has been good to me.
David remembered God's unfailing love. Perhaps he kept a spreadsheet of all the things God had done for him over the years. When we remember what God has done in the past we can face the future with confidence.
I'm not sure David was suggesting everyone should sing in choir (although it's not a bad idea) but the final verse is the perfect way to show what's in your heart. When we sing together on Sunday mornings in worship you should sing with all of your heart (especially if you're not in choir.) During the week you'll sing when you consider how God has been good to you.
Ha! That old hymn just popped in my head. "I sing because I'm happy. I sing because I'm free; for His eye is on the sparrow and I know He watches me."