marl / marl/pysox

vol() method of the Transformer class should be able to handle negative gain values

Open
#133 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
540
Forks
83
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at line 3558 in the Transformer.vol() implementation and compare its gain validation with the linked SoX documentation. Verify behavior for negative gain values with the amplitude and power gain types, including signal inversion with gain -1; done means valid negative values no longer raise the reported exception while other invalid values remain handled.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
audio-video-rtc
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.