polarity inversion on the fly by means of ALSA?

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
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.
 
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.
 
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.

I'm not sure I understand, or maybe my description was really bad, sorry!

I want a permeant config so every track is played with inverted polarity, all the time for any audio that the pCP plays. Both channels.
Does it makes sense or maybe I mistook your reply?

Thanks
 
Last edited:
I thought you wanted to flip the polarity on the fly, i.e. during playback.

If not, then use the alsa route solution as described earlier.

In alsa config (.e.g. $HOME/.asoundrc ):

Code:
pcm.inverted {
         type route
         slave {
                 pcm "hw:0" # the actual soundcard
                 channels 2
         }
	 ttable {
		 0.0= -1 # first channel  inverted (in0 -> out0 * -1)
		 1.1= -1 # second channel  inverted (in1 -> out1 * -1)
	 }
}

And tell your playback software to use the new alsa device called "inverted".

You will have to ask at the picoreplayer forums how to change the read-only filesystem of picorelinux to store the .asoundrc file and change your player config permanently Raspberry Pi .
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.