diff --git a/source/include/signalflow/node/operators/select-input.h b/source/include/signalflow/node/operators/select-input.h index 76437a4c..20895152 100644 --- a/source/include/signalflow/node/operators/select-input.h +++ b/source/include/signalflow/node/operators/select-input.h @@ -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 { diff --git a/tests/test_node_operators.py b/tests/test_node_operators.py index c993e5b0..fbd2c01b 100644 --- a/tests/test_node_operators.py +++ b/tests/test_node_operators.py @@ -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)