It can also be used as an adjective to describe something that is characterized by sadness, pensiveness, or a feeling of thoughtful dejection.
Here are some examples:
* Noun: "He felt a deep melancholy after the loss of his pet."
* Adjective: "The melancholy music filled the room with a sense of longing."