Go Back   Home > Forums > >

PC Based Computer music servers, crossovers, and equalization

polarity inversion on the fly by means of ALSA?
polarity inversion on the fly by means of ALSA?
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
Old 3rd October 2018, 09:47 PM   #1
xwollsock is offline xwollsock
diyAudio Member
 
Join Date: Oct 2018
Default polarity inversion on the fly by means of ALSA?

Hello,


Nooby question for ALSA experts, I hope this is the right forum: is it possible to invert the polarity of a digital stream on the fly using just ALSA? I've been discussing the usefulness of such a feature with the maintainer of a free MPD-based player for the Raspberry Pi, and the preferable way to implement this would seem to be using ALSA directly, possibly by means of a LADSPA plugin.


Please keep this thread focused on the feasability of this task; the merits of why this may or may not be useful to have can be discussed elsewhere if there is demand. Notice, however, that some pretty good DACs have a dedicated button for this purpose. Also DAPHILE (based on sqeezelite) has such a setting, although buried deep inside the menu system.
  Reply With Quote
Old 4th October 2018, 10:40 AM   #2
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Just define your own alsa device in .asoundrc with route plugin and invert the required channel. I do this for one of the channels (ttable ..... 0.1= -1 ) in virtual balanced_out device Virtual balanced in/out from regular soundcard in linux - results .
  Reply With Quote
Old 5th October 2018, 02:27 AM   #3
TimCurtis is offline TimCurtis  United States
diyAudio Member
 
TimCurtis's Avatar
 
Join Date: Jan 2012
Location: Metro-Detroit
Interesting :-)

The ttable coefficient represents volume (%) correct?
And a negative value inverts the waveform?
  Reply With Quote
Old 5th October 2018, 06:23 AM   #4
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Code:
A.B = X
The coeff X is a decimal-point number representing the multiplier of input channel A into the output channel B. All contributions to channel B are summed - that is why when mixing two channels (0.0 = X, 1.0 = Y) the coeffs should not exceed 0.5 to make sure no clipping can occur during the summation.

Negative sign just inverts phase - multiplication by a negative number.

The string number is read by the c-stdlib function strtod.
  Reply With Quote
Old 5th October 2018, 11:24 AM   #5
TimCurtis is offline TimCurtis  United States
diyAudio Member
 
TimCurtis's Avatar
 
Join Date: Jan 2012
Location: Metro-Detroit
Great, thanks :-) but is it performing a phase shift of the waveform (moving it forwards or backwards in time) or is it inverting the waveform (flipping it but no time shift)
Phase vs Polarity explained | JustMastering.com
  Reply With Quote
Old 5th October 2018, 11:45 AM   #6
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Just inverting - multiplication by negative number.
  Reply With Quote
Old 6th October 2018, 12:23 AM   #7
TimCurtis is offline TimCurtis  United States
diyAudio Member
 
TimCurtis's Avatar
 
Join Date: Jan 2012
Location: Metro-Detroit
Got it. Thanks for the explaination. ALSA scripting is not an easy one to figure out.

-Tim
  Reply With Quote
Old 10th October 2018, 06:08 AM   #8
xwollsock is offline xwollsock
diyAudio Member
 
Join Date: Oct 2018
Thanks phofman! I'm lloking forward to Tim's implementation of this feature.
  Reply With Quote
Old 19th March 2019, 08:11 PM   #9
daemonsgr is offline daemonsgr  United Kingdom
diyAudio Member
 
Join Date: Jun 2014
Location: London... sometimes sunny Greece
Hi, i think I actually asked the same thing by starting a new thread.

Going through this post I cant say I found/know the solution.
I need to invert both channels on the fly, both flipped. Running picoreplayer.

Did you manage to make the correct config?

Thanks
  Reply With Quote
Old 19th March 2019, 09:03 PM   #10
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Actually your requirement for on-the-fly flipping complicates the matter substantially. You cannot use a fixed alsa device with route plugin as its config cannot be changed while the stream plays.
  Reply With Quote

Reply


polarity inversion on the fly by means of ALSA?Hide this!Advertise here!
Thread Tools

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
ALSA finally on Openelec mkusan PC Based 0 24th February 2014 06:31 AM
Phase Shift or Polarity Inversion?? pYrana13 Class D 9 28th April 2013 08:23 PM
Avoid polarity inversion MaXiZ Everything Else 7 3rd March 2004 05:55 AM
Polarity Inversion circuit ashok Everything Else 17 5th April 2003 11:32 AM


New To Site? Need Help?

All times are GMT. The time now is 10:33 PM.


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