Edit: Around 18th and 19th centuries.
I'm going to go ahead and assume you are specifically referring to how popular music was spread in the eras before the Twentieth Century, and since my depth of knowledge of this subject extends no further than the US, we're going to constrain this answer to the American music scene of the late-1800's.
The real answer to this question is sheet music. Lyricists and composers popularized their music through consumers purchasing printed music sheets that they could use to play songs in the own homes or in the company of guests. This economy is often referenced in companion with the Tin Pan Alley, which became known as the epicenter of this music production due to the number of popular publishers and composers working in the same district in New York City. I believe that the rapid growth of this industry is largely due to longer and more strict copyright laws, but I would love someone with further knowledge to clarify this point. I suspect it is a bit nuanced.
The other important dimension of this though is the marketing to spread this music. To then create a national marketplace for these tunes, publishers would send out minstrel shows or singers to tour the country singing and performing these songs. These groups would perform in a variety of settings like between acts in the theatre or between humorous skits in the case of the minstrel shows. The publishers sold the sheet music after the show instead of t-shirts or CDs like they might nowadays. An audience member could remember a song they enjoyed, then pick up the music to replay at their home. It certainly is not a quick as broadcasting over the airwaves or sending out shipments of records, but in the end, these town-to-town tourers did achieve the same results.
I came to this topic in the context of the minstrel shows and their racial implications, so this 1978 article in American Heritage gets referenced a fair amount in these types of discussions. It should give a fair sense of these shows and their remarkable impact on American culture at the time.
Robert C. Toll, "Behind the Blackface," American Heritage 29, no. 3 (1978).
It doesn't include much about the spread of sheet music, but the Tin Pan Alley has been well researched, and it is not difficult to find further reading on that topic.
fyi, here's a related post on live music
Do you mean directly before, so around 1880s-1900s?