Skip to content

Commit

Permalink
Merge 517492b into 99de814
Browse files Browse the repository at this point in the history
  • Loading branch information
rabitt committed May 19, 2020
2 parents 99de814 + 517492b commit 94c86b3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sox/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ def mcompand(self, n_bands=2, crossover_frequencies=[1600],
raise ValueError(
"Tuple values in tf_points lists must be <= 0 (dB)."
)
if len(tf_points) > len(set([p[0] for p in tfp])):
if len(tfp) > len(set([p[0] for p in tfp])):
raise ValueError("Found duplicate x-value in tf_points list.")

if not isinstance(gain, list) or len(gain) != n_bands:
Expand Down
29 changes: 29 additions & 0 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,35 @@ def test_tf_points_valid(self):
expected_res = True
self.assertEqual(expected_res, actual_res)

def test_tf_points_valid2(self):
tfm = new_transformer()
tfm.mcompand(
n_bands=3,
crossover_frequencies=[6500, 8000],
attack_time=[0.001, 0.001, 0.001],
decay_time=[0.020, 0.020, 0.020],
soft_knee_db=[None, 2.0, None],
tf_points=[[(-40, -40), (0, 0)],
[(-40, -40), (-30, -38), (-20, -36), (0, -34)],
[(-40, -40), (0, 0)]],
gain=[None, None, None])
actual_args = tfm.effects
expected_args = [
'mcompand',
'0.001000,0.020000 -40.000000,-40.000000,0.000000,0.000000',
'6500.000000',
('0.001000,0.020000 2.000000:-40.000000,-40.000000,-30.000000,' +
'-38.000000,-20.000000,-36.000000,0.000000,-34.000000'),
'8000.000000',
'0.001000,0.020000 -40.000000,-40.000000,0.000000,0.000000'
]

self.assertEqual(expected_args, actual_args)

actual_res = tfm.build(INPUT_FILE, OUTPUT_FILE)
expected_res = True
self.assertEqual(expected_res, actual_res)

def test_tf_points_wrong_len(self):
tfm = new_transformer()
with self.assertRaises(ValueError):
Expand Down

0 comments on commit 94c86b3

Please sign in to comment.