Skip to content

Commit

Permalink
Test: Added tests StereoPanner
Browse files Browse the repository at this point in the history
  • Loading branch information
gregwht committed Dec 1, 2023
1 parent 5a45555 commit 4ec8bca
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/test_nodes_processors_multichannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,35 @@
import math

def test_nodes_multichannel_pan(graph):
# Test panning left
a = 0.5
b = sf.StereoPanner(a, -1.0)
graph.render_subgraph(b, reset=True)
assert all(b.output_buffer[0] == 0.5)
assert all(b.output_buffer[1] == 0.0)

# Test panning right
a = 0.5
b = sf.StereoPanner(a, 1.0)
graph.render_subgraph(b, reset=True)
assert all(b.output_buffer[0] == 0.0)
assert all(b.output_buffer[1] == 0.5)

# Test panning centre
b.set_input("pan", 0.0)
graph.render_subgraph(b, reset=True)
assert all(b.output_buffer[0] == 0.5 * math.sqrt(0.5))
assert all(b.output_buffer[1] == 0.5 * math.sqrt(0.5))
assert all(b.output_buffer[1] == 0.5 * math.sqrt(0.5))

# # Test panning values beyond range (-1.0, 1.0)
a = 0.5
b = sf.StereoPanner(a, -1.1)
graph.render_subgraph(b, reset=True)
assert all(b.output_buffer[0] == 0.5)
assert all(b.output_buffer[1] == 0.0)

a = 0.5
b = sf.StereoPanner(a, 1.1)
graph.render_subgraph(b, reset=True)
assert all(b.output_buffer[0] == 0.0)
assert all(b.output_buffer[1] == 0.5)

0 comments on commit 4ec8bca

Please sign in to comment.