Many consumer-grade computer sound cards (including ones built in to the motherboard) have digital S/PDIF outputs, however not the high quality outputs found on professional audio equipment. In my music server I have a SoundBlaster Audigy2 connected to my Sony surround receiver using a RG-59 coaxial cable from the 1/8" mini S/PDIF connector on the sound card to the digital audio input on the receiver.
This works great, however when the cable is connected a hum can be heard through the speakers, not mattering what input is selected on the receiver. In my experience with professional analog audio equipment, I instantly recognized it as a ground-loop hum. For those without electrical engineering degrees or unfamiliar with ground-loop problems, a ground-loop in an undesired effect occurring when there is a grounding potential difference on the main power supply of two separate devices and when a cable connects the two devices, connecting the devices' ground planes which will cause an electrical current to flow over the wire connecting the two grounds. This potential difference, although usually very small (in my case, less than a volt) can be amplified in analog sound amplifiers and heard in the speakers as a 60Hz hum. Even though we're using a completely digital audio connection, a ground-loop is still created because the shield of the coaxial cable used connects the ground plane of the PC with the ground plane of the Sony receiver.
For a while I considered getting some extra equipment to use a Toslink optical connection between the computer and the receiver, but instead I decided to apply some knowledge I had used when working with professional audio equipment, and that is inserting an isolation transformer between the two devices. Obviously, since this is a high-speed serial digital data connection and not an analog audio connection, we're going to have to think about this a little bit.
It turns out that we can fix this problem very easily, and probably with parts you already have lying around.
Step 1: Getting Things Together to Make a Better Cable
With a little research I found out that high-end professional gear comes from the manufacturer with an isolation transformer built in to the S/PDIF output which completely separates the sheild of the digital cable from the ground plane of the device. We should be able to simply modify our cable to include such a transformer near the output of the sound card.
What we need is a pulse transformer -- a transformer which is designed to transmit digital signals -- and one which is capable of at least 20MHz to support our 192kHz PCM S/PDIF audio signal. With a little thinking outside of the box, we realize that every computer Ethernet card has one such transformer to galvanically isolate the network interface circuitry from the transmission medium, the Ethernet cable. All we need to do is find an old 10/100 Ethernet network card and steal its pulse transformer -- I had an old AMD PCnet 10/100 card lying around which had a Pulse-brand transformer on it. Most common on Ethernet cards are Pulse or Bel-brand transformer. Any transformer suitable for FastEthernet should be suitable for our S/PDIF needs.
Just salvage this transformer from your old Ethernet card, grab a soldering iron, some solder, a knife and a side cutter, and you should have all you need to get on your way to digital audio bliss. It will also help to search the Internet to find a datasheet with a schematic of the internals of your particular pulse transformer so you know what pins to connect your cable's conductors. In my case, I found out I needed to connect the sound card side of the transformer to pins 15 and 16, and the receiver side of the transformer to pins 10 and 11. Because we're dealing with an isolation transformer, it doesn't much matter which pins we connect the shield or the core -- although if you can, you should try to match up shield-shield and core-core leads on the transformer. In my case, I attached the shield to pins 16 and 10 (the "top" leads) and the core to pins 15 and 11 (the "bottom" leads).