Also for those interested in this sort of thing, it is possible to extract the music data from a ROM and play it back using a program that emulates only the console's sound hardware.
In the case of gameboy games, the music data is usually provided in the "gameboy sound" format, with a .gbs file extension.
That was one of the things I did when I added audio support to my NES emulator; add NSF support as a mapper with some special case code (doesn't display video, uses controller inputs to switch tracks). It seems like it only took me a couple of hours to add.
At least Audacious (in its audacious-plugins package) as well as Qmmp support chiptunes via the Game_Music_Emu library. I'd imagine many other plugin-based players for Linux/Unix have support as well.
In the case of gameboy games, the music data is usually provided in the "gameboy sound" format, with a .gbs file extension.
https://www.zophar.net/music/gameboy-gbs
https://gbs.joshw.info/
GBS players typically take the form of a plugin or component for your audio player of choice.