coreaudio-rs
coreaudio-rs copied to clipboard
Clarify formats when working with input/output scopes on an AudioUnit's input/output elements.
Each audio unit actually has 4 formats:
- Input and output scope formats for the input element.
- Input and output scope formats for the output element.
#47 is related to this but perhaps not general enough in its approach to solving this.
Perhaps we should change stream_format to always require taking the Scope and Element as arguments? cc @plietar
It's been a really long time since I've used CA, so this is just from what I've been able to gather from the docs.
In general AU don't necessarily have one input and output element.
-
For I/O units, there are two elements, input for capture and output for playback. On the input (capture) element only the outputs scope's format is configurable, the input's scope's format is determined from the hardware. On the output (playback) element only the input scope's is used (and only if a render callback is connected. If another AU is connected then that unit's output scope's format is used). The output scope's format is determined from the hardware.
-
For Mixer elements there is a single output element and many inputs. The output element's output scope's sample rate can be configured, but not the rest of the format. The input elements' input scope's format is configurable if a render callback is used, otherwise the connected AU's format is.
I think AudioUnit should only expose set_property/get_property with an integer as the element. stream_format/set_stream_format should be provided by some AU-specific types. For example the IO unit type would expose a set_playback_format and set_capture_format. The Mixer unit type may expose a set_output_sample_rate and a set_input_format for each of it's channels.
Or the AudioUnit could expose the stream_format/set_stream_format methods, but with an integer element and a Scope and it is up to the caller to use the right one.