Rust Audio

Struggling with CPAL, maybe I should roll my own?

I had been hoping that I would be able to use cpal to:

  • identify and access raw hardware, and discard software layers and emulations
  • identify the real hardware capabilities

Primarily care about alsa, but Windows and BAS (not via emulation) are also important.

Briefly I would want to be able to reproduce the output of:

In particular I’d like to enumerate the native bit depths and sampling frequencies and numbers of selectable channels. (In my case for example the Intel HDMI will only open an even number of channels).

I’m not wanting any channel mapping, sample conversion, sample rate conversion, or mixing. That’s what I want to do in my app - which is a software crossover.

I’m a bit concerned that the API is quite far from allowing me to do this, and that some of the logical modelling in terms of sample sizes and endianness are quite abstracted from what the hardware might offer.

How much appetite is there to materially change the abstractions?

Plenty! If you have some ideas for ways in which you’d like to see CPAL’s API for exposing hardware capabilities improved feel free to open an issue there and share. I think there are already a couple of issues open about the need to improve the way we expose hardware capabilities but from memory there are no solid proposals just yet. The tricky part is coming up with something nice that works on all supported platforms.

This is in alignment with CPAL’s goals too. You might find a case or two of channel layout and/or format conversions behind the scenes, but these are temporary measures until the necessary API is exposed so that they can be removed.

Collaboration would be welcome, but it would be understandable if you wanted to roll your own approach just for the platforms you care about.

OK, I’ll have a think. I’m just learning Rust, but a longtime C++ programmer, so its easy for me to throw in the towel and revert. I should first of all have a play with the ALSA wrappers, I think. Unfortunately I do not have a Mac, and I know a lot of DAW installations use them.