Skip to content

Commit

Permalink
SelectInput: Docs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Aug 16, 2024
1 parent 32e2990 commit 4e5bbed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/include/signalflow/node/operators/select-input.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ namespace signalflow
{

/**--------------------------------------------------------------------------------*
* Generates the
* Pass through the output of one or more `inputs`, based on the integer input index
* specified in `index`. Unlike `ChannelSelect`, inputs may be multichannel,
* and `index` can be modulated in real time.
*---------------------------------------------------------------------------------*/
class SelectInput : public VariableInputNode
{
Expand Down
19 changes: 19 additions & 0 deletions tests/test_node_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,22 @@ def test_select_input(graph):
assert np.all(a.output_buffer[0][4:8] == 2)
assert np.all(a.output_buffer[0][8:12] == 3)
assert np.all(a.output_buffer[0][12:16] == 1)

# test multichannel upmix behaviour -
# should always honour the max number of input channels
a = ChannelArray([1, 2])
b = Constant(3)
c = SelectInput([a, b], index=0)
assert a.num_output_channels == 2
assert b.num_output_channels == 1
assert c.index.num_output_channels == 1
assert c.num_output_channels == 2

graph.render_subgraph(c, reset=True)
assert np.all(c.output_buffer[0] == 1)
assert np.all(c.output_buffer[1] == 2)

c.index = 1
graph.render_subgraph(c, reset=True)
assert np.all(c.output_buffer[0] == 3)
assert np.all(c.output_buffer[1] == 3)

0 comments on commit 4e5bbed

Please sign in to comment.