Go Back   Home > Forums > >
Home Forums Rules Articles diyAudio Store Blogs Gallery Wiki Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

PC Based Computer music servers, crossovers, and equalization

Virtual balanced in/out from regular soundcard in linux - results
Virtual balanced in/out from regular soundcard in linux - results
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 29th August 2018, 12:35 PM   #1
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Default Virtual balanced in/out from regular soundcard in linux - results

Regular soundcards have only single-ended inputs/outputs. For longer runs/measurements/avoiding ground loops a balanced connection is needed.

This is what happens if stereo single-ended inputs/outputs of a regular internal soundcard are converted into dual-mono balanced ones by simple alsa configuration in .asoundrc.

Code:
pcm.balanced_in {
         type route
         slave {
                 pcm "hw:0"
                 channels 2
         }

	 ttable {
		 0.0= 0.485571
		 0.1= -0.49
		 1.0= 0.485571
		 1.1= -0.49
	 }
}

pcm.balanced_out {
         type route
         slave {
                 pcm "hw:0"
                 channels 2
         }
	 ttable {
		 0.0= 1
		 0.1= -1
	 }
}
pcm.balanced
{
    type asym
    playback.pcm
    {
        type plug
        slave.pcm "balanced_out"
    }
    capture.pcm 
    {
        type plug
        slave.pcm "balanced_in"
    }
}
Device balanced_out - right channel of the virtual device is inverted to the soundcard left output channel

Device balanced_in - input channels of the soundcard are subtracted into identical right/left channels of the virtual device. To avoid clipping with full-scale signal, each input channel contributes < 50% to the result.

To optimize common-mode rejection I measured transfer of each in/out chain:

1) recording stereo signal (hw:0 -> hw:0) and

2) measuring RMS in each channel by sox

Code:
sox out.wav -n remix 1 stat
sox out.wav -n remix 2 stat
The ratio of listed RMS amplitudes gives the channel difference and corresponding coffecient of one channel in balanced_in definition must be multiplied with. In my case the default 0.49 coefficient was calibrated to 0.485571 for the other channel.

Measured results:

Line-in jack on PC front panel was hooked with line-out jack on back panel with a regular thin long curly stereo jack cable. Older power-consuming workstation producing lots of EMI/RFI (Dell Precision, 2 x dual Xeon, 72GB RAM), internal Intel HDA with 24bit codec AD1984A.

Measured in arta under wine (wine must be configured to offer alsa software devices)

Code:
winetricks sound=alsa
Sound - WineHQ Wiki

Useful Registry Keys - WineHQ Wiki


Measured results show that even a simple integrated soundcard in the extremely noisy environment of a loaded PC offers very good CMRR (70dB).

With a stereo soundcard such setup can enable measuring bridged amps and/or significantly reducing ground loop effects in measuring.

A multichannel soundcard can be configured to provide stereo balanced output for longer runs and/or reducing the ground-loop issues.
Attached Images
File Type: png single-ended-1200Hz.png (118.5 KB, 268 views)
File Type: png virtual-balanced-1200Hz.png (108.3 KB, 259 views)
File Type: png single-ended-13+14kHz.png (116.1 KB, 257 views)
File Type: png virtual-balanced-13+14kHz.png (112.2 KB, 256 views)
File Type: png calibrated-cmmr.png (109.0 KB, 255 views)
File Type: png calibrated-cmrr-13+14kHz.png (108.3 KB, 34 views)

Last edited by phofman; 29th August 2018 at 08:41 PM.
  Reply With Quote
Old 29th August 2018, 03:02 PM   #2
PMA is offline PMA  Europe
diyAudio Member
 
PMA's Avatar
 
Join Date: Apr 2002
Location: Prague
Good job, it is a nice way how to get balanced input from conventional sound card single-ended inputs and thus avoid ground loops that are inevitable in single-ended loop measurements.
  Reply With Quote
Old 29th August 2018, 05:36 PM   #3
voltwide is offline voltwide  Ireland
diyAudio Member
 
Join Date: Jan 2010
USB soundcards like EMU202 offer symm inputs and are affordable.
  Reply With Quote
Old 29th August 2018, 06:25 PM   #4
DPH is offline DPH  United States
diyAudio Member
 
Join Date: Dec 2008
Location: Portland, OR
Quote:
Originally Posted by PMA View Post
Good job, it is a nice way how to get balanced input from conventional sound card single-ended inputs and thus avoid ground loops that are inevitable in single-ended loop measurements.
x2 on the praise. Clever trick worth keeping in mind. Thanks, PHofman
__________________
Happy DIYing, Daniel
  Reply With Quote
Old 31st August 2018, 10:26 PM   #5
miero is offline miero  Czech Republic
diyAudio Member
 
Join Date: Jun 2011
Location: Prague
I'd like to show measurements of two amplifiers giving 1Vrms into a real loudspeaker using this method.

Measurement equipment:
- virtual balanced input on line-in of internal soundcard [Realtek ALC892, ADC with 90dB(A) SNR] in a PC with ATX supply
- Linux+Wine and ARTA measurement software

Both measurements are direct input from loudspeaker terminal into L+R wires of line-in input - no divider (ground wire was not connected). Voltage on a speaker terminal 1Vrms.

Notice: without virtual balanced input measurements would show much more power line frequencies and their intermodulations with a signal.


Amplifier #1: NAD D3020, USB input [Class-D]
Click the image to open in full size.


Amplifier #2: DPA222mk2 fast SSE [Class-AB, designed by Pavel Dudek (Upupa Epops), built by me from DIY kit]

In this case I used internal sound card as a signal source. It has a higher noise floor at least by 3dB than it would have with a better signal source.
Click the image to open in full size.
__________________
BeagleBone Black with I2S, DSD and SPDIF interface (Linux driver)
http://bbb.ieero.com/
  Reply With Quote
Old 31st August 2018, 10:34 PM   #6
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Miero, thanks for the measurements. Is the DPA amp earthed (class I)?
  Reply With Quote
Old 31st August 2018, 10:40 PM   #7
miero is offline miero  Czech Republic
diyAudio Member
 
Join Date: Jun 2011
Location: Prague
Yes, both measured amplifiers are earthed. There was no hum in the loudspeaker, so I guess the line input of the sound card has capacitors on signal lines.
__________________
BeagleBone Black with I2S, DSD and SPDIF interface (Linux driver)
http://bbb.ieero.com/

Last edited by miero; 31st August 2018 at 10:42 PM.
  Reply With Quote
Old 17th September 2018, 09:55 PM   #8
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Comparision of virtual vs. native balanced input of ESI Juli@ in my measurement station Headless Amplifier Measurement Workstation

The poor CMRR (-50dB) of native balanced inputs suggests Juli uses a fake balanced input similar to one described in Audio Note

Click the image to open in full size.

When shorting the corresponding SE (cinch) input, the cold balanced input sensitivity drops down to -50dB.

IMO the performance of calibrated virtual input is clearly better than that of native fake balanced inputs of Juli.

Of course a proper balanced input with good differential amp does offer a significantly better CMMR (e.g. -100dB for Lynx22 with standard INAxxx).
Attached Images
File Type: png no-signal-virtual-balanced.png (41.8 KB, 32 views)
File Type: png no-signal-native-balanced.png (42.0 KB, 28 views)
File Type: png cmrr-virtual-balanced-192kHz.png (41.3 KB, 23 views)
File Type: png cmrr-native-192kHz.png (38.7 KB, 24 views)
File Type: png fr-virtual-balanced-192kHz.png (37.9 KB, 18 views)
File Type: png fr-native-balanced-192.png (35.4 KB, 16 views)
  Reply With Quote
Old 20th October 2018, 02:52 AM   #9
cacao ambiance is offline cacao ambiance  United Kingdom
diyAudio Member
 
Join Date: Oct 2015
oww, this is a cleaver trick! nice, thanks for sharing.
  Reply With Quote
Old 27th October 2018, 01:43 AM   #10
sgrossklass is offline sgrossklass  Germany
diyAudio Member
 
Join Date: Nov 2004
Location: Germany
I like this old trick, too. It's something I would have liked to see integrated into software like REW, but being able to use the device system-wide (with channel gain delta compensation no less) is even better. Good for you Linux guys.

One thing:
Quote:
Originally Posted by phofman View Post
To optimize common-mode rejection I measured transfer of each in/out chain:

1) recording stereo signal (hw:0 -> hw:0) and

2) measuring RMS in each channel by sox

Code:
sox out.wav -n remix 1 stat
sox out.wav -n remix 2 stat
This will work fine if you just do a loopback measurement, however in a real-life application you'll have to determine channel gain delta for input and output separately. No way around making cables or plugging up adapters so you can split one output channel across both L and R inputs or alternate between the output channels on either input.

Once you've matched your input channel gains well, there is no reason why CMRR couldn't be pretty high - in the "directly connected amplifier" scenario, for example, source impedance is <<1 ohm on both channels, and input impedance a few kOhms at least, possibly several 10 kOhms. If I'm not mistaken, CMRR equals about 2 R_in / ΔR_out, so we're looking at maybe 90 to 110 dB in that case (assuming 2k2..22k in and a damping factor of 60 / 8R, midband). When using a balanced attenuator of 10k/470R each (26 dB and change, the common-mode-reducing variant with midpoint at ground), it's still 54 to 74 dB with 1% parts assuming worst-case tolerances, meaning any sane person with a multimeter and a handful of each resistor value would probably do 20 dB better or more.

What's more, the cost of a stereo opamp buffer should get you a boost of another 14-20 dB if we assume an input impedance of 100-220k, and another 6 dB if instead of simply 2 resistors to ground, we are going with a T-type input bias (e.g. 10k + 10k with a 100k branching off to ground gives more than twice the common-mode input impedance as 2x 100k to ground). Realistically this is one to iron out bigger amounts of mismatch, but still. T topology also is a good idea if you need some Cs in the input for RF suppression.

Quote:
Originally Posted by phofman View Post
Comparision of virtual vs. native balanced input of ESI Juli@ in my measurement station Headless Amplifier Measurement Workstation

The poor CMRR (-50dB) of native balanced inputs suggests Juli uses a fake balanced input similar to one described in Audio Note

Click the image to open in full size.
While this sounds plausible, there is absolutely nothing "fake" about this circuit as long as R1/R3 and R2/R4 are matched. It is a functional balanced line receiver and used like this in loads of lower-cost (home) studio or PA equipment - power amps, monitor speakers, digital crossovers, you name it. It merely involves some nasty tradeoffs between (common-mode) input impedance, gain and noise performance, so it's not really good for anything more than a basic line-level receiver, where levels are high enough and thus lowest noise and highest CMRR aren't of utmost importance. Some particularly cheap manufacturers have also used it for a balanced mic preamp of particularly meh performance - not recommended.

If you take that same circuit and add a buffer in front as outlined above, performance can be improved dramatically. Likewise, a discrete variable-gain balanced frontend turns it into a pretty decent mic preamp (ESP P66, Behringer mixers). And of course, the two amps of the buffer can also be used to form an instrumentation amp.

So lower performance - yes, but fake - decidedly not.

Last edited by sgrossklass; 27th October 2018 at 01:48 AM.
  Reply With Quote

Reply


Virtual balanced in/out from regular soundcard in linux - resultsHide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
UCD180 balanced via soundcard mlihl Class D 5 18th December 2007 11:37 PM
Which soundcard with balanced outs has the best SQ and is less than $250? MikeHunt79 Digital Source 7 28th October 2007 06:19 PM
Modify soundcard, unbalanced to balanced. Llafriel Parts 6 16th May 2006 04:12 PM
Soundcard test results IanHarvey Digital Source 2 23rd January 2004 12:08 PM
got my ESI WT2496 soundcard today - results :) ergo Digital Source 3 30th October 2003 08:24 PM


New To Site? Need Help?

All times are GMT. The time now is 06:29 AM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 14.29%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Copyright ©1999-2018 diyAudio
Wiki