Python package: sox==1.4.1
Python version: 3.6
OS: Windows 10
sox cmd line utility version: 14.4.2
The current implementation of the vol() method from the Transformer class throws an exception if the gain argument is set to a negative value. According to sox documentation from https://linux.die.net/man/1/sox it should be possible to set a negative gain value when is the gain type is selected as "amplitude" or "power".
One useful application of using a negative gain value is signal inversion. When I changed line 3558 as below and set the gain argument to -1 I was able to invert the input audio signal:
if gain_type in ['amplitude', 'power'] and gain < 0 and gain != -1:
raise ValueError(
"If gain_type = amplitude or power, gain must be positive."
)
Unless there is another way of performing signal inversion using another Transformer method, the above conditional statement can be modified to accept negative values.
Python package: sox==1.4.1 Python version: 3.6 OS: Windows 10 sox cmd line utility version: 14.4.2
The current implementation of the vol() method from the Transformer class throws an exception if the gain argument is set to a negative value. According to sox documentation from https://linux.die.net/man/1/sox it should be possible to set a negative gain value when is the gain type is selected as "amplitude" or "power".
One useful application of using a negative gain value is signal inversion. When I changed line 3558 as below and set the gain argument to -1 I was able to invert the input audio signal:
if gain_type in ['amplitude', 'power'] and gain < 0 and gain != -1: raise ValueError( "If gain_type = amplitude or power, gain must be positive." )
Unless there is another way of performing signal inversion using another Transformer method, the above conditional statement can be modified to accept negative values.