1. XBMC 12.2 is getting a bit old... given the changes in the audio system for Gotham, you'd probably be wise to upgrade as a first step, see if the problem is still there.
2. Did the same files used to play properly before? Or are these new ones?
3. You'll need to describe a lot more about your setup - and the files themselves. What's the audio coded in; how many channels; is there a pattern there; what's your audio output; is VLC using the same output; what are your volume/audio settings (downmix/normalisation, etc.); is this a passthrough audio issue to an external decoder... and so on.
The description of "static in the background" immediately makes me think of hardware and connections, so you'd need to be certain that VLC is using identical outputs before concluding that it's XBMC. I'd also investigate what's changed - if these are new files, and old ones play okay, then is it something to do with the way they're encoded; if these are old files that used to play okay, then what's changed (HW or SW).
MKV and MP4 don't tell you about the audio streams themselves, unfortunately - those are the containers, the boxes into which the video and audio streams are placed. There could still be a variety of different underlying audio formats (MP3, AAC, AC3...) in those, especially in MKV.
I'd look to getting a
debug_log (wiki) and run media info on the files as a starting point, plus work through how the audio gets from file to application to speakers.