With the XRoar 'tapehack' patch. I've just rolled this into the main tree (so future releases should have it built-in) and generated a snapshot, so you can play with this yourself:
Source codeWindows binaryBasically, when run with the "-tapehack" command line option, anything read in on the input cassette file is rewritten to the output cassette file. While doing so, it tries to maintain byte sync (so the CAS files remain "readable") and inserts extra leaders where appropriate.
So, run with "-tapehack" on the command line, use Ctrl+L to attach a tape, press Ctrl+W to give a .cas filename to write to, then load the game. Any bytes read in while loading should be written out to the file you specify.
Input can be CAS, ASC/BAS or audio files. Output can only be CAS files at the moment. Be aware that as it is, it won't work for *everything* (really special loaders will cause issues), but most things are ok.
And actually, it doesn't quite work for Return of the Ring either - that needs some extra leader bytes inserting, as its loader turns the motor on and then waits long enough that the default leader isn't quite long enough. But that's rare.