Musical fiction is a genre of fiction in which music is the main subject matter of the narrative. It can also be through the rhythm and flow of the prose itself. As a literary sub-genre it engages musical pretexts, as well a relationship to a musical model.
June Skinner stated in her book, The Best of Rock Fiction – “Rock fiction has not received the proper respect it deserves, which is unfortunate given the caliber of writers who have captured its fleeting essence on the written page.”
Novels written with a musical component can be base on the era, a personality or a vehicle to set the ‘mood’ of the narrative.
One of my favorites is High Fidelity by Nick Hornby, the movie of the same name starring John Cusack was full of musical references.
Here is a great list of music based novels. https://www.penguinrandomhouse.com/the-read-down/books-to-read-if-you-love-music