ideoforms / signalflow

A sound synthesis framework for Python, designed for clear and concise expression of musical ideas
https://signalflow.dev
Other
179 stars 14 forks source link

Support multiple AudioIn channels, honour input_device_name #117

Open jarmitage opened 4 months ago

jarmitage commented 4 months ago

https://github.com/ideoforms/signalflow/blob/af49b099675be2bc8de04815a5416fc3fe3790a8/source/src/node/io/input/abstract.cpp#L10

ideoforms commented 4 months ago

Funnily enough, you raised this at the precise moment that I also need this feature so I'm working on this as I speak. Should be done later today!

ideoforms commented 4 months ago

OK, I looked at this and unforunately it's a larger refactor than I have time to do right now as i'm on a project deadline. However! You can achieve the same effect with a workaround, which is what I'm doing:

# read the full multichannel input here
all_input_channels = AudioIn(8)
# then use the subscript operator to select individual mono channels
first_channel = all_input_channels[0]
second_channel = all_input_channels[1]

I'll leave this issue open to remind me to fix it properly at some point...

jarmitage commented 4 months ago

I can't get all_input_channels = AudioIn(8) to work:

python signalflow-examples/audio-through-example.py
Output device: BlackHole 64ch (44100Hz, buffer size 4096 samples, 24 channels)
Traceback (most recent call last):
  File "../signalflow-examples/audio-through-example.py", line 34, in <module>
    main()
  File "../signalflow-examples/audio-through-example.py", line 21, in main
    audio_in = AudioIn(8)
               ^^^^^^^^^^
signalflow.AudioIOException: AudioIn: Not enough input channels available (requested 8, available 1)
[1]    35077 segmentation fault  python signalflow-examples/audio-through-example.py
ideoforms commented 3 months ago

Hmm, this would happen if the audio input device of SignalFlow has fewer than 8 channels. If you set your system's default input device to (say) BlackHole 64ch, this should resolve the issue.

In investigating this, I've also found that input_device_name is not honoured in .signalflow/config (or SIGNALFLOW_INPUT_BUFFER_SIZE), which should be addressed in the same fix as for the wider AudioIn issue.