I was wondering if a character was in a nighclub or at a concert. How do you represent the music?
It got me thinking that writing is a very non musical medium and that it is actually pretty hard to make the reader hear what you want to.
All mediums have their limitations. The medium of books is the written word. Despite the popular dictum of "show don't tell", you cannot address any senses directly through writing, you have to describe everything that your readers are then asked to imagine.
Music is no different than any other aspect of reality, when it comes to writing about it. There is a large specialized vocabulary to describe the different aspects of music, if you want to be very accurate and detailed, but just like all technical jargon this is usually not readily comprehensible to the layperson. Everyone can hear a crescendo, for example, but most people do not know that that term denotes.
So you must make a decision: Do you write as an expert to experts, in a similar way as some technical science fiction relies on a good understanding of the relevant technology in its readers? Or do you use common but vague terms like "loud", "rhythmic" or "exciting" to allude to experiences with music that most of us share?
If you write to a non-specialist audience, think about writing about music as similar to writing about anything else. You describe a house in your story without being an architect and knowing what architrave is. You describe emotions without being a psychologist.
Just carefully observe the music and your characters response to it, and describe that. And leave the readers some leeway to fill in what a "heavy beat" or "pleasant melody" might be for them. It does not matter, if the music they imagine differs from the one you have in mind, what is important is that this music has the same effect on them.
What you must consider, though, is the character of your narrator. Is he an omniscient, neutral narrator? Then he would use standardized, educated, but non-specialist language. Is your tale told by a music enthusiast? Then you need the terminology of music, because she will think in it. (You can still write for a lay audience, if your terminology explains itself from the context, or its exact meaning is irrelevant to the plot.) Is your narrator an teenage boy? Then use the language of teenagers to describe the music.
If you are writing fiction, your narrator will dictate how you write about music. Make yourself familiar with how such a person speaks by doing research. The internet is full of all types of people discussing music, so this should be fairly easy.
Let me add a lengthy quote from "The Serpent Mage" by Greg Bear, narrating the entirety of Mahler's Tenth Symphony. This is to give you a clue how deep in detail one can get, how you can convey a whole concerto piece through a written text.
Of course in your everyday writing you hardly ever need to go into this level of detail. Give the genre, give the mood. You may give the title, music is at hands' reach of today's readers so if they are compelled to do so, they can play it freely.
Music can give background to the scenes, follow them - describe its changes of the beat to reflect the effects. It can guide, influence the characters. It may hint, explain, or pretty much do everything a secondary character that can't physically touch the protagonist can do. You can make the music an actor - like in the above piece.
Or you can go the easier way. Reflect the music in the impressions of the characters - instead of writing about the music, write about their reactions. Tapping the rhythm, going into melancholy, getting annoyed, getting cheered up against their wishes, calming down, delving into reminiscences. That's the easy way, music being the background.
The neat thing about that approach is that you filter the music through the perception of a character. Two different people will react differently to the same piece of music. An omniscient narrator, or a switch of perspective can give a nice bit of exposure of a character's mind through showing how they react to given piece. "That lie aimed at kids who don't know any better" vs "that piece which truly inspires to greatness"? "That little annoying tune" vs "an uplifting, cheerful melody"? "The legend of magnificence and harmony" vs "that boring, long thing snobs listen to, to show how elaborate they are"? You can use music to ask questions, and have the reader judge the characters by the answers.