Fix ChorusEffect (#91)

To make properties properly raise ValueError
This commit is contained in:
Ngô Xuân Minh 2020-05-03 20:53:57 +07:00 committed by GitHub
parent 11cda099a3
commit b39aaa9903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -2383,6 +2383,8 @@ cdef class ChorusEffect(BaseEffect):
@phase.setter
def phase(self, value: int) -> None:
if value < -180 or value > 180:
raise ValueError(f'invalid phase: {value}')
self.properties.phase = value
self.impl.set_chorus_properties(self.properties)
self.slot.apply_effect(self.impl)
@ -2394,6 +2396,8 @@ cdef class ChorusEffect(BaseEffect):
@depth.setter
def depth(self, value: float) -> None:
if value < 0.0 or value > 1.0:
raise ValueError(f'invalid depth: {value}')
self.properties.depth = value
self.impl.set_chorus_properties(self.properties)
self.slot.apply_effect(self.impl)
@ -2405,6 +2409,8 @@ cdef class ChorusEffect(BaseEffect):
@feedback.setter
def feedback(self, value: float) -> None:
if value < -1.0 or value > 1.0:
raise ValueError(f'invalid feedback: {value}')
self.properties.feedback = value
self.impl.set_chorus_properties(self.properties)
self.slot.apply_effect(self.impl)
@ -2416,6 +2422,8 @@ cdef class ChorusEffect(BaseEffect):
@delay.setter
def delay(self, value: float) -> None:
if value < 0.0 or value > 0.016:
raise ValueError(f'invalid delay: {value}')
self.properties.delay = value
self.impl.set_chorus_properties(self.properties)
self.slot.apply_effect(self.impl)

View File

@ -413,7 +413,6 @@ def test_chorus_waveform(context):
with raises(ValueError): fx.waveform = 'ABC'
@mark.xfail
def test_chorus_phase(context):
"""Test ChorusEffect's property phase."""
with ChorusEffect() as fx:
@ -439,7 +438,6 @@ def test_chorus_rate(context):
with raises(ValueError): fx.rate = -1
@mark.xfail
def test_chorus_depth(context):
"""Test ChorusEffect's property depth."""
with ChorusEffect() as fx:
@ -452,7 +450,6 @@ def test_chorus_depth(context):
with raises(ValueError): fx.depth = -1
@mark.xfail
def test_chorus_feedback(context):
"""Test ChorusEffect's property feedback."""
with ChorusEffect() as fx:
@ -465,7 +462,6 @@ def test_chorus_feedback(context):
with raises(ValueError): fx.feedback = -7/5
@mark.xfail
def test_chorus_delay(context):
"""Test ChorusEffect's property delay."""
with ChorusEffect() as fx: