Using the default GOG settings, you get fully digital sounds, like doors that creak open and such, but also that random piano when you walk.
Using the fix above gets rid of that piano sound, but also the digital sounds, so sound effects are just bad midi sounds. :( (this is in UU2 only)
Is there no better solution?
Hmm strangely, for me the above-mentioned configuration actually both fixes the music and the piano sound *and* keeps the digital sound - well, that only proves the idea that DosBox needs to be fine-tuned sometimes for each particular system... Well, you can experiment with that line in uw.cfg and try other sound devices, so basically change it, step by step, to one of the following:
2 -1 -1 -1 sound
3 -1 -1 -1 sound
4 -1 -1 -1 sound
5 -1 -1 -1 sound
and see if any of it produces the desired output for you. If not, maybe try playing with the sound card settings in the DosBox configuration file (dosboxULTIMA2.conf for UW2, dosboxULTIMA1.conf for UW1), and see if maybe changing 'sbtype' to sb1, sb2, sbpro1, sbpro2, or sb16 does anything to fix your issue.
Also, since you're getting issues with random MIDI playback kicking in, maybe try changing 'mpu401' from intelligent to uart or none in those DosBox configuration files as well, and see if that makes it any better.
It's a good idea to make backups of both uw.cfg and the DosBox .conf files before modifying them so you can revert to the original settings easily.
Please let us know if any of it solved the issue for you.